intrinsic.texi revision 1.1 1 1.1 mrg @ignore
2 1.1 mrg Copyright (C) 2005-2019 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 mrg @ref{EXIT}, @ref{KILL}, @ref{BACKTRACE}
407 1.1 mrg
408 1.1 mrg @end table
409 1.1 mrg
410 1.1 mrg
411 1.1 mrg
412 1.1 mrg @node ABS
413 1.1 mrg @section @code{ABS} --- Absolute value
414 1.1 mrg @fnindex ABS
415 1.1 mrg @fnindex CABS
416 1.1 mrg @fnindex DABS
417 1.1 mrg @fnindex IABS
418 1.1 mrg @fnindex ZABS
419 1.1 mrg @fnindex CDABS
420 1.1 mrg @fnindex BABS
421 1.1 mrg @fnindex IIABS
422 1.1 mrg @fnindex JIABS
423 1.1 mrg @fnindex KIABS
424 1.1 mrg @cindex absolute value
425 1.1 mrg
426 1.1 mrg @table @asis
427 1.1 mrg @item @emph{Description}:
428 1.1 mrg @code{ABS(A)} computes the absolute value of @code{A}.
429 1.1 mrg
430 1.1 mrg @item @emph{Standard}:
431 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
432 1.1 mrg
433 1.1 mrg @item @emph{Class}:
434 1.1 mrg Elemental function
435 1.1 mrg
436 1.1 mrg @item @emph{Syntax}:
437 1.1 mrg @code{RESULT = ABS(A)}
438 1.1 mrg
439 1.1 mrg @item @emph{Arguments}:
440 1.1 mrg @multitable @columnfractions .15 .70
441 1.1 mrg @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
442 1.1 mrg @code{REAL}, or @code{COMPLEX}.
443 1.1 mrg @end multitable
444 1.1 mrg
445 1.1 mrg @item @emph{Return value}:
446 1.1 mrg The return value is of the same type and
447 1.1 mrg kind as the argument except the return value is @code{REAL} for a
448 1.1 mrg @code{COMPLEX} argument.
449 1.1 mrg
450 1.1 mrg @item @emph{Example}:
451 1.1 mrg @smallexample
452 1.1 mrg program test_abs
453 1.1 mrg integer :: i = -1
454 1.1 mrg real :: x = -1.e0
455 1.1 mrg complex :: z = (-1.e0,0.e0)
456 1.1 mrg i = abs(i)
457 1.1 mrg x = abs(x)
458 1.1 mrg x = abs(z)
459 1.1 mrg end program test_abs
460 1.1 mrg @end smallexample
461 1.1 mrg
462 1.1 mrg @item @emph{Specific names}:
463 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
464 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
465 1.1 mrg @item @code{ABS(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
466 1.1 mrg @item @code{CABS(A)} @tab @code{COMPLEX(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
467 1.1 mrg @item @code{DABS(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
468 1.1 mrg @item @code{IABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
469 1.1 mrg @item @code{BABS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
470 1.1 mrg @item @code{IIABS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
471 1.1 mrg @item @code{JIABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
472 1.1 mrg @item @code{KIABS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
473 1.1 mrg @item @code{ZABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
474 1.1 mrg @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
475 1.1 mrg @end multitable
476 1.1 mrg @end table
477 1.1 mrg
478 1.1 mrg
479 1.1 mrg
480 1.1 mrg @node ACCESS
481 1.1 mrg @section @code{ACCESS} --- Checks file access modes
482 1.1 mrg @fnindex ACCESS
483 1.1 mrg @cindex file system, access mode
484 1.1 mrg
485 1.1 mrg @table @asis
486 1.1 mrg @item @emph{Description}:
487 1.1 mrg @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
488 1.1 mrg exists, is readable, writable or executable. Except for the
489 1.1 mrg executable check, @code{ACCESS} can be replaced by
490 1.1 mrg Fortran 95's @code{INQUIRE}.
491 1.1 mrg
492 1.1 mrg @item @emph{Standard}:
493 1.1 mrg GNU extension
494 1.1 mrg
495 1.1 mrg @item @emph{Class}:
496 1.1 mrg Inquiry function
497 1.1 mrg
498 1.1 mrg @item @emph{Syntax}:
499 1.1 mrg @code{RESULT = ACCESS(NAME, MODE)}
500 1.1 mrg
501 1.1 mrg @item @emph{Arguments}:
502 1.1 mrg @multitable @columnfractions .15 .70
503 1.1 mrg @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
504 1.1 mrg file name. Tailing blank are ignored unless the character @code{achar(0)}
505 1.1 mrg is present, then all characters up to and excluding @code{achar(0)} are
506 1.1 mrg used as file name.
507 1.1 mrg @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
508 1.1 mrg file access mode, may be any concatenation of @code{"r"} (readable),
509 1.1 mrg @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
510 1.1 mrg for existence.
511 1.1 mrg @end multitable
512 1.1 mrg
513 1.1 mrg @item @emph{Return value}:
514 1.1 mrg Returns a scalar @code{INTEGER}, which is @code{0} if the file is
515 1.1 mrg accessible in the given mode; otherwise or if an invalid argument
516 1.1 mrg has been given for @code{MODE} the value @code{1} is returned.
517 1.1 mrg
518 1.1 mrg @item @emph{Example}:
519 1.1 mrg @smallexample
520 1.1 mrg program access_test
521 1.1 mrg implicit none
522 1.1 mrg character(len=*), parameter :: file = 'test.dat'
523 1.1 mrg character(len=*), parameter :: file2 = 'test.dat '//achar(0)
524 1.1 mrg if(access(file,' ') == 0) print *, trim(file),' is exists'
525 1.1 mrg if(access(file,'r') == 0) print *, trim(file),' is readable'
526 1.1 mrg if(access(file,'w') == 0) print *, trim(file),' is writable'
527 1.1 mrg if(access(file,'x') == 0) print *, trim(file),' is executable'
528 1.1 mrg if(access(file2,'rwx') == 0) &
529 1.1 mrg print *, trim(file2),' is readable, writable and executable'
530 1.1 mrg end program access_test
531 1.1 mrg @end smallexample
532 1.1 mrg @item @emph{Specific names}:
533 1.1 mrg @item @emph{See also}:
534 1.1 mrg
535 1.1 mrg @end table
536 1.1 mrg
537 1.1 mrg
538 1.1 mrg
539 1.1 mrg @node ACHAR
540 1.1 mrg @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
541 1.1 mrg @fnindex ACHAR
542 1.1 mrg @cindex @acronym{ASCII} collating sequence
543 1.1 mrg @cindex collating sequence, @acronym{ASCII}
544 1.1 mrg
545 1.1 mrg @table @asis
546 1.1 mrg @item @emph{Description}:
547 1.1 mrg @code{ACHAR(I)} returns the character located at position @code{I}
548 1.1 mrg in the @acronym{ASCII} collating sequence.
549 1.1 mrg
550 1.1 mrg @item @emph{Standard}:
551 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
552 1.1 mrg
553 1.1 mrg @item @emph{Class}:
554 1.1 mrg Elemental function
555 1.1 mrg
556 1.1 mrg @item @emph{Syntax}:
557 1.1 mrg @code{RESULT = ACHAR(I [, KIND])}
558 1.1 mrg
559 1.1 mrg @item @emph{Arguments}:
560 1.1 mrg @multitable @columnfractions .15 .70
561 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
562 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
563 1.1 mrg expression indicating the kind parameter of the result.
564 1.1 mrg @end multitable
565 1.1 mrg
566 1.1 mrg @item @emph{Return value}:
567 1.1 mrg The return value is of type @code{CHARACTER} with a length of one.
568 1.1 mrg If the @var{KIND} argument is present, the return value is of the
569 1.1 mrg specified kind and of the default kind otherwise.
570 1.1 mrg
571 1.1 mrg @item @emph{Example}:
572 1.1 mrg @smallexample
573 1.1 mrg program test_achar
574 1.1 mrg character c
575 1.1 mrg c = achar(32)
576 1.1 mrg end program test_achar
577 1.1 mrg @end smallexample
578 1.1 mrg
579 1.1 mrg @item @emph{Note}:
580 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values
581 1.1 mrg and formatted string representations.
582 1.1 mrg
583 1.1 mrg @item @emph{See also}:
584 1.1 mrg @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
585 1.1 mrg
586 1.1 mrg @end table
587 1.1 mrg
588 1.1 mrg
589 1.1 mrg
590 1.1 mrg @node ACOS
591 1.1 mrg @section @code{ACOS} --- Arccosine function
592 1.1 mrg @fnindex ACOS
593 1.1 mrg @fnindex DACOS
594 1.1 mrg @cindex trigonometric function, cosine, inverse
595 1.1 mrg @cindex cosine, inverse
596 1.1 mrg
597 1.1 mrg @table @asis
598 1.1 mrg @item @emph{Description}:
599 1.1 mrg @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
600 1.1 mrg
601 1.1 mrg @item @emph{Standard}:
602 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
603 1.1 mrg
604 1.1 mrg @item @emph{Class}:
605 1.1 mrg Elemental function
606 1.1 mrg
607 1.1 mrg @item @emph{Syntax}:
608 1.1 mrg @code{RESULT = ACOS(X)}
609 1.1 mrg
610 1.1 mrg @item @emph{Arguments}:
611 1.1 mrg @multitable @columnfractions .15 .70
612 1.1 mrg @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
613 1.1 mrg less than or equal to one - or the type shall be @code{COMPLEX}.
614 1.1 mrg @end multitable
615 1.1 mrg
616 1.1 mrg @item @emph{Return value}:
617 1.1 mrg The return value is of the same type and kind as @var{X}.
618 1.1 mrg The real part of the result is in radians and lies in the range
619 1.1 mrg @math{0 \leq \Re \acos(x) \leq \pi}.
620 1.1 mrg
621 1.1 mrg @item @emph{Example}:
622 1.1 mrg @smallexample
623 1.1 mrg program test_acos
624 1.1 mrg real(8) :: x = 0.866_8
625 1.1 mrg x = acos(x)
626 1.1 mrg end program test_acos
627 1.1 mrg @end smallexample
628 1.1 mrg
629 1.1 mrg @item @emph{Specific names}:
630 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
631 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
632 1.1 mrg @item @code{ACOS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
633 1.1 mrg @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
634 1.1 mrg @end multitable
635 1.1 mrg
636 1.1 mrg @item @emph{See also}:
637 1.1 mrg Inverse function: @ref{COS}
638 1.1 mrg Degrees function: @ref{ACOSD}
639 1.1 mrg
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 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 mrg @item @code{ACOSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
691 1.1 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 mrg Inverse function: @ref{COSD}
696 1.1 mrg Radians function: @ref{ACOS}
697 1.1 mrg
698 1.1 mrg @end table
699 1.1 mrg
700 1.1 mrg
701 1.1 mrg
702 1.1 mrg @node ACOSH
703 1.1 mrg @section @code{ACOSH} --- Inverse hyperbolic cosine function
704 1.1 mrg @fnindex ACOSH
705 1.1 mrg @fnindex DACOSH
706 1.1 mrg @cindex area hyperbolic cosine
707 1.1 mrg @cindex inverse hyperbolic cosine
708 1.1 mrg @cindex hyperbolic function, cosine, inverse
709 1.1 mrg @cindex cosine, hyperbolic, inverse
710 1.1 mrg
711 1.1 mrg @table @asis
712 1.1 mrg @item @emph{Description}:
713 1.1 mrg @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
714 1.1 mrg
715 1.1 mrg @item @emph{Standard}:
716 1.1 mrg Fortran 2008 and later
717 1.1 mrg
718 1.1 mrg @item @emph{Class}:
719 1.1 mrg Elemental function
720 1.1 mrg
721 1.1 mrg @item @emph{Syntax}:
722 1.1 mrg @code{RESULT = ACOSH(X)}
723 1.1 mrg
724 1.1 mrg @item @emph{Arguments}:
725 1.1 mrg @multitable @columnfractions .15 .70
726 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
727 1.1 mrg @end multitable
728 1.1 mrg
729 1.1 mrg @item @emph{Return value}:
730 1.1 mrg The return value has the same type and kind as @var{X}. If @var{X} is
731 1.1 mrg complex, the imaginary part of the result is in radians and lies between
732 1.1 mrg @math{ 0 \leq \Im \acosh(x) \leq \pi}.
733 1.1 mrg
734 1.1 mrg @item @emph{Example}:
735 1.1 mrg @smallexample
736 1.1 mrg PROGRAM test_acosh
737 1.1 mrg REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
738 1.1 mrg WRITE (*,*) ACOSH(x)
739 1.1 mrg END PROGRAM
740 1.1 mrg @end smallexample
741 1.1 mrg
742 1.1 mrg @item @emph{Specific names}:
743 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
744 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
745 1.1 mrg @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
746 1.1 mrg @end multitable
747 1.1 mrg
748 1.1 mrg @item @emph{See also}:
749 1.1 mrg Inverse function: @ref{COSH}
750 1.1 mrg @end table
751 1.1 mrg
752 1.1 mrg
753 1.1 mrg
754 1.1 mrg @node ADJUSTL
755 1.1 mrg @section @code{ADJUSTL} --- Left adjust a string
756 1.1 mrg @fnindex ADJUSTL
757 1.1 mrg @cindex string, adjust left
758 1.1 mrg @cindex adjust string
759 1.1 mrg
760 1.1 mrg @table @asis
761 1.1 mrg @item @emph{Description}:
762 1.1 mrg @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
763 1.1 mrg Spaces are inserted at the end of the string as needed.
764 1.1 mrg
765 1.1 mrg @item @emph{Standard}:
766 1.1 mrg Fortran 90 and later
767 1.1 mrg
768 1.1 mrg @item @emph{Class}:
769 1.1 mrg Elemental function
770 1.1 mrg
771 1.1 mrg @item @emph{Syntax}:
772 1.1 mrg @code{RESULT = ADJUSTL(STRING)}
773 1.1 mrg
774 1.1 mrg @item @emph{Arguments}:
775 1.1 mrg @multitable @columnfractions .15 .70
776 1.1 mrg @item @var{STRING} @tab The type shall be @code{CHARACTER}.
777 1.1 mrg @end multitable
778 1.1 mrg
779 1.1 mrg @item @emph{Return value}:
780 1.1 mrg The return value is of type @code{CHARACTER} and of the same kind as
781 1.1 mrg @var{STRING} where leading spaces are removed and the same number of
782 1.1 mrg spaces are inserted on the end of @var{STRING}.
783 1.1 mrg
784 1.1 mrg @item @emph{Example}:
785 1.1 mrg @smallexample
786 1.1 mrg program test_adjustl
787 1.1 mrg character(len=20) :: str = ' gfortran'
788 1.1 mrg str = adjustl(str)
789 1.1 mrg print *, str
790 1.1 mrg end program test_adjustl
791 1.1 mrg @end smallexample
792 1.1 mrg
793 1.1 mrg @item @emph{See also}:
794 1.1 mrg @ref{ADJUSTR}, @ref{TRIM}
795 1.1 mrg @end table
796 1.1 mrg
797 1.1 mrg
798 1.1 mrg
799 1.1 mrg @node ADJUSTR
800 1.1 mrg @section @code{ADJUSTR} --- Right adjust a string
801 1.1 mrg @fnindex ADJUSTR
802 1.1 mrg @cindex string, adjust right
803 1.1 mrg @cindex adjust string
804 1.1 mrg
805 1.1 mrg @table @asis
806 1.1 mrg @item @emph{Description}:
807 1.1 mrg @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
808 1.1 mrg Spaces are inserted at the start of the string as needed.
809 1.1 mrg
810 1.1 mrg @item @emph{Standard}:
811 1.1 mrg Fortran 95 and later
812 1.1 mrg
813 1.1 mrg @item @emph{Class}:
814 1.1 mrg Elemental function
815 1.1 mrg
816 1.1 mrg @item @emph{Syntax}:
817 1.1 mrg @code{RESULT = ADJUSTR(STRING)}
818 1.1 mrg
819 1.1 mrg @item @emph{Arguments}:
820 1.1 mrg @multitable @columnfractions .15 .70
821 1.1 mrg @item @var{STR} @tab The type shall be @code{CHARACTER}.
822 1.1 mrg @end multitable
823 1.1 mrg
824 1.1 mrg @item @emph{Return value}:
825 1.1 mrg The return value is of type @code{CHARACTER} and of the same kind as
826 1.1 mrg @var{STRING} where trailing spaces are removed and the same number of
827 1.1 mrg spaces are inserted at the start of @var{STRING}.
828 1.1 mrg
829 1.1 mrg @item @emph{Example}:
830 1.1 mrg @smallexample
831 1.1 mrg program test_adjustr
832 1.1 mrg character(len=20) :: str = 'gfortran'
833 1.1 mrg str = adjustr(str)
834 1.1 mrg print *, str
835 1.1 mrg end program test_adjustr
836 1.1 mrg @end smallexample
837 1.1 mrg
838 1.1 mrg @item @emph{See also}:
839 1.1 mrg @ref{ADJUSTL}, @ref{TRIM}
840 1.1 mrg @end table
841 1.1 mrg
842 1.1 mrg
843 1.1 mrg
844 1.1 mrg @node AIMAG
845 1.1 mrg @section @code{AIMAG} --- Imaginary part of complex number
846 1.1 mrg @fnindex AIMAG
847 1.1 mrg @fnindex DIMAG
848 1.1 mrg @fnindex IMAG
849 1.1 mrg @fnindex IMAGPART
850 1.1 mrg @cindex complex numbers, imaginary part
851 1.1 mrg
852 1.1 mrg @table @asis
853 1.1 mrg @item @emph{Description}:
854 1.1 mrg @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
855 1.1 mrg The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
856 1.1 mrg for compatibility with @command{g77}, and their use in new code is
857 1.1 mrg strongly discouraged.
858 1.1 mrg
859 1.1 mrg @item @emph{Standard}:
860 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
861 1.1 mrg
862 1.1 mrg @item @emph{Class}:
863 1.1 mrg Elemental function
864 1.1 mrg
865 1.1 mrg @item @emph{Syntax}:
866 1.1 mrg @code{RESULT = AIMAG(Z)}
867 1.1 mrg
868 1.1 mrg @item @emph{Arguments}:
869 1.1 mrg @multitable @columnfractions .15 .70
870 1.1 mrg @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
871 1.1 mrg @end multitable
872 1.1 mrg
873 1.1 mrg @item @emph{Return value}:
874 1.1 mrg The return value is of type @code{REAL} with the
875 1.1 mrg kind type parameter of the argument.
876 1.1 mrg
877 1.1 mrg @item @emph{Example}:
878 1.1 mrg @smallexample
879 1.1 mrg program test_aimag
880 1.1 mrg complex(4) z4
881 1.1 mrg complex(8) z8
882 1.1 mrg z4 = cmplx(1.e0_4, 0.e0_4)
883 1.1 mrg z8 = cmplx(0.e0_8, 1.e0_8)
884 1.1 mrg print *, aimag(z4), dimag(z8)
885 1.1 mrg end program test_aimag
886 1.1 mrg @end smallexample
887 1.1 mrg
888 1.1 mrg @item @emph{Specific names}:
889 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
890 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
891 1.1 mrg @item @code{AIMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
892 1.1 mrg @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
893 1.1 mrg @item @code{IMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
894 1.1 mrg @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
895 1.1 mrg @end multitable
896 1.1 mrg @end table
897 1.1 mrg
898 1.1 mrg
899 1.1 mrg
900 1.1 mrg @node AINT
901 1.1 mrg @section @code{AINT} --- Truncate to a whole number
902 1.1 mrg @fnindex AINT
903 1.1 mrg @fnindex DINT
904 1.1 mrg @cindex floor
905 1.1 mrg @cindex rounding, floor
906 1.1 mrg
907 1.1 mrg @table @asis
908 1.1 mrg @item @emph{Description}:
909 1.1 mrg @code{AINT(A [, KIND])} truncates its argument to a whole number.
910 1.1 mrg
911 1.1 mrg @item @emph{Standard}:
912 1.1 mrg Fortran 77 and later
913 1.1 mrg
914 1.1 mrg @item @emph{Class}:
915 1.1 mrg Elemental function
916 1.1 mrg
917 1.1 mrg @item @emph{Syntax}:
918 1.1 mrg @code{RESULT = AINT(A [, KIND])}
919 1.1 mrg
920 1.1 mrg @item @emph{Arguments}:
921 1.1 mrg @multitable @columnfractions .15 .70
922 1.1 mrg @item @var{A} @tab The type of the argument shall be @code{REAL}.
923 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
924 1.1 mrg expression indicating the kind parameter of the result.
925 1.1 mrg @end multitable
926 1.1 mrg
927 1.1 mrg @item @emph{Return value}:
928 1.1 mrg The return value is of type @code{REAL} with the kind type parameter of the
929 1.1 mrg argument if the optional @var{KIND} is absent; otherwise, the kind
930 1.1 mrg type parameter will be given by @var{KIND}. If the magnitude of
931 1.1 mrg @var{X} is less than one, @code{AINT(X)} returns zero. If the
932 1.1 mrg magnitude is equal to or greater than one then it returns the largest
933 1.1 mrg whole number that does not exceed its magnitude. The sign is the same
934 1.1 mrg as the sign of @var{X}.
935 1.1 mrg
936 1.1 mrg @item @emph{Example}:
937 1.1 mrg @smallexample
938 1.1 mrg program test_aint
939 1.1 mrg real(4) x4
940 1.1 mrg real(8) x8
941 1.1 mrg x4 = 1.234E0_4
942 1.1 mrg x8 = 4.321_8
943 1.1 mrg print *, aint(x4), dint(x8)
944 1.1 mrg x8 = aint(x4,8)
945 1.1 mrg end program test_aint
946 1.1 mrg @end smallexample
947 1.1 mrg
948 1.1 mrg @item @emph{Specific names}:
949 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
950 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
951 1.1 mrg @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
952 1.1 mrg @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
953 1.1 mrg @end multitable
954 1.1 mrg @end table
955 1.1 mrg
956 1.1 mrg
957 1.1 mrg
958 1.1 mrg @node ALARM
959 1.1 mrg @section @code{ALARM} --- Execute a routine after a given delay
960 1.1 mrg @fnindex ALARM
961 1.1 mrg @cindex delayed execution
962 1.1 mrg
963 1.1 mrg @table @asis
964 1.1 mrg @item @emph{Description}:
965 1.1 mrg @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
966 1.1 mrg to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
967 1.1 mrg set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
968 1.1 mrg supplied, it will be returned with the number of seconds remaining until
969 1.1 mrg any previously scheduled alarm was due to be delivered, or zero if there
970 1.1 mrg was no previously scheduled alarm.
971 1.1 mrg
972 1.1 mrg @item @emph{Standard}:
973 1.1 mrg GNU extension
974 1.1 mrg
975 1.1 mrg @item @emph{Class}:
976 1.1 mrg Subroutine
977 1.1 mrg
978 1.1 mrg @item @emph{Syntax}:
979 1.1 mrg @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
980 1.1 mrg
981 1.1 mrg @item @emph{Arguments}:
982 1.1 mrg @multitable @columnfractions .15 .70
983 1.1 mrg @item @var{SECONDS} @tab The type of the argument shall be a scalar
984 1.1 mrg @code{INTEGER}. It is @code{INTENT(IN)}.
985 1.1 mrg @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
986 1.1 mrg @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
987 1.1 mrg values may be either @code{SIG_IGN=1} to ignore the alarm generated
988 1.1 mrg or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
989 1.1 mrg @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
990 1.1 mrg variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
991 1.1 mrg @end multitable
992 1.1 mrg
993 1.1 mrg @item @emph{Example}:
994 1.1 mrg @smallexample
995 1.1 mrg program test_alarm
996 1.1 mrg external handler_print
997 1.1 mrg integer i
998 1.1 mrg call alarm (3, handler_print, i)
999 1.1 mrg print *, i
1000 1.1 mrg call sleep(10)
1001 1.1 mrg end program test_alarm
1002 1.1 mrg @end smallexample
1003 1.1 mrg This will cause the external routine @var{handler_print} to be called
1004 1.1 mrg after 3 seconds.
1005 1.1 mrg @end table
1006 1.1 mrg
1007 1.1 mrg
1008 1.1 mrg
1009 1.1 mrg @node ALL
1010 1.1 mrg @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
1011 1.1 mrg @fnindex ALL
1012 1.1 mrg @cindex array, apply condition
1013 1.1 mrg @cindex array, condition testing
1014 1.1 mrg
1015 1.1 mrg @table @asis
1016 1.1 mrg @item @emph{Description}:
1017 1.1 mrg @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
1018 1.1 mrg in the array along dimension @var{DIM}.
1019 1.1 mrg
1020 1.1 mrg @item @emph{Standard}:
1021 1.1 mrg Fortran 95 and later
1022 1.1 mrg
1023 1.1 mrg @item @emph{Class}:
1024 1.1 mrg Transformational function
1025 1.1 mrg
1026 1.1 mrg @item @emph{Syntax}:
1027 1.1 mrg @code{RESULT = ALL(MASK [, DIM])}
1028 1.1 mrg
1029 1.1 mrg @item @emph{Arguments}:
1030 1.1 mrg @multitable @columnfractions .15 .70
1031 1.1 mrg @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1032 1.1 mrg it shall not be scalar.
1033 1.1 mrg @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1034 1.1 mrg with a value that lies between one and the rank of @var{MASK}.
1035 1.1 mrg @end multitable
1036 1.1 mrg
1037 1.1 mrg @item @emph{Return value}:
1038 1.1 mrg @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
1039 1.1 mrg the kind type parameter is the same as the kind type parameter of
1040 1.1 mrg @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
1041 1.1 mrg an array with the rank of @var{MASK} minus 1. The shape is determined from
1042 1.1 mrg the shape of @var{MASK} where the @var{DIM} dimension is elided.
1043 1.1 mrg
1044 1.1 mrg @table @asis
1045 1.1 mrg @item (A)
1046 1.1 mrg @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
1047 1.1 mrg It also is true if @var{MASK} has zero size; otherwise, it is false.
1048 1.1 mrg @item (B)
1049 1.1 mrg If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
1050 1.1 mrg to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
1051 1.1 mrg is determined by applying @code{ALL} to the array sections.
1052 1.1 mrg @end table
1053 1.1 mrg
1054 1.1 mrg @item @emph{Example}:
1055 1.1 mrg @smallexample
1056 1.1 mrg program test_all
1057 1.1 mrg logical l
1058 1.1 mrg l = all((/.true., .true., .true./))
1059 1.1 mrg print *, l
1060 1.1 mrg call section
1061 1.1 mrg contains
1062 1.1 mrg subroutine section
1063 1.1 mrg integer a(2,3), b(2,3)
1064 1.1 mrg a = 1
1065 1.1 mrg b = 1
1066 1.1 mrg b(2,2) = 2
1067 1.1 mrg print *, all(a .eq. b, 1)
1068 1.1 mrg print *, all(a .eq. b, 2)
1069 1.1 mrg end subroutine section
1070 1.1 mrg end program test_all
1071 1.1 mrg @end smallexample
1072 1.1 mrg @end table
1073 1.1 mrg
1074 1.1 mrg
1075 1.1 mrg
1076 1.1 mrg @node ALLOCATED
1077 1.1 mrg @section @code{ALLOCATED} --- Status of an allocatable entity
1078 1.1 mrg @fnindex ALLOCATED
1079 1.1 mrg @cindex allocation, status
1080 1.1 mrg
1081 1.1 mrg @table @asis
1082 1.1 mrg @item @emph{Description}:
1083 1.1 mrg @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
1084 1.1 mrg status of @var{ARRAY} and @var{SCALAR}, respectively.
1085 1.1 mrg
1086 1.1 mrg @item @emph{Standard}:
1087 1.1 mrg Fortran 95 and later. Note, the @code{SCALAR=} keyword and allocatable
1088 1.1 mrg scalar entities are available in Fortran 2003 and later.
1089 1.1 mrg
1090 1.1 mrg @item @emph{Class}:
1091 1.1 mrg Inquiry function
1092 1.1 mrg
1093 1.1 mrg @item @emph{Syntax}:
1094 1.1 mrg @multitable @columnfractions .80
1095 1.1 mrg @item @code{RESULT = ALLOCATED(ARRAY)}
1096 1.1 mrg @item @code{RESULT = ALLOCATED(SCALAR)}
1097 1.1 mrg @end multitable
1098 1.1 mrg
1099 1.1 mrg @item @emph{Arguments}:
1100 1.1 mrg @multitable @columnfractions .15 .70
1101 1.1 mrg @item @var{ARRAY} @tab The argument shall be an @code{ALLOCATABLE} array.
1102 1.1 mrg @item @var{SCALAR} @tab The argument shall be an @code{ALLOCATABLE} scalar.
1103 1.1 mrg @end multitable
1104 1.1 mrg
1105 1.1 mrg @item @emph{Return value}:
1106 1.1 mrg The return value is a scalar @code{LOGICAL} with the default logical
1107 1.1 mrg kind type parameter. If the argument is allocated, then the result is
1108 1.1 mrg @code{.TRUE.}; otherwise, it returns @code{.FALSE.}
1109 1.1 mrg
1110 1.1 mrg @item @emph{Example}:
1111 1.1 mrg @smallexample
1112 1.1 mrg program test_allocated
1113 1.1 mrg integer :: i = 4
1114 1.1 mrg real(4), allocatable :: x(:)
1115 1.1 mrg if (.not. allocated(x)) allocate(x(i))
1116 1.1 mrg end program test_allocated
1117 1.1 mrg @end smallexample
1118 1.1 mrg @end table
1119 1.1 mrg
1120 1.1 mrg
1121 1.1 mrg
1122 1.1 mrg @node AND
1123 1.1 mrg @section @code{AND} --- Bitwise logical AND
1124 1.1 mrg @fnindex AND
1125 1.1 mrg @cindex bitwise logical and
1126 1.1 mrg @cindex logical and, bitwise
1127 1.1 mrg
1128 1.1 mrg @table @asis
1129 1.1 mrg @item @emph{Description}:
1130 1.1 mrg Bitwise logical @code{AND}.
1131 1.1 mrg
1132 1.1 mrg This intrinsic routine is provided for backwards compatibility with
1133 1.1 mrg GNU Fortran 77. For integer arguments, programmers should consider
1134 1.1 mrg the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1135 1.1 mrg
1136 1.1 mrg @item @emph{Standard}:
1137 1.1 mrg GNU extension
1138 1.1 mrg
1139 1.1 mrg @item @emph{Class}:
1140 1.1 mrg Function
1141 1.1 mrg
1142 1.1 mrg @item @emph{Syntax}:
1143 1.1 mrg @code{RESULT = AND(I, J)}
1144 1.1 mrg
1145 1.1 mrg @item @emph{Arguments}:
1146 1.1 mrg @multitable @columnfractions .15 .70
1147 1.1 mrg @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1148 1.1 mrg type or a scalar @code{LOGICAL} type or a boz-literal-constant.
1149 1.1 mrg @item @var{J} @tab The type shall be the same as the type of @var{I} or
1150 1.1 mrg a boz-literal-constant. @var{I} and @var{J} shall not both be
1151 1.1 mrg boz-literal-constants. If either @var{I} or @var{J} is a
1152 1.1 mrg boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
1153 1.1 mrg @end multitable
1154 1.1 mrg
1155 1.1 mrg @item @emph{Return value}:
1156 1.1 mrg The return type is either a scalar @code{INTEGER} or a scalar
1157 1.1 mrg @code{LOGICAL}. If the kind type parameters differ, then the
1158 1.1 mrg smaller kind type is implicitly converted to larger kind, and the
1159 1.1 mrg return has the larger kind. A boz-literal-constant is
1160 1.1 mrg converted to an @code{INTEGER} with the kind type parameter of
1161 1.1 mrg the other argument as-if a call to @ref{INT} occurred.
1162 1.1 mrg
1163 1.1 mrg @item @emph{Example}:
1164 1.1 mrg @smallexample
1165 1.1 mrg PROGRAM test_and
1166 1.1 mrg LOGICAL :: T = .TRUE., F = .FALSE.
1167 1.1 mrg INTEGER :: a, b
1168 1.1 mrg DATA a / Z'F' /, b / Z'3' /
1169 1.1 mrg
1170 1.1 mrg WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1171 1.1 mrg WRITE (*,*) AND(a, b)
1172 1.1 mrg END PROGRAM
1173 1.1 mrg @end smallexample
1174 1.1 mrg
1175 1.1 mrg @item @emph{See also}:
1176 1.1 mrg Fortran 95 elemental function: @ref{IAND}
1177 1.1 mrg @end table
1178 1.1 mrg
1179 1.1 mrg
1180 1.1 mrg
1181 1.1 mrg @node ANINT
1182 1.1 mrg @section @code{ANINT} --- Nearest whole number
1183 1.1 mrg @fnindex ANINT
1184 1.1 mrg @fnindex DNINT
1185 1.1 mrg @cindex ceiling
1186 1.1 mrg @cindex rounding, ceiling
1187 1.1 mrg
1188 1.1 mrg @table @asis
1189 1.1 mrg @item @emph{Description}:
1190 1.1 mrg @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1191 1.1 mrg
1192 1.1 mrg @item @emph{Standard}:
1193 1.1 mrg Fortran 77 and later
1194 1.1 mrg
1195 1.1 mrg @item @emph{Class}:
1196 1.1 mrg Elemental function
1197 1.1 mrg
1198 1.1 mrg @item @emph{Syntax}:
1199 1.1 mrg @code{RESULT = ANINT(A [, KIND])}
1200 1.1 mrg
1201 1.1 mrg @item @emph{Arguments}:
1202 1.1 mrg @multitable @columnfractions .15 .70
1203 1.1 mrg @item @var{A} @tab The type of the argument shall be @code{REAL}.
1204 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1205 1.1 mrg expression indicating the kind parameter of the result.
1206 1.1 mrg @end multitable
1207 1.1 mrg
1208 1.1 mrg @item @emph{Return value}:
1209 1.1 mrg The return value is of type real with the kind type parameter of the
1210 1.1 mrg argument if the optional @var{KIND} is absent; otherwise, the kind
1211 1.1 mrg type parameter will be given by @var{KIND}. If @var{A} is greater than
1212 1.1 mrg zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is
1213 1.1 mrg less than or equal to zero then it returns @code{AINT(X-0.5)}.
1214 1.1 mrg
1215 1.1 mrg @item @emph{Example}:
1216 1.1 mrg @smallexample
1217 1.1 mrg program test_anint
1218 1.1 mrg real(4) x4
1219 1.1 mrg real(8) x8
1220 1.1 mrg x4 = 1.234E0_4
1221 1.1 mrg x8 = 4.321_8
1222 1.1 mrg print *, anint(x4), dnint(x8)
1223 1.1 mrg x8 = anint(x4,8)
1224 1.1 mrg end program test_anint
1225 1.1 mrg @end smallexample
1226 1.1 mrg
1227 1.1 mrg @item @emph{Specific names}:
1228 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1229 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1230 1.1 mrg @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
1231 1.1 mrg @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
1232 1.1 mrg @end multitable
1233 1.1 mrg @end table
1234 1.1 mrg
1235 1.1 mrg
1236 1.1 mrg
1237 1.1 mrg @node ANY
1238 1.1 mrg @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1239 1.1 mrg @fnindex ANY
1240 1.1 mrg @cindex array, apply condition
1241 1.1 mrg @cindex array, condition testing
1242 1.1 mrg
1243 1.1 mrg @table @asis
1244 1.1 mrg @item @emph{Description}:
1245 1.1 mrg @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1246 1.1 mrg @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1247 1.1 mrg
1248 1.1 mrg @item @emph{Standard}:
1249 1.1 mrg Fortran 95 and later
1250 1.1 mrg
1251 1.1 mrg @item @emph{Class}:
1252 1.1 mrg Transformational function
1253 1.1 mrg
1254 1.1 mrg @item @emph{Syntax}:
1255 1.1 mrg @code{RESULT = ANY(MASK [, DIM])}
1256 1.1 mrg
1257 1.1 mrg @item @emph{Arguments}:
1258 1.1 mrg @multitable @columnfractions .15 .70
1259 1.1 mrg @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1260 1.1 mrg it shall not be scalar.
1261 1.1 mrg @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1262 1.1 mrg with a value that lies between one and the rank of @var{MASK}.
1263 1.1 mrg @end multitable
1264 1.1 mrg
1265 1.1 mrg @item @emph{Return value}:
1266 1.1 mrg @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1267 1.1 mrg the kind type parameter is the same as the kind type parameter of
1268 1.1 mrg @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1269 1.1 mrg an array with the rank of @var{MASK} minus 1. The shape is determined from
1270 1.1 mrg the shape of @var{MASK} where the @var{DIM} dimension is elided.
1271 1.1 mrg
1272 1.1 mrg @table @asis
1273 1.1 mrg @item (A)
1274 1.1 mrg @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1275 1.1 mrg otherwise, it is false. It also is false if @var{MASK} has zero size.
1276 1.1 mrg @item (B)
1277 1.1 mrg If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1278 1.1 mrg to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1279 1.1 mrg is determined by applying @code{ANY} to the array sections.
1280 1.1 mrg @end table
1281 1.1 mrg
1282 1.1 mrg @item @emph{Example}:
1283 1.1 mrg @smallexample
1284 1.1 mrg program test_any
1285 1.1 mrg logical l
1286 1.1 mrg l = any((/.true., .true., .true./))
1287 1.1 mrg print *, l
1288 1.1 mrg call section
1289 1.1 mrg contains
1290 1.1 mrg subroutine section
1291 1.1 mrg integer a(2,3), b(2,3)
1292 1.1 mrg a = 1
1293 1.1 mrg b = 1
1294 1.1 mrg b(2,2) = 2
1295 1.1 mrg print *, any(a .eq. b, 1)
1296 1.1 mrg print *, any(a .eq. b, 2)
1297 1.1 mrg end subroutine section
1298 1.1 mrg end program test_any
1299 1.1 mrg @end smallexample
1300 1.1 mrg @end table
1301 1.1 mrg
1302 1.1 mrg
1303 1.1 mrg
1304 1.1 mrg @node ASIN
1305 1.1 mrg @section @code{ASIN} --- Arcsine function
1306 1.1 mrg @fnindex ASIN
1307 1.1 mrg @fnindex DASIN
1308 1.1 mrg @cindex trigonometric function, sine, inverse
1309 1.1 mrg @cindex sine, inverse
1310 1.1 mrg
1311 1.1 mrg @table @asis
1312 1.1 mrg @item @emph{Description}:
1313 1.1 mrg @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1314 1.1 mrg
1315 1.1 mrg @item @emph{Standard}:
1316 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
1317 1.1 mrg
1318 1.1 mrg @item @emph{Class}:
1319 1.1 mrg Elemental function
1320 1.1 mrg
1321 1.1 mrg @item @emph{Syntax}:
1322 1.1 mrg @code{RESULT = ASIN(X)}
1323 1.1 mrg
1324 1.1 mrg @item @emph{Arguments}:
1325 1.1 mrg @multitable @columnfractions .15 .70
1326 1.1 mrg @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1327 1.1 mrg less than or equal to one - or be @code{COMPLEX}.
1328 1.1 mrg @end multitable
1329 1.1 mrg
1330 1.1 mrg @item @emph{Return value}:
1331 1.1 mrg The return value is of the same type and kind as @var{X}.
1332 1.1 mrg The real part of the result is in radians and lies in the range
1333 1.1 mrg @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1334 1.1 mrg
1335 1.1 mrg @item @emph{Example}:
1336 1.1 mrg @smallexample
1337 1.1 mrg program test_asin
1338 1.1 mrg real(8) :: x = 0.866_8
1339 1.1 mrg x = asin(x)
1340 1.1 mrg end program test_asin
1341 1.1 mrg @end smallexample
1342 1.1 mrg
1343 1.1 mrg @item @emph{Specific names}:
1344 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1345 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1346 1.1 mrg @item @code{ASIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1347 1.1 mrg @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1348 1.1 mrg @end multitable
1349 1.1 mrg
1350 1.1 mrg @item @emph{See also}:
1351 1.1 mrg Inverse function: @ref{SIN}
1352 1.1 mrg Degrees function: @ref{ASIND}
1353 1.1 mrg
1354 1.1 mrg @end table
1355 1.1 mrg
1356 1.1 mrg
1357 1.1 mrg
1358 1.1 mrg @node ASIND
1359 1.1 mrg @section @code{ASIND} --- Arcsine function, degrees
1360 1.1 mrg @fnindex ASIND
1361 1.1 mrg @fnindex DASIND
1362 1.1 mrg @cindex trigonometric function, sine, inverse, degrees
1363 1.1 mrg @cindex sine, inverse, degrees
1364 1.1 mrg
1365 1.1 mrg @table @asis
1366 1.1 mrg @item @emph{Description}:
1367 1.1 mrg @code{ASIND(X)} computes the arcsine of its @var{X} in degrees (inverse of
1368 1.1 mrg @code{SIND(X)}).
1369 1.1 mrg
1370 1.1 mrg This function is for compatibility only and should be avoided in favor of
1371 1.1 mrg standard constructs wherever possible.
1372 1.1 mrg
1373 1.1 mrg @item @emph{Standard}:
1374 1.1 mrg GNU Extension, enabled with @option{-fdec-math}.
1375 1.1 mrg
1376 1.1 mrg @item @emph{Class}:
1377 1.1 mrg Elemental function
1378 1.1 mrg
1379 1.1 mrg @item @emph{Syntax}:
1380 1.1 mrg @code{RESULT = ASIND(X)}
1381 1.1 mrg
1382 1.1 mrg @item @emph{Arguments}:
1383 1.1 mrg @multitable @columnfractions .15 .70
1384 1.1 mrg @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1385 1.1 mrg less than or equal to one - or be @code{COMPLEX}.
1386 1.1 mrg @end multitable
1387 1.1 mrg
1388 1.1 mrg @item @emph{Return value}:
1389 1.1 mrg The return value is of the same type and kind as @var{X}.
1390 1.1 mrg The real part of the result is in degrees and lies in the range
1391 1.1 mrg @math{-90 \leq \Re \asin(x) \leq 90}.
1392 1.1 mrg
1393 1.1 mrg @item @emph{Example}:
1394 1.1 mrg @smallexample
1395 1.1 mrg program test_asind
1396 1.1 mrg real(8) :: x = 0.866_8
1397 1.1 mrg x = asind(x)
1398 1.1 mrg end program test_asind
1399 1.1 mrg @end smallexample
1400 1.1 mrg
1401 1.1 mrg @item @emph{Specific names}:
1402 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1403 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1404 1.1 mrg @item @code{ASIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
1405 1.1 mrg @item @code{DASIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
1406 1.1 mrg @end multitable
1407 1.1 mrg
1408 1.1 mrg @item @emph{See also}:
1409 1.1 mrg Inverse function: @ref{SIND}
1410 1.1 mrg Radians function: @ref{ASIN}
1411 1.1 mrg
1412 1.1 mrg @end table
1413 1.1 mrg
1414 1.1 mrg
1415 1.1 mrg
1416 1.1 mrg @node ASINH
1417 1.1 mrg @section @code{ASINH} --- Inverse hyperbolic sine function
1418 1.1 mrg @fnindex ASINH
1419 1.1 mrg @fnindex DASINH
1420 1.1 mrg @cindex area hyperbolic sine
1421 1.1 mrg @cindex inverse hyperbolic sine
1422 1.1 mrg @cindex hyperbolic function, sine, inverse
1423 1.1 mrg @cindex sine, hyperbolic, inverse
1424 1.1 mrg
1425 1.1 mrg @table @asis
1426 1.1 mrg @item @emph{Description}:
1427 1.1 mrg @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1428 1.1 mrg
1429 1.1 mrg @item @emph{Standard}:
1430 1.1 mrg Fortran 2008 and later
1431 1.1 mrg
1432 1.1 mrg @item @emph{Class}:
1433 1.1 mrg Elemental function
1434 1.1 mrg
1435 1.1 mrg @item @emph{Syntax}:
1436 1.1 mrg @code{RESULT = ASINH(X)}
1437 1.1 mrg
1438 1.1 mrg @item @emph{Arguments}:
1439 1.1 mrg @multitable @columnfractions .15 .70
1440 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1441 1.1 mrg @end multitable
1442 1.1 mrg
1443 1.1 mrg @item @emph{Return value}:
1444 1.1 mrg The return value is of the same type and kind as @var{X}. If @var{X} is
1445 1.1 mrg complex, the imaginary part of the result is in radians and lies between
1446 1.1 mrg @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1447 1.1 mrg
1448 1.1 mrg @item @emph{Example}:
1449 1.1 mrg @smallexample
1450 1.1 mrg PROGRAM test_asinh
1451 1.1 mrg REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1452 1.1 mrg WRITE (*,*) ASINH(x)
1453 1.1 mrg END PROGRAM
1454 1.1 mrg @end smallexample
1455 1.1 mrg
1456 1.1 mrg @item @emph{Specific names}:
1457 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1458 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1459 1.1 mrg @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1460 1.1 mrg @end multitable
1461 1.1 mrg
1462 1.1 mrg @item @emph{See also}:
1463 1.1 mrg Inverse function: @ref{SINH}
1464 1.1 mrg @end table
1465 1.1 mrg
1466 1.1 mrg
1467 1.1 mrg
1468 1.1 mrg @node ASSOCIATED
1469 1.1 mrg @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1470 1.1 mrg @fnindex ASSOCIATED
1471 1.1 mrg @cindex pointer, status
1472 1.1 mrg @cindex association status
1473 1.1 mrg
1474 1.1 mrg @table @asis
1475 1.1 mrg @item @emph{Description}:
1476 1.1 mrg @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1477 1.1 mrg @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1478 1.1 mrg
1479 1.1 mrg @item @emph{Standard}:
1480 1.1 mrg Fortran 95 and later
1481 1.1 mrg
1482 1.1 mrg @item @emph{Class}:
1483 1.1 mrg Inquiry function
1484 1.1 mrg
1485 1.1 mrg @item @emph{Syntax}:
1486 1.1 mrg @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1487 1.1 mrg
1488 1.1 mrg @item @emph{Arguments}:
1489 1.1 mrg @multitable @columnfractions .15 .70
1490 1.1 mrg @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1491 1.1 mrg and it can be of any type.
1492 1.1 mrg @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1493 1.1 mrg a target. It must have the same type, kind type parameter, and
1494 1.1 mrg array rank as @var{POINTER}.
1495 1.1 mrg @end multitable
1496 1.1 mrg The association status of neither @var{POINTER} nor @var{TARGET} shall be
1497 1.1 mrg undefined.
1498 1.1 mrg
1499 1.1 mrg @item @emph{Return value}:
1500 1.1 mrg @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1501 1.1 mrg There are several cases:
1502 1.1 mrg @table @asis
1503 1.1 mrg @item (A) When the optional @var{TARGET} is not present then
1504 1.1 mrg @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1505 1.1 mrg @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1506 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
1507 1.1 mrg disassociated, the result is false.
1508 1.1 mrg @item (C) If @var{TARGET} is present and an array target, the result is true if
1509 1.1 mrg @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1510 1.1 mrg are arrays whose elements are not zero-sized storage sequences, and
1511 1.1 mrg @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1512 1.1 mrg order.
1513 1.1 mrg As in case(B), the result is false, if @var{POINTER} is disassociated.
1514 1.1 mrg @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1515 1.1 mrg if @var{TARGET} is associated with @var{POINTER}, the target associated with
1516 1.1 mrg @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1517 1.1 mrg units.
1518 1.1 mrg The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1519 1.1 mrg @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1520 1.1 mrg target associated with @var{POINTER} and the target associated with @var{TARGET}
1521 1.1 mrg have the same shape, are not zero-sized arrays, are arrays whose elements are
1522 1.1 mrg not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1523 1.1 mrg the same storage units in array element order.
1524 1.1 mrg The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1525 1.1 mrg @end table
1526 1.1 mrg
1527 1.1 mrg @item @emph{Example}:
1528 1.1 mrg @smallexample
1529 1.1 mrg program test_associated
1530 1.1 mrg implicit none
1531 1.1 mrg real, target :: tgt(2) = (/1., 2./)
1532 1.1 mrg real, pointer :: ptr(:)
1533 1.1 mrg ptr => tgt
1534 1.1 mrg if (associated(ptr) .eqv. .false.) call abort
1535 1.1 mrg if (associated(ptr,tgt) .eqv. .false.) call abort
1536 1.1 mrg end program test_associated
1537 1.1 mrg @end smallexample
1538 1.1 mrg
1539 1.1 mrg @item @emph{See also}:
1540 1.1 mrg @ref{NULL}
1541 1.1 mrg @end table
1542 1.1 mrg
1543 1.1 mrg
1544 1.1 mrg
1545 1.1 mrg @node ATAN
1546 1.1 mrg @section @code{ATAN} --- Arctangent function
1547 1.1 mrg @fnindex ATAN
1548 1.1 mrg @fnindex DATAN
1549 1.1 mrg @cindex trigonometric function, tangent, inverse
1550 1.1 mrg @cindex tangent, inverse
1551 1.1 mrg
1552 1.1 mrg @table @asis
1553 1.1 mrg @item @emph{Description}:
1554 1.1 mrg @code{ATAN(X)} computes the arctangent of @var{X}.
1555 1.1 mrg
1556 1.1 mrg @item @emph{Standard}:
1557 1.1 mrg Fortran 77 and later, for a complex argument and for two arguments
1558 1.1 mrg Fortran 2008 or later
1559 1.1 mrg
1560 1.1 mrg @item @emph{Class}:
1561 1.1 mrg Elemental function
1562 1.1 mrg
1563 1.1 mrg @item @emph{Syntax}:
1564 1.1 mrg @multitable @columnfractions .80
1565 1.1 mrg @item @code{RESULT = ATAN(X)}
1566 1.1 mrg @item @code{RESULT = ATAN(Y, X)}
1567 1.1 mrg @end multitable
1568 1.1 mrg
1569 1.1 mrg @item @emph{Arguments}:
1570 1.1 mrg @multitable @columnfractions .15 .70
1571 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1572 1.1 mrg if @var{Y} is present, @var{X} shall be REAL.
1573 1.1 mrg @item @var{Y} shall be of the same type and kind as @var{X}.
1574 1.1 mrg @end multitable
1575 1.1 mrg
1576 1.1 mrg @item @emph{Return value}:
1577 1.1 mrg The return value is of the same type and kind as @var{X}.
1578 1.1 mrg If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1579 1.1 mrg Otherwise, it the arcus tangent of @var{X}, where the real part of
1580 1.1 mrg the result is in radians and lies in the range
1581 1.1 mrg @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1582 1.1 mrg
1583 1.1 mrg @item @emph{Example}:
1584 1.1 mrg @smallexample
1585 1.1 mrg program test_atan
1586 1.1 mrg real(8) :: x = 2.866_8
1587 1.1 mrg x = atan(x)
1588 1.1 mrg end program test_atan
1589 1.1 mrg @end smallexample
1590 1.1 mrg
1591 1.1 mrg @item @emph{Specific names}:
1592 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1593 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1594 1.1 mrg @item @code{ATAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1595 1.1 mrg @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1596 1.1 mrg @end multitable
1597 1.1 mrg
1598 1.1 mrg @item @emph{See also}:
1599 1.1 mrg Inverse function: @ref{TAN}
1600 1.1 mrg Degrees function: @ref{ATAND}
1601 1.1 mrg
1602 1.1 mrg @end table
1603 1.1 mrg
1604 1.1 mrg
1605 1.1 mrg
1606 1.1 mrg @node ATAND
1607 1.1 mrg @section @code{ATAND} --- Arctangent function, degrees
1608 1.1 mrg @fnindex ATAND
1609 1.1 mrg @fnindex DATAND
1610 1.1 mrg @cindex trigonometric function, tangent, inverse, degrees
1611 1.1 mrg @cindex tangent, inverse, degrees
1612 1.1 mrg
1613 1.1 mrg @table @asis
1614 1.1 mrg @item @emph{Description}:
1615 1.1 mrg @code{ATAND(X)} computes the arctangent of @var{X} in degrees (inverse of
1616 1.1 mrg @ref{TAND}).
1617 1.1 mrg
1618 1.1 mrg This function is for compatibility only and should be avoided in favor of
1619 1.1 mrg standard constructs wherever possible.
1620 1.1 mrg
1621 1.1 mrg @item @emph{Standard}:
1622 1.1 mrg GNU Extension, enabled with @option{-fdec-math}.
1623 1.1 mrg
1624 1.1 mrg @item @emph{Class}:
1625 1.1 mrg Elemental function
1626 1.1 mrg
1627 1.1 mrg @item @emph{Syntax}:
1628 1.1 mrg @multitable @columnfractions .80
1629 1.1 mrg @item @code{RESULT = ATAND(X)}
1630 1.1 mrg @item @code{RESULT = ATAND(Y, X)}
1631 1.1 mrg @end multitable
1632 1.1 mrg
1633 1.1 mrg @item @emph{Arguments}:
1634 1.1 mrg @multitable @columnfractions .15 .70
1635 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1636 1.1 mrg if @var{Y} is present, @var{X} shall be REAL.
1637 1.1 mrg @item @var{Y} shall be of the same type and kind as @var{X}.
1638 1.1 mrg @end multitable
1639 1.1 mrg
1640 1.1 mrg @item @emph{Return value}:
1641 1.1 mrg The return value is of the same type and kind as @var{X}.
1642 1.1 mrg If @var{Y} is present, the result is identical to @code{ATAND2(Y,X)}.
1643 1.1 mrg Otherwise, it is the arcus tangent of @var{X}, where the real part of
1644 1.1 mrg the result is in degrees and lies in the range
1645 1.1 mrg @math{-90 \leq \Re \atand(x) \leq 90}.
1646 1.1 mrg
1647 1.1 mrg @item @emph{Example}:
1648 1.1 mrg @smallexample
1649 1.1 mrg program test_atand
1650 1.1 mrg real(8) :: x = 2.866_8
1651 1.1 mrg x = atand(x)
1652 1.1 mrg end program test_atand
1653 1.1 mrg @end smallexample
1654 1.1 mrg
1655 1.1 mrg @item @emph{Specific names}:
1656 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1657 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1658 1.1 mrg @item @code{ATAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
1659 1.1 mrg @item @code{DATAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
1660 1.1 mrg @end multitable
1661 1.1 mrg
1662 1.1 mrg @item @emph{See also}:
1663 1.1 mrg Inverse function: @ref{TAND}
1664 1.1 mrg Radians function: @ref{ATAN}
1665 1.1 mrg
1666 1.1 mrg @end table
1667 1.1 mrg
1668 1.1 mrg
1669 1.1 mrg
1670 1.1 mrg @node ATAN2
1671 1.1 mrg @section @code{ATAN2} --- Arctangent function
1672 1.1 mrg @fnindex ATAN2
1673 1.1 mrg @fnindex DATAN2
1674 1.1 mrg @cindex trigonometric function, tangent, inverse
1675 1.1 mrg @cindex tangent, inverse
1676 1.1 mrg
1677 1.1 mrg @table @asis
1678 1.1 mrg @item @emph{Description}:
1679 1.1 mrg @code{ATAN2(Y, X)} computes the principal value of the argument
1680 1.1 mrg function of the complex number @math{X + i Y}. This function can
1681 1.1 mrg be used to transform from Cartesian into polar coordinates and
1682 1.1 mrg allows to determine the angle in the correct quadrant.
1683 1.1 mrg
1684 1.1 mrg @item @emph{Standard}:
1685 1.1 mrg Fortran 77 and later
1686 1.1 mrg
1687 1.1 mrg @item @emph{Class}:
1688 1.1 mrg Elemental function
1689 1.1 mrg
1690 1.1 mrg @item @emph{Syntax}:
1691 1.1 mrg @code{RESULT = ATAN2(Y, X)}
1692 1.1 mrg
1693 1.1 mrg @item @emph{Arguments}:
1694 1.1 mrg @multitable @columnfractions .15 .70
1695 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}.
1696 1.1 mrg @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1697 1.1 mrg If @var{Y} is zero, then @var{X} must be nonzero.
1698 1.1 mrg @end multitable
1699 1.1 mrg
1700 1.1 mrg @item @emph{Return value}:
1701 1.1 mrg The return value has the same type and kind type parameter as @var{Y}. It
1702 1.1 mrg is the principal value of the complex number @math{X + i Y}. If @var{X}
1703 1.1 mrg is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1704 1.1 mrg The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1705 1.1 mrg the return value is zero if @var{X} is strictly positive, @math{\pi} if
1706 1.1 mrg @var{X} is negative and @var{Y} is positive zero (or the processor does
1707 1.1 mrg not handle signed zeros), and @math{-\pi} if @var{X} is negative and
1708 1.1 mrg @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1709 1.1 mrg magnitude of the result is @math{\pi/2}.
1710 1.1 mrg
1711 1.1 mrg @item @emph{Example}:
1712 1.1 mrg @smallexample
1713 1.1 mrg program test_atan2
1714 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4
1715 1.1 mrg x = atan2(y,x)
1716 1.1 mrg end program test_atan2
1717 1.1 mrg @end smallexample
1718 1.1 mrg
1719 1.1 mrg @item @emph{Specific names}:
1720 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1721 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1722 1.1 mrg @item @code{ATAN2(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1723 1.1 mrg @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1724 1.1 mrg @end multitable
1725 1.1 mrg
1726 1.1 mrg @item @emph{See also}:
1727 1.1 mrg Alias: @ref{ATAN}
1728 1.1 mrg Degrees function: @ref{ATAN2D}
1729 1.1 mrg
1730 1.1 mrg @end table
1731 1.1 mrg
1732 1.1 mrg
1733 1.1 mrg
1734 1.1 mrg @node ATAN2D
1735 1.1 mrg @section @code{ATAN2D} --- Arctangent function, degrees
1736 1.1 mrg @fnindex ATAN2D
1737 1.1 mrg @fnindex DATAN2D
1738 1.1 mrg @cindex trigonometric function, tangent, inverse, degrees
1739 1.1 mrg @cindex tangent, inverse, degrees
1740 1.1 mrg
1741 1.1 mrg @table @asis
1742 1.1 mrg @item @emph{Description}:
1743 1.1 mrg @code{ATAN2D(Y, X)} computes the principal value of the argument
1744 1.1 mrg function of the complex number @math{X + i Y} in degrees. This function can
1745 1.1 mrg be used to transform from Cartesian into polar coordinates and
1746 1.1 mrg allows to determine the angle in the correct quadrant.
1747 1.1 mrg
1748 1.1 mrg This function is for compatibility only and should be avoided in favor of
1749 1.1 mrg standard constructs wherever possible.
1750 1.1 mrg
1751 1.1 mrg @item @emph{Standard}:
1752 1.1 mrg GNU Extension, enabled with @option{-fdec-math}.
1753 1.1 mrg
1754 1.1 mrg @item @emph{Class}:
1755 1.1 mrg Elemental function
1756 1.1 mrg
1757 1.1 mrg @item @emph{Syntax}:
1758 1.1 mrg @code{RESULT = ATAN2D(Y, X)}
1759 1.1 mrg
1760 1.1 mrg @item @emph{Arguments}:
1761 1.1 mrg @multitable @columnfractions .15 .70
1762 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}.
1763 1.1 mrg @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1764 1.1 mrg If @var{Y} is zero, then @var{X} must be nonzero.
1765 1.1 mrg @end multitable
1766 1.1 mrg
1767 1.1 mrg @item @emph{Return value}:
1768 1.1 mrg The return value has the same type and kind type parameter as @var{Y}. It
1769 1.1 mrg is the principal value of the complex number @math{X + i Y}. If @var{X}
1770 1.1 mrg is nonzero, then it lies in the range @math{-180 \le \atan (x) \leq 180}.
1771 1.1 mrg The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1772 1.1 mrg the return value is zero if @var{X} is strictly positive, @math{180} if
1773 1.1 mrg @var{X} is negative and @var{Y} is positive zero (or the processor does
1774 1.1 mrg not handle signed zeros), and @math{-180} if @var{X} is negative and
1775 1.1 mrg @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1776 1.1 mrg magnitude of the result is @math{90}.
1777 1.1 mrg
1778 1.1 mrg @item @emph{Example}:
1779 1.1 mrg @smallexample
1780 1.1 mrg program test_atan2d
1781 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4
1782 1.1 mrg x = atan2d(y,x)
1783 1.1 mrg end program test_atan2d
1784 1.1 mrg @end smallexample
1785 1.1 mrg
1786 1.1 mrg @item @emph{Specific names}:
1787 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1788 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1789 1.1 mrg @item @code{ATAN2D(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab GNU Extension
1790 1.1 mrg @item @code{DATAN2D(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab GNU Extension
1791 1.1 mrg @end multitable
1792 1.1 mrg
1793 1.1 mrg @item @emph{See also}:
1794 1.1 mrg Alias: @ref{ATAND}
1795 1.1 mrg Radians function: @ref{ATAN2}
1796 1.1 mrg
1797 1.1 mrg @end table
1798 1.1 mrg
1799 1.1 mrg
1800 1.1 mrg
1801 1.1 mrg @node ATANH
1802 1.1 mrg @section @code{ATANH} --- Inverse hyperbolic tangent function
1803 1.1 mrg @fnindex ATANH
1804 1.1 mrg @fnindex DATANH
1805 1.1 mrg @cindex area hyperbolic tangent
1806 1.1 mrg @cindex inverse hyperbolic tangent
1807 1.1 mrg @cindex hyperbolic function, tangent, inverse
1808 1.1 mrg @cindex tangent, hyperbolic, inverse
1809 1.1 mrg
1810 1.1 mrg @table @asis
1811 1.1 mrg @item @emph{Description}:
1812 1.1 mrg @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1813 1.1 mrg
1814 1.1 mrg @item @emph{Standard}:
1815 1.1 mrg Fortran 2008 and later
1816 1.1 mrg
1817 1.1 mrg @item @emph{Class}:
1818 1.1 mrg Elemental function
1819 1.1 mrg
1820 1.1 mrg @item @emph{Syntax}:
1821 1.1 mrg @code{RESULT = ATANH(X)}
1822 1.1 mrg
1823 1.1 mrg @item @emph{Arguments}:
1824 1.1 mrg @multitable @columnfractions .15 .70
1825 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1826 1.1 mrg @end multitable
1827 1.1 mrg
1828 1.1 mrg @item @emph{Return value}:
1829 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is
1830 1.1 mrg complex, the imaginary part of the result is in radians and lies between
1831 1.1 mrg @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1832 1.1 mrg
1833 1.1 mrg @item @emph{Example}:
1834 1.1 mrg @smallexample
1835 1.1 mrg PROGRAM test_atanh
1836 1.1 mrg REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1837 1.1 mrg WRITE (*,*) ATANH(x)
1838 1.1 mrg END PROGRAM
1839 1.1 mrg @end smallexample
1840 1.1 mrg
1841 1.1 mrg @item @emph{Specific names}:
1842 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
1843 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
1844 1.1 mrg @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1845 1.1 mrg @end multitable
1846 1.1 mrg
1847 1.1 mrg @item @emph{See also}:
1848 1.1 mrg Inverse function: @ref{TANH}
1849 1.1 mrg @end table
1850 1.1 mrg
1851 1.1 mrg
1852 1.1 mrg
1853 1.1 mrg @node ATOMIC_ADD
1854 1.1 mrg @section @code{ATOMIC_ADD} --- Atomic ADD operation
1855 1.1 mrg @fnindex ATOMIC_ADD
1856 1.1 mrg @cindex Atomic subroutine, add
1857 1.1 mrg
1858 1.1 mrg @table @asis
1859 1.1 mrg @item @emph{Description}:
1860 1.1 mrg @code{ATOMIC_ADD(ATOM, VALUE)} atomically adds the value of @var{VAR} to the
1861 1.1 mrg variable @var{ATOM}. When @var{STAT} is present and the invocation was
1862 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation
1863 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed
1864 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
1865 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1866 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
1867 1.1 mrg
1868 1.1 mrg @item @emph{Standard}:
1869 1.1 mrg TS 18508 or later
1870 1.1 mrg
1871 1.1 mrg @item @emph{Class}:
1872 1.1 mrg Atomic subroutine
1873 1.1 mrg
1874 1.1 mrg @item @emph{Syntax}:
1875 1.1 mrg @code{CALL ATOMIC_ADD (ATOM, VALUE [, STAT])}
1876 1.1 mrg
1877 1.1 mrg @item @emph{Arguments}:
1878 1.1 mrg @multitable @columnfractions .15 .70
1879 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1880 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
1881 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1882 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
1883 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1884 1.1 mrg @end multitable
1885 1.1 mrg
1886 1.1 mrg @item @emph{Example}:
1887 1.1 mrg @smallexample
1888 1.1 mrg program atomic
1889 1.1 mrg use iso_fortran_env
1890 1.1 mrg integer(atomic_int_kind) :: atom[*]
1891 1.1 mrg call atomic_add (atom[1], this_image())
1892 1.1 mrg end program atomic
1893 1.1 mrg @end smallexample
1894 1.1 mrg
1895 1.1 mrg @item @emph{See also}:
1896 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_ADD}, @ref{ISO_FORTRAN_ENV},
1897 1.1 mrg @ref{ATOMIC_AND}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1898 1.1 mrg @end table
1899 1.1 mrg
1900 1.1 mrg
1901 1.1 mrg
1902 1.1 mrg
1903 1.1 mrg @node ATOMIC_AND
1904 1.1 mrg @section @code{ATOMIC_AND} --- Atomic bitwise AND operation
1905 1.1 mrg @fnindex ATOMIC_AND
1906 1.1 mrg @cindex Atomic subroutine, AND
1907 1.1 mrg
1908 1.1 mrg @table @asis
1909 1.1 mrg @item @emph{Description}:
1910 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
1911 1.1 mrg AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
1912 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present
1913 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular,
1914 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
1915 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
1916 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}.
1917 1.1 mrg
1918 1.1 mrg @item @emph{Standard}:
1919 1.1 mrg TS 18508 or later
1920 1.1 mrg
1921 1.1 mrg @item @emph{Class}:
1922 1.1 mrg Atomic subroutine
1923 1.1 mrg
1924 1.1 mrg @item @emph{Syntax}:
1925 1.1 mrg @code{CALL ATOMIC_AND (ATOM, VALUE [, STAT])}
1926 1.1 mrg
1927 1.1 mrg @item @emph{Arguments}:
1928 1.1 mrg @multitable @columnfractions .15 .70
1929 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1930 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
1931 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1932 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
1933 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1934 1.1 mrg @end multitable
1935 1.1 mrg
1936 1.1 mrg @item @emph{Example}:
1937 1.1 mrg @smallexample
1938 1.1 mrg program atomic
1939 1.1 mrg use iso_fortran_env
1940 1.1 mrg integer(atomic_int_kind) :: atom[*]
1941 1.1 mrg call atomic_and (atom[1], int(b'10100011101'))
1942 1.1 mrg end program atomic
1943 1.1 mrg @end smallexample
1944 1.1 mrg
1945 1.1 mrg @item @emph{See also}:
1946 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_AND}, @ref{ISO_FORTRAN_ENV},
1947 1.1 mrg @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1948 1.1 mrg @end table
1949 1.1 mrg
1950 1.1 mrg
1951 1.1 mrg
1952 1.1 mrg @node ATOMIC_CAS
1953 1.1 mrg @section @code{ATOMIC_CAS} --- Atomic compare and swap
1954 1.1 mrg @fnindex ATOMIC_DEFINE
1955 1.1 mrg @cindex Atomic subroutine, compare and swap
1956 1.1 mrg
1957 1.1 mrg @table @asis
1958 1.1 mrg @item @emph{Description}:
1959 1.1 mrg @code{ATOMIC_CAS} compares the variable @var{ATOM} with the value of
1960 1.1 mrg @var{COMPARE}; if the value is the same, @var{ATOM} is set to the value
1961 1.1 mrg of @var{NEW}. Additionally, @var{OLD} is set to the value of @var{ATOM}
1962 1.1 mrg that was used for the comparison. When @var{STAT} is present and the invocation
1963 1.1 mrg was successful, it is assigned the value 0. If it is present and the invocation
1964 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed
1965 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
1966 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1967 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
1968 1.1 mrg
1969 1.1 mrg @item @emph{Standard}:
1970 1.1 mrg TS 18508 or later
1971 1.1 mrg
1972 1.1 mrg @item @emph{Class}:
1973 1.1 mrg Atomic subroutine
1974 1.1 mrg
1975 1.1 mrg @item @emph{Syntax}:
1976 1.1 mrg @code{CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])}
1977 1.1 mrg
1978 1.1 mrg @item @emph{Arguments}:
1979 1.1 mrg @multitable @columnfractions .15 .70
1980 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
1981 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with
1982 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind.
1983 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
1984 1.1 mrg @item @var{COMPARE} @tab Scalar variable of the same type and kind as
1985 1.1 mrg @var{ATOM}.
1986 1.1 mrg @item @var{NEW} @tab Scalar variable of the same type as @var{ATOM}. If kind
1987 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
1988 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1989 1.1 mrg @end multitable
1990 1.1 mrg
1991 1.1 mrg @item @emph{Example}:
1992 1.1 mrg @smallexample
1993 1.1 mrg program atomic
1994 1.1 mrg use iso_fortran_env
1995 1.1 mrg logical(atomic_logical_kind) :: atom[*], prev
1996 1.1 mrg call atomic_cas (atom[1], prev, .false., .true.))
1997 1.1 mrg end program atomic
1998 1.1 mrg @end smallexample
1999 1.1 mrg
2000 1.1 mrg @item @emph{See also}:
2001 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_REF}, @ref{ISO_FORTRAN_ENV}
2002 1.1 mrg @end table
2003 1.1 mrg
2004 1.1 mrg
2005 1.1 mrg
2006 1.1 mrg @node ATOMIC_DEFINE
2007 1.1 mrg @section @code{ATOMIC_DEFINE} --- Setting a variable atomically
2008 1.1 mrg @fnindex ATOMIC_DEFINE
2009 1.1 mrg @cindex Atomic subroutine, define
2010 1.1 mrg
2011 1.1 mrg @table @asis
2012 1.1 mrg @item @emph{Description}:
2013 1.1 mrg @code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value
2014 1.1 mrg @var{VALUE} atomically. When @var{STAT} is present and the invocation was
2015 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation
2016 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed
2017 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2018 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2019 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2020 1.1 mrg
2021 1.1 mrg @item @emph{Standard}:
2022 1.1 mrg Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2023 1.1 mrg
2024 1.1 mrg @item @emph{Class}:
2025 1.1 mrg Atomic subroutine
2026 1.1 mrg
2027 1.1 mrg @item @emph{Syntax}:
2028 1.1 mrg @code{CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT])}
2029 1.1 mrg
2030 1.1 mrg @item @emph{Arguments}:
2031 1.1 mrg @multitable @columnfractions .15 .70
2032 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2033 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with
2034 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind.
2035 1.1 mrg
2036 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2037 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2038 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2039 1.1 mrg @end multitable
2040 1.1 mrg
2041 1.1 mrg @item @emph{Example}:
2042 1.1 mrg @smallexample
2043 1.1 mrg program atomic
2044 1.1 mrg use iso_fortran_env
2045 1.1 mrg integer(atomic_int_kind) :: atom[*]
2046 1.1 mrg call atomic_define (atom[1], this_image())
2047 1.1 mrg end program atomic
2048 1.1 mrg @end smallexample
2049 1.1 mrg
2050 1.1 mrg @item @emph{See also}:
2051 1.1 mrg @ref{ATOMIC_REF}, @ref{ATOMIC_CAS}, @ref{ISO_FORTRAN_ENV},
2052 1.1 mrg @ref{ATOMIC_ADD}, @ref{ATOMIC_AND}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2053 1.1 mrg @end table
2054 1.1 mrg
2055 1.1 mrg
2056 1.1 mrg
2057 1.1 mrg @node ATOMIC_FETCH_ADD
2058 1.1 mrg @section @code{ATOMIC_FETCH_ADD} --- Atomic ADD operation with prior fetch
2059 1.1 mrg @fnindex ATOMIC_FETCH_ADD
2060 1.1 mrg @cindex Atomic subroutine, ADD with fetch
2061 1.1 mrg
2062 1.1 mrg @table @asis
2063 1.1 mrg @item @emph{Description}:
2064 1.1 mrg @code{ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)} atomically stores the value of
2065 1.1 mrg @var{ATOM} in @var{OLD} and adds the value of @var{VAR} to the
2066 1.1 mrg variable @var{ATOM}. When @var{STAT} is present and the invocation was
2067 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation
2068 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed
2069 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2070 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2071 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2072 1.1 mrg
2073 1.1 mrg @item @emph{Standard}:
2074 1.1 mrg TS 18508 or later
2075 1.1 mrg
2076 1.1 mrg @item @emph{Class}:
2077 1.1 mrg Atomic subroutine
2078 1.1 mrg
2079 1.1 mrg @item @emph{Syntax}:
2080 1.1 mrg @code{CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT])}
2081 1.1 mrg
2082 1.1 mrg @item @emph{Arguments}:
2083 1.1 mrg @multitable @columnfractions .15 .70
2084 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2085 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2086 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind.
2087 1.1 mrg
2088 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2089 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2090 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2091 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2092 1.1 mrg @end multitable
2093 1.1 mrg
2094 1.1 mrg @item @emph{Example}:
2095 1.1 mrg @smallexample
2096 1.1 mrg program atomic
2097 1.1 mrg use iso_fortran_env
2098 1.1 mrg integer(atomic_int_kind) :: atom[*], old
2099 1.1 mrg call atomic_add (atom[1], this_image(), old)
2100 1.1 mrg end program atomic
2101 1.1 mrg @end smallexample
2102 1.1 mrg
2103 1.1 mrg @item @emph{See also}:
2104 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_ADD}, @ref{ISO_FORTRAN_ENV},
2105 1.1 mrg @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR}, @ref{ATOMIC_FETCH_XOR}
2106 1.1 mrg @end table
2107 1.1 mrg
2108 1.1 mrg
2109 1.1 mrg
2110 1.1 mrg @node ATOMIC_FETCH_AND
2111 1.1 mrg @section @code{ATOMIC_FETCH_AND} --- Atomic bitwise AND operation with prior fetch
2112 1.1 mrg @fnindex ATOMIC_FETCH_AND
2113 1.1 mrg @cindex Atomic subroutine, AND with fetch
2114 1.1 mrg
2115 1.1 mrg @table @asis
2116 1.1 mrg @item @emph{Description}:
2117 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2118 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise AND between the values of
2119 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2120 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has
2121 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed
2122 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2123 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2124 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2125 1.1 mrg
2126 1.1 mrg @item @emph{Standard}:
2127 1.1 mrg TS 18508 or later
2128 1.1 mrg
2129 1.1 mrg @item @emph{Class}:
2130 1.1 mrg Atomic subroutine
2131 1.1 mrg
2132 1.1 mrg @item @emph{Syntax}:
2133 1.1 mrg @code{CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])}
2134 1.1 mrg
2135 1.1 mrg @item @emph{Arguments}:
2136 1.1 mrg @multitable @columnfractions .15 .70
2137 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2138 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2139 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2140 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2141 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2142 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2143 1.1 mrg @end multitable
2144 1.1 mrg
2145 1.1 mrg @item @emph{Example}:
2146 1.1 mrg @smallexample
2147 1.1 mrg program atomic
2148 1.1 mrg use iso_fortran_env
2149 1.1 mrg integer(atomic_int_kind) :: atom[*], old
2150 1.1 mrg call atomic_fetch_and (atom[1], int(b'10100011101'), old)
2151 1.1 mrg end program atomic
2152 1.1 mrg @end smallexample
2153 1.1 mrg
2154 1.1 mrg @item @emph{See also}:
2155 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_AND}, @ref{ISO_FORTRAN_ENV},
2156 1.1 mrg @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_OR}, @ref{ATOMIC_FETCH_XOR}
2157 1.1 mrg @end table
2158 1.1 mrg
2159 1.1 mrg
2160 1.1 mrg
2161 1.1 mrg @node ATOMIC_FETCH_OR
2162 1.1 mrg @section @code{ATOMIC_FETCH_OR} --- Atomic bitwise OR operation with prior fetch
2163 1.1 mrg @fnindex ATOMIC_FETCH_OR
2164 1.1 mrg @cindex Atomic subroutine, OR with fetch
2165 1.1 mrg
2166 1.1 mrg @table @asis
2167 1.1 mrg @item @emph{Description}:
2168 1.1 mrg @code{ATOMIC_OR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2169 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise OR between the values of
2170 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2171 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has
2172 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed
2173 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2174 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2175 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2176 1.1 mrg
2177 1.1 mrg @item @emph{Standard}:
2178 1.1 mrg TS 18508 or later
2179 1.1 mrg
2180 1.1 mrg @item @emph{Class}:
2181 1.1 mrg Atomic subroutine
2182 1.1 mrg
2183 1.1 mrg @item @emph{Syntax}:
2184 1.1 mrg @code{CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])}
2185 1.1 mrg
2186 1.1 mrg @item @emph{Arguments}:
2187 1.1 mrg @multitable @columnfractions .15 .70
2188 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2189 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2190 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2191 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2192 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2193 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2194 1.1 mrg @end multitable
2195 1.1 mrg
2196 1.1 mrg @item @emph{Example}:
2197 1.1 mrg @smallexample
2198 1.1 mrg program atomic
2199 1.1 mrg use iso_fortran_env
2200 1.1 mrg integer(atomic_int_kind) :: atom[*], old
2201 1.1 mrg call atomic_fetch_or (atom[1], int(b'10100011101'), old)
2202 1.1 mrg end program atomic
2203 1.1 mrg @end smallexample
2204 1.1 mrg
2205 1.1 mrg @item @emph{See also}:
2206 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_OR}, @ref{ISO_FORTRAN_ENV},
2207 1.1 mrg @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_XOR}
2208 1.1 mrg @end table
2209 1.1 mrg
2210 1.1 mrg
2211 1.1 mrg
2212 1.1 mrg @node ATOMIC_FETCH_XOR
2213 1.1 mrg @section @code{ATOMIC_FETCH_XOR} --- Atomic bitwise XOR operation with prior fetch
2214 1.1 mrg @fnindex ATOMIC_FETCH_XOR
2215 1.1 mrg @cindex Atomic subroutine, XOR with fetch
2216 1.1 mrg
2217 1.1 mrg @table @asis
2218 1.1 mrg @item @emph{Description}:
2219 1.1 mrg @code{ATOMIC_XOR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2220 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise XOR between the values of
2221 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2222 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has
2223 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed
2224 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of
2225 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2226 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}.
2227 1.1 mrg
2228 1.1 mrg @item @emph{Standard}:
2229 1.1 mrg TS 18508 or later
2230 1.1 mrg
2231 1.1 mrg @item @emph{Class}:
2232 1.1 mrg Atomic subroutine
2233 1.1 mrg
2234 1.1 mrg @item @emph{Syntax}:
2235 1.1 mrg @code{CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])}
2236 1.1 mrg
2237 1.1 mrg @item @emph{Arguments}:
2238 1.1 mrg @multitable @columnfractions .15 .70
2239 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2240 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2241 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2242 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2243 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2244 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2245 1.1 mrg @end multitable
2246 1.1 mrg
2247 1.1 mrg @item @emph{Example}:
2248 1.1 mrg @smallexample
2249 1.1 mrg program atomic
2250 1.1 mrg use iso_fortran_env
2251 1.1 mrg integer(atomic_int_kind) :: atom[*], old
2252 1.1 mrg call atomic_fetch_xor (atom[1], int(b'10100011101'), old)
2253 1.1 mrg end program atomic
2254 1.1 mrg @end smallexample
2255 1.1 mrg
2256 1.1 mrg @item @emph{See also}:
2257 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_XOR}, @ref{ISO_FORTRAN_ENV},
2258 1.1 mrg @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR}
2259 1.1 mrg @end table
2260 1.1 mrg
2261 1.1 mrg
2262 1.1 mrg
2263 1.1 mrg @node ATOMIC_OR
2264 1.1 mrg @section @code{ATOMIC_OR} --- Atomic bitwise OR operation
2265 1.1 mrg @fnindex ATOMIC_OR
2266 1.1 mrg @cindex Atomic subroutine, OR
2267 1.1 mrg
2268 1.1 mrg @table @asis
2269 1.1 mrg @item @emph{Description}:
2270 1.1 mrg @code{ATOMIC_OR(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2271 1.1 mrg AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2272 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present
2273 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular,
2274 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2275 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2276 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}.
2277 1.1 mrg
2278 1.1 mrg @item @emph{Standard}:
2279 1.1 mrg TS 18508 or later
2280 1.1 mrg
2281 1.1 mrg @item @emph{Class}:
2282 1.1 mrg Atomic subroutine
2283 1.1 mrg
2284 1.1 mrg @item @emph{Syntax}:
2285 1.1 mrg @code{CALL ATOMIC_OR (ATOM, VALUE [, STAT])}
2286 1.1 mrg
2287 1.1 mrg @item @emph{Arguments}:
2288 1.1 mrg @multitable @columnfractions .15 .70
2289 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2290 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2291 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2292 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2293 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2294 1.1 mrg @end multitable
2295 1.1 mrg
2296 1.1 mrg @item @emph{Example}:
2297 1.1 mrg @smallexample
2298 1.1 mrg program atomic
2299 1.1 mrg use iso_fortran_env
2300 1.1 mrg integer(atomic_int_kind) :: atom[*]
2301 1.1 mrg call atomic_or (atom[1], int(b'10100011101'))
2302 1.1 mrg end program atomic
2303 1.1 mrg @end smallexample
2304 1.1 mrg
2305 1.1 mrg @item @emph{See also}:
2306 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_OR}, @ref{ISO_FORTRAN_ENV},
2307 1.1 mrg @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2308 1.1 mrg @end table
2309 1.1 mrg
2310 1.1 mrg
2311 1.1 mrg
2312 1.1 mrg @node ATOMIC_REF
2313 1.1 mrg @section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically
2314 1.1 mrg @fnindex ATOMIC_REF
2315 1.1 mrg @cindex Atomic subroutine, reference
2316 1.1 mrg
2317 1.1 mrg @table @asis
2318 1.1 mrg @item @emph{Description}:
2319 1.1 mrg @code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the
2320 1.1 mrg variable @var{ATOM} to @var{VALUE}. When @var{STAT} is present and the
2321 1.1 mrg invocation was successful, it is assigned the value 0. If it is present and the
2322 1.1 mrg invocation has failed, it is assigned a positive value; in particular, for a
2323 1.1 mrg coindexed @var{ATOM}, if the remote image has stopped, it is assigned the value
2324 1.1 mrg of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image
2325 1.1 mrg has failed, the value @code{STAT_FAILED_IMAGE}.
2326 1.1 mrg
2327 1.1 mrg
2328 1.1 mrg @item @emph{Standard}:
2329 1.1 mrg Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2330 1.1 mrg
2331 1.1 mrg @item @emph{Class}:
2332 1.1 mrg Atomic subroutine
2333 1.1 mrg
2334 1.1 mrg @item @emph{Syntax}:
2335 1.1 mrg @code{CALL ATOMIC_REF(VALUE, ATOM [, STAT])}
2336 1.1 mrg
2337 1.1 mrg @item @emph{Arguments}:
2338 1.1 mrg @multitable @columnfractions .15 .70
2339 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2340 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2341 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2342 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with
2343 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind.
2344 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2345 1.1 mrg @end multitable
2346 1.1 mrg
2347 1.1 mrg @item @emph{Example}:
2348 1.1 mrg @smallexample
2349 1.1 mrg program atomic
2350 1.1 mrg use iso_fortran_env
2351 1.1 mrg logical(atomic_logical_kind) :: atom[*]
2352 1.1 mrg logical :: val
2353 1.1 mrg call atomic_ref (atom, .false.)
2354 1.1 mrg ! ...
2355 1.1 mrg call atomic_ref (atom, val)
2356 1.1 mrg if (val) then
2357 1.1 mrg print *, "Obtained"
2358 1.1 mrg end if
2359 1.1 mrg end program atomic
2360 1.1 mrg @end smallexample
2361 1.1 mrg
2362 1.1 mrg @item @emph{See also}:
2363 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_CAS}, @ref{ISO_FORTRAN_ENV},
2364 1.1 mrg @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR},
2365 1.1 mrg @ref{ATOMIC_FETCH_XOR}
2366 1.1 mrg @end table
2367 1.1 mrg
2368 1.1 mrg
2369 1.1 mrg @node ATOMIC_XOR
2370 1.1 mrg @section @code{ATOMIC_XOR} --- Atomic bitwise OR operation
2371 1.1 mrg @fnindex ATOMIC_XOR
2372 1.1 mrg @cindex Atomic subroutine, XOR
2373 1.1 mrg
2374 1.1 mrg @table @asis
2375 1.1 mrg @item @emph{Description}:
2376 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2377 1.1 mrg XOR between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2378 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present
2379 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular,
2380 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2381 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2382 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}.
2383 1.1 mrg
2384 1.1 mrg @item @emph{Standard}:
2385 1.1 mrg TS 18508 or later
2386 1.1 mrg
2387 1.1 mrg @item @emph{Class}:
2388 1.1 mrg Atomic subroutine
2389 1.1 mrg
2390 1.1 mrg @item @emph{Syntax}:
2391 1.1 mrg @code{CALL ATOMIC_XOR (ATOM, VALUE [, STAT])}
2392 1.1 mrg
2393 1.1 mrg @item @emph{Arguments}:
2394 1.1 mrg @multitable @columnfractions .15 .70
2395 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2396 1.1 mrg type with @code{ATOMIC_INT_KIND} kind.
2397 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2398 1.1 mrg is different, the value is converted to the kind of @var{ATOM}.
2399 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2400 1.1 mrg @end multitable
2401 1.1 mrg
2402 1.1 mrg @item @emph{Example}:
2403 1.1 mrg @smallexample
2404 1.1 mrg program atomic
2405 1.1 mrg use iso_fortran_env
2406 1.1 mrg integer(atomic_int_kind) :: atom[*]
2407 1.1 mrg call atomic_xor (atom[1], int(b'10100011101'))
2408 1.1 mrg end program atomic
2409 1.1 mrg @end smallexample
2410 1.1 mrg
2411 1.1 mrg @item @emph{See also}:
2412 1.1 mrg @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_XOR}, @ref{ISO_FORTRAN_ENV},
2413 1.1 mrg @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2414 1.1 mrg @end table
2415 1.1 mrg
2416 1.1 mrg
2417 1.1 mrg @node BACKTRACE
2418 1.1 mrg @section @code{BACKTRACE} --- Show a backtrace
2419 1.1 mrg @fnindex BACKTRACE
2420 1.1 mrg @cindex backtrace
2421 1.1 mrg
2422 1.1 mrg @table @asis
2423 1.1 mrg @item @emph{Description}:
2424 1.1 mrg @code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program
2425 1.1 mrg execution continues normally afterwards. The backtrace information is printed
2426 1.1 mrg to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}.
2427 1.1 mrg
2428 1.1 mrg @item @emph{Standard}:
2429 1.1 mrg GNU Extension
2430 1.1 mrg
2431 1.1 mrg @item @emph{Class}:
2432 1.1 mrg Subroutine
2433 1.1 mrg
2434 1.1 mrg @item @emph{Syntax}:
2435 1.1 mrg @code{CALL BACKTRACE}
2436 1.1 mrg
2437 1.1 mrg @item @emph{Arguments}:
2438 1.1 mrg None
2439 1.1 mrg
2440 1.1 mrg @item @emph{See also}:
2441 1.1 mrg @ref{ABORT}
2442 1.1 mrg @end table
2443 1.1 mrg
2444 1.1 mrg
2445 1.1 mrg
2446 1.1 mrg @node BESSEL_J0
2447 1.1 mrg @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
2448 1.1 mrg @fnindex BESSEL_J0
2449 1.1 mrg @fnindex BESJ0
2450 1.1 mrg @fnindex DBESJ0
2451 1.1 mrg @cindex Bessel function, first kind
2452 1.1 mrg
2453 1.1 mrg @table @asis
2454 1.1 mrg @item @emph{Description}:
2455 1.1 mrg @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
2456 1.1 mrg order 0 of @var{X}. This function is available under the name
2457 1.1 mrg @code{BESJ0} as a GNU extension.
2458 1.1 mrg
2459 1.1 mrg @item @emph{Standard}:
2460 1.1 mrg Fortran 2008 and later
2461 1.1 mrg
2462 1.1 mrg @item @emph{Class}:
2463 1.1 mrg Elemental function
2464 1.1 mrg
2465 1.1 mrg @item @emph{Syntax}:
2466 1.1 mrg @code{RESULT = BESSEL_J0(X)}
2467 1.1 mrg
2468 1.1 mrg @item @emph{Arguments}:
2469 1.1 mrg @multitable @columnfractions .15 .70
2470 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
2471 1.1 mrg @end multitable
2472 1.1 mrg
2473 1.1 mrg @item @emph{Return value}:
2474 1.1 mrg The return value is of type @code{REAL} and lies in the
2475 1.1 mrg range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
2476 1.1 mrg kind as @var{X}.
2477 1.1 mrg
2478 1.1 mrg @item @emph{Example}:
2479 1.1 mrg @smallexample
2480 1.1 mrg program test_besj0
2481 1.1 mrg real(8) :: x = 0.0_8
2482 1.1 mrg x = bessel_j0(x)
2483 1.1 mrg end program test_besj0
2484 1.1 mrg @end smallexample
2485 1.1 mrg
2486 1.1 mrg @item @emph{Specific names}:
2487 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2488 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2489 1.1 mrg @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2490 1.1 mrg @end multitable
2491 1.1 mrg @end table
2492 1.1 mrg
2493 1.1 mrg
2494 1.1 mrg
2495 1.1 mrg @node BESSEL_J1
2496 1.1 mrg @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
2497 1.1 mrg @fnindex BESSEL_J1
2498 1.1 mrg @fnindex BESJ1
2499 1.1 mrg @fnindex DBESJ1
2500 1.1 mrg @cindex Bessel function, first kind
2501 1.1 mrg
2502 1.1 mrg @table @asis
2503 1.1 mrg @item @emph{Description}:
2504 1.1 mrg @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
2505 1.1 mrg order 1 of @var{X}. This function is available under the name
2506 1.1 mrg @code{BESJ1} as a GNU extension.
2507 1.1 mrg
2508 1.1 mrg @item @emph{Standard}:
2509 1.1 mrg Fortran 2008
2510 1.1 mrg
2511 1.1 mrg @item @emph{Class}:
2512 1.1 mrg Elemental function
2513 1.1 mrg
2514 1.1 mrg @item @emph{Syntax}:
2515 1.1 mrg @code{RESULT = BESSEL_J1(X)}
2516 1.1 mrg
2517 1.1 mrg @item @emph{Arguments}:
2518 1.1 mrg @multitable @columnfractions .15 .70
2519 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
2520 1.1 mrg @end multitable
2521 1.1 mrg
2522 1.1 mrg @item @emph{Return value}:
2523 1.1 mrg The return value is of type @code{REAL} and lies in the
2524 1.1 mrg range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
2525 1.1 mrg kind as @var{X}.
2526 1.1 mrg
2527 1.1 mrg @item @emph{Example}:
2528 1.1 mrg @smallexample
2529 1.1 mrg program test_besj1
2530 1.1 mrg real(8) :: x = 1.0_8
2531 1.1 mrg x = bessel_j1(x)
2532 1.1 mrg end program test_besj1
2533 1.1 mrg @end smallexample
2534 1.1 mrg
2535 1.1 mrg @item @emph{Specific names}:
2536 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2537 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2538 1.1 mrg @item @code{DBESJ1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2539 1.1 mrg @end multitable
2540 1.1 mrg @end table
2541 1.1 mrg
2542 1.1 mrg
2543 1.1 mrg
2544 1.1 mrg @node BESSEL_JN
2545 1.1 mrg @section @code{BESSEL_JN} --- Bessel function of the first kind
2546 1.1 mrg @fnindex BESSEL_JN
2547 1.1 mrg @fnindex BESJN
2548 1.1 mrg @fnindex DBESJN
2549 1.1 mrg @cindex Bessel function, first kind
2550 1.1 mrg
2551 1.1 mrg @table @asis
2552 1.1 mrg @item @emph{Description}:
2553 1.1 mrg @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
2554 1.1 mrg order @var{N} of @var{X}. This function is available under the name
2555 1.1 mrg @code{BESJN} as a GNU extension. If @var{N} and @var{X} are arrays,
2556 1.1 mrg their ranks and shapes shall conform.
2557 1.1 mrg
2558 1.1 mrg @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
2559 1.1 mrg of the first kind of the orders @var{N1} to @var{N2}.
2560 1.1 mrg
2561 1.1 mrg @item @emph{Standard}:
2562 1.1 mrg Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2563 1.1 mrg
2564 1.1 mrg @item @emph{Class}:
2565 1.1 mrg Elemental function, except for the transformational function
2566 1.1 mrg @code{BESSEL_JN(N1, N2, X)}
2567 1.1 mrg
2568 1.1 mrg @item @emph{Syntax}:
2569 1.1 mrg @multitable @columnfractions .80
2570 1.1 mrg @item @code{RESULT = BESSEL_JN(N, X)}
2571 1.1 mrg @item @code{RESULT = BESSEL_JN(N1, N2, X)}
2572 1.1 mrg @end multitable
2573 1.1 mrg
2574 1.1 mrg @item @emph{Arguments}:
2575 1.1 mrg @multitable @columnfractions .15 .70
2576 1.1 mrg @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}.
2577 1.1 mrg @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2578 1.1 mrg @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2579 1.1 mrg @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2580 1.1 mrg for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
2581 1.1 mrg @end multitable
2582 1.1 mrg
2583 1.1 mrg @item @emph{Return value}:
2584 1.1 mrg The return value is a scalar of type @code{REAL}. It has the same
2585 1.1 mrg kind as @var{X}.
2586 1.1 mrg
2587 1.1 mrg @item @emph{Note}:
2588 1.1 mrg The transformational function uses a recurrence algorithm which might,
2589 1.1 mrg for some values of @var{X}, lead to different results than calls to
2590 1.1 mrg the elemental function.
2591 1.1 mrg
2592 1.1 mrg @item @emph{Example}:
2593 1.1 mrg @smallexample
2594 1.1 mrg program test_besjn
2595 1.1 mrg real(8) :: x = 1.0_8
2596 1.1 mrg x = bessel_jn(5,x)
2597 1.1 mrg end program test_besjn
2598 1.1 mrg @end smallexample
2599 1.1 mrg
2600 1.1 mrg @item @emph{Specific names}:
2601 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2602 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2603 1.1 mrg @item @code{DBESJN(N, X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2604 1.1 mrg @item @tab @code{REAL(8) X} @tab @tab
2605 1.1 mrg @end multitable
2606 1.1 mrg @end table
2607 1.1 mrg
2608 1.1 mrg
2609 1.1 mrg
2610 1.1 mrg @node BESSEL_Y0
2611 1.1 mrg @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
2612 1.1 mrg @fnindex BESSEL_Y0
2613 1.1 mrg @fnindex BESY0
2614 1.1 mrg @fnindex DBESY0
2615 1.1 mrg @cindex Bessel function, second kind
2616 1.1 mrg
2617 1.1 mrg @table @asis
2618 1.1 mrg @item @emph{Description}:
2619 1.1 mrg @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
2620 1.1 mrg order 0 of @var{X}. This function is available under the name
2621 1.1 mrg @code{BESY0} as a GNU extension.
2622 1.1 mrg
2623 1.1 mrg @item @emph{Standard}:
2624 1.1 mrg Fortran 2008 and later
2625 1.1 mrg
2626 1.1 mrg @item @emph{Class}:
2627 1.1 mrg Elemental function
2628 1.1 mrg
2629 1.1 mrg @item @emph{Syntax}:
2630 1.1 mrg @code{RESULT = BESSEL_Y0(X)}
2631 1.1 mrg
2632 1.1 mrg @item @emph{Arguments}:
2633 1.1 mrg @multitable @columnfractions .15 .70
2634 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
2635 1.1 mrg @end multitable
2636 1.1 mrg
2637 1.1 mrg @item @emph{Return value}:
2638 1.1 mrg The return value is of type @code{REAL}. It has the same kind as @var{X}.
2639 1.1 mrg
2640 1.1 mrg @item @emph{Example}:
2641 1.1 mrg @smallexample
2642 1.1 mrg program test_besy0
2643 1.1 mrg real(8) :: x = 0.0_8
2644 1.1 mrg x = bessel_y0(x)
2645 1.1 mrg end program test_besy0
2646 1.1 mrg @end smallexample
2647 1.1 mrg
2648 1.1 mrg @item @emph{Specific names}:
2649 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2650 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2651 1.1 mrg @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2652 1.1 mrg @end multitable
2653 1.1 mrg @end table
2654 1.1 mrg
2655 1.1 mrg
2656 1.1 mrg
2657 1.1 mrg @node BESSEL_Y1
2658 1.1 mrg @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
2659 1.1 mrg @fnindex BESSEL_Y1
2660 1.1 mrg @fnindex BESY1
2661 1.1 mrg @fnindex DBESY1
2662 1.1 mrg @cindex Bessel function, second kind
2663 1.1 mrg
2664 1.1 mrg @table @asis
2665 1.1 mrg @item @emph{Description}:
2666 1.1 mrg @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
2667 1.1 mrg order 1 of @var{X}. This function is available under the name
2668 1.1 mrg @code{BESY1} as a GNU extension.
2669 1.1 mrg
2670 1.1 mrg @item @emph{Standard}:
2671 1.1 mrg Fortran 2008 and later
2672 1.1 mrg
2673 1.1 mrg @item @emph{Class}:
2674 1.1 mrg Elemental function
2675 1.1 mrg
2676 1.1 mrg @item @emph{Syntax}:
2677 1.1 mrg @code{RESULT = BESSEL_Y1(X)}
2678 1.1 mrg
2679 1.1 mrg @item @emph{Arguments}:
2680 1.1 mrg @multitable @columnfractions .15 .70
2681 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
2682 1.1 mrg @end multitable
2683 1.1 mrg
2684 1.1 mrg @item @emph{Return value}:
2685 1.1 mrg The return value is of type @code{REAL}. It has the same kind as @var{X}.
2686 1.1 mrg
2687 1.1 mrg @item @emph{Example}:
2688 1.1 mrg @smallexample
2689 1.1 mrg program test_besy1
2690 1.1 mrg real(8) :: x = 1.0_8
2691 1.1 mrg x = bessel_y1(x)
2692 1.1 mrg end program test_besy1
2693 1.1 mrg @end smallexample
2694 1.1 mrg
2695 1.1 mrg @item @emph{Specific names}:
2696 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2697 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2698 1.1 mrg @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2699 1.1 mrg @end multitable
2700 1.1 mrg @end table
2701 1.1 mrg
2702 1.1 mrg
2703 1.1 mrg
2704 1.1 mrg @node BESSEL_YN
2705 1.1 mrg @section @code{BESSEL_YN} --- Bessel function of the second kind
2706 1.1 mrg @fnindex BESSEL_YN
2707 1.1 mrg @fnindex BESYN
2708 1.1 mrg @fnindex DBESYN
2709 1.1 mrg @cindex Bessel function, second kind
2710 1.1 mrg
2711 1.1 mrg @table @asis
2712 1.1 mrg @item @emph{Description}:
2713 1.1 mrg @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
2714 1.1 mrg order @var{N} of @var{X}. This function is available under the name
2715 1.1 mrg @code{BESYN} as a GNU extension. If @var{N} and @var{X} are arrays,
2716 1.1 mrg their ranks and shapes shall conform.
2717 1.1 mrg
2718 1.1 mrg @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
2719 1.1 mrg of the first kind of the orders @var{N1} to @var{N2}.
2720 1.1 mrg
2721 1.1 mrg @item @emph{Standard}:
2722 1.1 mrg Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2723 1.1 mrg
2724 1.1 mrg @item @emph{Class}:
2725 1.1 mrg Elemental function, except for the transformational function
2726 1.1 mrg @code{BESSEL_YN(N1, N2, X)}
2727 1.1 mrg
2728 1.1 mrg @item @emph{Syntax}:
2729 1.1 mrg @multitable @columnfractions .80
2730 1.1 mrg @item @code{RESULT = BESSEL_YN(N, X)}
2731 1.1 mrg @item @code{RESULT = BESSEL_YN(N1, N2, X)}
2732 1.1 mrg @end multitable
2733 1.1 mrg
2734 1.1 mrg @item @emph{Arguments}:
2735 1.1 mrg @multitable @columnfractions .15 .70
2736 1.1 mrg @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER} .
2737 1.1 mrg @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2738 1.1 mrg @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2739 1.1 mrg @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2740 1.1 mrg for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
2741 1.1 mrg @end multitable
2742 1.1 mrg
2743 1.1 mrg @item @emph{Return value}:
2744 1.1 mrg The return value is a scalar of type @code{REAL}. It has the same
2745 1.1 mrg kind as @var{X}.
2746 1.1 mrg
2747 1.1 mrg @item @emph{Note}:
2748 1.1 mrg The transformational function uses a recurrence algorithm which might,
2749 1.1 mrg for some values of @var{X}, lead to different results than calls to
2750 1.1 mrg the elemental function.
2751 1.1 mrg
2752 1.1 mrg @item @emph{Example}:
2753 1.1 mrg @smallexample
2754 1.1 mrg program test_besyn
2755 1.1 mrg real(8) :: x = 1.0_8
2756 1.1 mrg x = bessel_yn(5,x)
2757 1.1 mrg end program test_besyn
2758 1.1 mrg @end smallexample
2759 1.1 mrg
2760 1.1 mrg @item @emph{Specific names}:
2761 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2762 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2763 1.1 mrg @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2764 1.1 mrg @item @tab @code{REAL(8) X} @tab @tab
2765 1.1 mrg @end multitable
2766 1.1 mrg @end table
2767 1.1 mrg
2768 1.1 mrg
2769 1.1 mrg
2770 1.1 mrg @node BGE
2771 1.1 mrg @section @code{BGE} --- Bitwise greater than or equal to
2772 1.1 mrg @fnindex BGE
2773 1.1 mrg @cindex bitwise comparison
2774 1.1 mrg
2775 1.1 mrg @table @asis
2776 1.1 mrg @item @emph{Description}:
2777 1.1 mrg Determines whether an integral is a bitwise greater than or equal to
2778 1.1 mrg another.
2779 1.1 mrg
2780 1.1 mrg @item @emph{Standard}:
2781 1.1 mrg Fortran 2008 and later
2782 1.1 mrg
2783 1.1 mrg @item @emph{Class}:
2784 1.1 mrg Elemental function
2785 1.1 mrg
2786 1.1 mrg @item @emph{Syntax}:
2787 1.1 mrg @code{RESULT = BGE(I, J)}
2788 1.1 mrg
2789 1.1 mrg @item @emph{Arguments}:
2790 1.1 mrg @multitable @columnfractions .15 .70
2791 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type.
2792 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2793 1.1 mrg as @var{I}.
2794 1.1 mrg @end multitable
2795 1.1 mrg
2796 1.1 mrg @item @emph{Return value}:
2797 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind.
2798 1.1 mrg
2799 1.1 mrg @item @emph{See also}:
2800 1.1 mrg @ref{BGT}, @ref{BLE}, @ref{BLT}
2801 1.1 mrg @end table
2802 1.1 mrg
2803 1.1 mrg
2804 1.1 mrg
2805 1.1 mrg @node BGT
2806 1.1 mrg @section @code{BGT} --- Bitwise greater than
2807 1.1 mrg @fnindex BGT
2808 1.1 mrg @cindex bitwise comparison
2809 1.1 mrg
2810 1.1 mrg @table @asis
2811 1.1 mrg @item @emph{Description}:
2812 1.1 mrg Determines whether an integral is a bitwise greater than another.
2813 1.1 mrg
2814 1.1 mrg @item @emph{Standard}:
2815 1.1 mrg Fortran 2008 and later
2816 1.1 mrg
2817 1.1 mrg @item @emph{Class}:
2818 1.1 mrg Elemental function
2819 1.1 mrg
2820 1.1 mrg @item @emph{Syntax}:
2821 1.1 mrg @code{RESULT = BGT(I, J)}
2822 1.1 mrg
2823 1.1 mrg @item @emph{Arguments}:
2824 1.1 mrg @multitable @columnfractions .15 .70
2825 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type.
2826 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2827 1.1 mrg as @var{I}.
2828 1.1 mrg @end multitable
2829 1.1 mrg
2830 1.1 mrg @item @emph{Return value}:
2831 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind.
2832 1.1 mrg
2833 1.1 mrg @item @emph{See also}:
2834 1.1 mrg @ref{BGE}, @ref{BLE}, @ref{BLT}
2835 1.1 mrg @end table
2836 1.1 mrg
2837 1.1 mrg
2838 1.1 mrg
2839 1.1 mrg @node BIT_SIZE
2840 1.1 mrg @section @code{BIT_SIZE} --- Bit size inquiry function
2841 1.1 mrg @fnindex BIT_SIZE
2842 1.1 mrg @cindex bits, number of
2843 1.1 mrg @cindex size of a variable, in bits
2844 1.1 mrg
2845 1.1 mrg @table @asis
2846 1.1 mrg @item @emph{Description}:
2847 1.1 mrg @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
2848 1.1 mrg represented by the type of @var{I}. The result of @code{BIT_SIZE(I)} is
2849 1.1 mrg independent of the actual value of @var{I}.
2850 1.1 mrg
2851 1.1 mrg @item @emph{Standard}:
2852 1.1 mrg Fortran 95 and later
2853 1.1 mrg
2854 1.1 mrg @item @emph{Class}:
2855 1.1 mrg Inquiry function
2856 1.1 mrg
2857 1.1 mrg @item @emph{Syntax}:
2858 1.1 mrg @code{RESULT = BIT_SIZE(I)}
2859 1.1 mrg
2860 1.1 mrg @item @emph{Arguments}:
2861 1.1 mrg @multitable @columnfractions .15 .70
2862 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
2863 1.1 mrg @end multitable
2864 1.1 mrg
2865 1.1 mrg @item @emph{Return value}:
2866 1.1 mrg The return value is of type @code{INTEGER}
2867 1.1 mrg
2868 1.1 mrg @item @emph{Example}:
2869 1.1 mrg @smallexample
2870 1.1 mrg program test_bit_size
2871 1.1 mrg integer :: i = 123
2872 1.1 mrg integer :: size
2873 1.1 mrg size = bit_size(i)
2874 1.1 mrg print *, size
2875 1.1 mrg end program test_bit_size
2876 1.1 mrg @end smallexample
2877 1.1 mrg @end table
2878 1.1 mrg
2879 1.1 mrg
2880 1.1 mrg
2881 1.1 mrg @node BLE
2882 1.1 mrg @section @code{BLE} --- Bitwise less than or equal to
2883 1.1 mrg @fnindex BLE
2884 1.1 mrg @cindex bitwise comparison
2885 1.1 mrg
2886 1.1 mrg @table @asis
2887 1.1 mrg @item @emph{Description}:
2888 1.1 mrg Determines whether an integral is a bitwise less than or equal to
2889 1.1 mrg another.
2890 1.1 mrg
2891 1.1 mrg @item @emph{Standard}:
2892 1.1 mrg Fortran 2008 and later
2893 1.1 mrg
2894 1.1 mrg @item @emph{Class}:
2895 1.1 mrg Elemental function
2896 1.1 mrg
2897 1.1 mrg @item @emph{Syntax}:
2898 1.1 mrg @code{RESULT = BLE(I, J)}
2899 1.1 mrg
2900 1.1 mrg @item @emph{Arguments}:
2901 1.1 mrg @multitable @columnfractions .15 .70
2902 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type.
2903 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2904 1.1 mrg as @var{I}.
2905 1.1 mrg @end multitable
2906 1.1 mrg
2907 1.1 mrg @item @emph{Return value}:
2908 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind.
2909 1.1 mrg
2910 1.1 mrg @item @emph{See also}:
2911 1.1 mrg @ref{BGT}, @ref{BGE}, @ref{BLT}
2912 1.1 mrg @end table
2913 1.1 mrg
2914 1.1 mrg
2915 1.1 mrg
2916 1.1 mrg @node BLT
2917 1.1 mrg @section @code{BLT} --- Bitwise less than
2918 1.1 mrg @fnindex BLT
2919 1.1 mrg @cindex bitwise comparison
2920 1.1 mrg
2921 1.1 mrg @table @asis
2922 1.1 mrg @item @emph{Description}:
2923 1.1 mrg Determines whether an integral is a bitwise less than another.
2924 1.1 mrg
2925 1.1 mrg @item @emph{Standard}:
2926 1.1 mrg Fortran 2008 and later
2927 1.1 mrg
2928 1.1 mrg @item @emph{Class}:
2929 1.1 mrg Elemental function
2930 1.1 mrg
2931 1.1 mrg @item @emph{Syntax}:
2932 1.1 mrg @code{RESULT = BLT(I, J)}
2933 1.1 mrg
2934 1.1 mrg @item @emph{Arguments}:
2935 1.1 mrg @multitable @columnfractions .15 .70
2936 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type.
2937 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2938 1.1 mrg as @var{I}.
2939 1.1 mrg @end multitable
2940 1.1 mrg
2941 1.1 mrg @item @emph{Return value}:
2942 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind.
2943 1.1 mrg
2944 1.1 mrg @item @emph{See also}:
2945 1.1 mrg @ref{BGE}, @ref{BGT}, @ref{BLE}
2946 1.1 mrg @end table
2947 1.1 mrg
2948 1.1 mrg
2949 1.1 mrg
2950 1.1 mrg @node BTEST
2951 1.1 mrg @section @code{BTEST} --- Bit test function
2952 1.1 mrg @fnindex BTEST
2953 1.1 mrg @fnindex BBTEST
2954 1.1 mrg @fnindex BITEST
2955 1.1 mrg @fnindex BJTEST
2956 1.1 mrg @fnindex BKTEST
2957 1.1 mrg @cindex bits, testing
2958 1.1 mrg
2959 1.1 mrg @table @asis
2960 1.1 mrg @item @emph{Description}:
2961 1.1 mrg @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
2962 1.1 mrg in @var{I} is set. The counting of the bits starts at 0.
2963 1.1 mrg
2964 1.1 mrg @item @emph{Standard}:
2965 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
2966 1.1 mrg
2967 1.1 mrg @item @emph{Class}:
2968 1.1 mrg Elemental function
2969 1.1 mrg
2970 1.1 mrg @item @emph{Syntax}:
2971 1.1 mrg @code{RESULT = BTEST(I, POS)}
2972 1.1 mrg
2973 1.1 mrg @item @emph{Arguments}:
2974 1.1 mrg @multitable @columnfractions .15 .70
2975 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
2976 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}.
2977 1.1 mrg @end multitable
2978 1.1 mrg
2979 1.1 mrg @item @emph{Return value}:
2980 1.1 mrg The return value is of type @code{LOGICAL}
2981 1.1 mrg
2982 1.1 mrg @item @emph{Example}:
2983 1.1 mrg @smallexample
2984 1.1 mrg program test_btest
2985 1.1 mrg integer :: i = 32768 + 1024 + 64
2986 1.1 mrg integer :: pos
2987 1.1 mrg logical :: bool
2988 1.1 mrg do pos=0,16
2989 1.1 mrg bool = btest(i, pos)
2990 1.1 mrg print *, pos, bool
2991 1.1 mrg end do
2992 1.1 mrg end program test_btest
2993 1.1 mrg @end smallexample
2994 1.1 mrg
2995 1.1 mrg @item @emph{Specific names}:
2996 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
2997 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
2998 1.1 mrg @item @code{BTEST(I,POS)} @tab @code{INTEGER I,POS} @tab @code{LOGICAL} @tab F95 and later
2999 1.1 mrg @item @code{BBTEST(I,POS)} @tab @code{INTEGER(1) I,POS} @tab @code{LOGICAL(1)} @tab GNU extension
3000 1.1 mrg @item @code{BITEST(I,POS)} @tab @code{INTEGER(2) I,POS} @tab @code{LOGICAL(2)} @tab GNU extension
3001 1.1 mrg @item @code{BJTEST(I,POS)} @tab @code{INTEGER(4) I,POS} @tab @code{LOGICAL(4)} @tab GNU extension
3002 1.1 mrg @item @code{BKTEST(I,POS)} @tab @code{INTEGER(8) I,POS} @tab @code{LOGICAL(8)} @tab GNU extension
3003 1.1 mrg @end multitable
3004 1.1 mrg @end table
3005 1.1 mrg
3006 1.1 mrg @node C_ASSOCIATED
3007 1.1 mrg @section @code{C_ASSOCIATED} --- Status of a C pointer
3008 1.1 mrg @fnindex C_ASSOCIATED
3009 1.1 mrg @cindex association status, C pointer
3010 1.1 mrg @cindex pointer, C association status
3011 1.1 mrg
3012 1.1 mrg @table @asis
3013 1.1 mrg @item @emph{Description}:
3014 1.1 mrg @code{C_ASSOCIATED(c_ptr_1[, c_ptr_2])} determines the status of the C pointer
3015 1.1 mrg @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
3016 1.1 mrg
3017 1.1 mrg @item @emph{Standard}:
3018 1.1 mrg Fortran 2003 and later
3019 1.1 mrg
3020 1.1 mrg @item @emph{Class}:
3021 1.1 mrg Inquiry function
3022 1.1 mrg
3023 1.1 mrg @item @emph{Syntax}:
3024 1.1 mrg @code{RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2])}
3025 1.1 mrg
3026 1.1 mrg @item @emph{Arguments}:
3027 1.1 mrg @multitable @columnfractions .15 .70
3028 1.1 mrg @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
3029 1.1 mrg @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
3030 1.1 mrg @end multitable
3031 1.1 mrg
3032 1.1 mrg @item @emph{Return value}:
3033 1.1 mrg The return value is of type @code{LOGICAL}; it is @code{.false.} if either
3034 1.1 mrg @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
3035 1.1 mrg point to different addresses.
3036 1.1 mrg
3037 1.1 mrg @item @emph{Example}:
3038 1.1 mrg @smallexample
3039 1.1 mrg subroutine association_test(a,b)
3040 1.1 mrg use iso_c_binding, only: c_associated, c_loc, c_ptr
3041 1.1 mrg implicit none
3042 1.1 mrg real, pointer :: a
3043 1.1 mrg type(c_ptr) :: b
3044 1.1 mrg if(c_associated(b, c_loc(a))) &
3045 1.1 mrg stop 'b and a do not point to same target'
3046 1.1 mrg end subroutine association_test
3047 1.1 mrg @end smallexample
3048 1.1 mrg
3049 1.1 mrg @item @emph{See also}:
3050 1.1 mrg @ref{C_LOC}, @ref{C_FUNLOC}
3051 1.1 mrg @end table
3052 1.1 mrg
3053 1.1 mrg
3054 1.1 mrg @node C_F_POINTER
3055 1.1 mrg @section @code{C_F_POINTER} --- Convert C into Fortran pointer
3056 1.1 mrg @fnindex C_F_POINTER
3057 1.1 mrg @cindex pointer, convert C to Fortran
3058 1.1 mrg
3059 1.1 mrg @table @asis
3060 1.1 mrg @item @emph{Description}:
3061 1.1 mrg @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer
3062 1.1 mrg @var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape.
3063 1.1 mrg
3064 1.1 mrg @item @emph{Standard}:
3065 1.1 mrg Fortran 2003 and later
3066 1.1 mrg
3067 1.1 mrg @item @emph{Class}:
3068 1.1 mrg Subroutine
3069 1.1 mrg
3070 1.1 mrg @item @emph{Syntax}:
3071 1.1 mrg @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
3072 1.1 mrg
3073 1.1 mrg @item @emph{Arguments}:
3074 1.1 mrg @multitable @columnfractions .15 .70
3075 1.1 mrg @item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is
3076 1.1 mrg @code{INTENT(IN)}.
3077 1.1 mrg @item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is
3078 1.1 mrg @code{INTENT(OUT)}.
3079 1.1 mrg @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
3080 1.1 mrg with @code{INTENT(IN)}. It shall be present
3081 1.1 mrg if and only if @var{fptr} is an array. The size
3082 1.1 mrg must be equal to the rank of @var{fptr}.
3083 1.1 mrg @end multitable
3084 1.1 mrg
3085 1.1 mrg @item @emph{Example}:
3086 1.1 mrg @smallexample
3087 1.1 mrg program main
3088 1.1 mrg use iso_c_binding
3089 1.1 mrg implicit none
3090 1.1 mrg interface
3091 1.1 mrg subroutine my_routine(p) bind(c,name='myC_func')
3092 1.1 mrg import :: c_ptr
3093 1.1 mrg type(c_ptr), intent(out) :: p
3094 1.1 mrg end subroutine
3095 1.1 mrg end interface
3096 1.1 mrg type(c_ptr) :: cptr
3097 1.1 mrg real,pointer :: a(:)
3098 1.1 mrg call my_routine(cptr)
3099 1.1 mrg call c_f_pointer(cptr, a, [12])
3100 1.1 mrg end program main
3101 1.1 mrg @end smallexample
3102 1.1 mrg
3103 1.1 mrg @item @emph{See also}:
3104 1.1 mrg @ref{C_LOC}, @ref{C_F_PROCPOINTER}
3105 1.1 mrg @end table
3106 1.1 mrg
3107 1.1 mrg
3108 1.1 mrg @node C_F_PROCPOINTER
3109 1.1 mrg @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
3110 1.1 mrg @fnindex C_F_PROCPOINTER
3111 1.1 mrg @cindex pointer, C address of pointers
3112 1.1 mrg
3113 1.1 mrg @table @asis
3114 1.1 mrg @item @emph{Description}:
3115 1.1 mrg @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
3116 1.1 mrg @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
3117 1.1 mrg
3118 1.1 mrg @item @emph{Standard}:
3119 1.1 mrg Fortran 2003 and later
3120 1.1 mrg
3121 1.1 mrg @item @emph{Class}:
3122 1.1 mrg Subroutine
3123 1.1 mrg
3124 1.1 mrg @item @emph{Syntax}:
3125 1.1 mrg @code{CALL C_F_PROCPOINTER(cptr, fptr)}
3126 1.1 mrg
3127 1.1 mrg @item @emph{Arguments}:
3128 1.1 mrg @multitable @columnfractions .15 .70
3129 1.1 mrg @item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is
3130 1.1 mrg @code{INTENT(IN)}.
3131 1.1 mrg @item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is
3132 1.1 mrg @code{INTENT(OUT)}.
3133 1.1 mrg @end multitable
3134 1.1 mrg
3135 1.1 mrg @item @emph{Example}:
3136 1.1 mrg @smallexample
3137 1.1 mrg program main
3138 1.1 mrg use iso_c_binding
3139 1.1 mrg implicit none
3140 1.1 mrg abstract interface
3141 1.1 mrg function func(a)
3142 1.1 mrg import :: c_float
3143 1.1 mrg real(c_float), intent(in) :: a
3144 1.1 mrg real(c_float) :: func
3145 1.1 mrg end function
3146 1.1 mrg end interface
3147 1.1 mrg interface
3148 1.1 mrg function getIterFunc() bind(c,name="getIterFunc")
3149 1.1 mrg import :: c_funptr
3150 1.1 mrg type(c_funptr) :: getIterFunc
3151 1.1 mrg end function
3152 1.1 mrg end interface
3153 1.1 mrg type(c_funptr) :: cfunptr
3154 1.1 mrg procedure(func), pointer :: myFunc
3155 1.1 mrg cfunptr = getIterFunc()
3156 1.1 mrg call c_f_procpointer(cfunptr, myFunc)
3157 1.1 mrg end program main
3158 1.1 mrg @end smallexample
3159 1.1 mrg
3160 1.1 mrg @item @emph{See also}:
3161 1.1 mrg @ref{C_LOC}, @ref{C_F_POINTER}
3162 1.1 mrg @end table
3163 1.1 mrg
3164 1.1 mrg
3165 1.1 mrg @node C_FUNLOC
3166 1.1 mrg @section @code{C_FUNLOC} --- Obtain the C address of a procedure
3167 1.1 mrg @fnindex C_FUNLOC
3168 1.1 mrg @cindex pointer, C address of procedures
3169 1.1 mrg
3170 1.1 mrg @table @asis
3171 1.1 mrg @item @emph{Description}:
3172 1.1 mrg @code{C_FUNLOC(x)} determines the C address of the argument.
3173 1.1 mrg
3174 1.1 mrg @item @emph{Standard}:
3175 1.1 mrg Fortran 2003 and later
3176 1.1 mrg
3177 1.1 mrg @item @emph{Class}:
3178 1.1 mrg Inquiry function
3179 1.1 mrg
3180 1.1 mrg @item @emph{Syntax}:
3181 1.1 mrg @code{RESULT = C_FUNLOC(x)}
3182 1.1 mrg
3183 1.1 mrg @item @emph{Arguments}:
3184 1.1 mrg @multitable @columnfractions .15 .70
3185 1.1 mrg @item @var{x} @tab Interoperable function or pointer to such function.
3186 1.1 mrg @end multitable
3187 1.1 mrg
3188 1.1 mrg @item @emph{Return value}:
3189 1.1 mrg The return value is of type @code{C_FUNPTR} and contains the C address
3190 1.1 mrg of the argument.
3191 1.1 mrg
3192 1.1 mrg @item @emph{Example}:
3193 1.1 mrg @smallexample
3194 1.1 mrg module x
3195 1.1 mrg use iso_c_binding
3196 1.1 mrg implicit none
3197 1.1 mrg contains
3198 1.1 mrg subroutine sub(a) bind(c)
3199 1.1 mrg real(c_float) :: a
3200 1.1 mrg a = sqrt(a)+5.0
3201 1.1 mrg end subroutine sub
3202 1.1 mrg end module x
3203 1.1 mrg program main
3204 1.1 mrg use iso_c_binding
3205 1.1 mrg use x
3206 1.1 mrg implicit none
3207 1.1 mrg interface
3208 1.1 mrg subroutine my_routine(p) bind(c,name='myC_func')
3209 1.1 mrg import :: c_funptr
3210 1.1 mrg type(c_funptr), intent(in) :: p
3211 1.1 mrg end subroutine
3212 1.1 mrg end interface
3213 1.1 mrg call my_routine(c_funloc(sub))
3214 1.1 mrg end program main
3215 1.1 mrg @end smallexample
3216 1.1 mrg
3217 1.1 mrg @item @emph{See also}:
3218 1.1 mrg @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
3219 1.1 mrg @end table
3220 1.1 mrg
3221 1.1 mrg
3222 1.1 mrg @node C_LOC
3223 1.1 mrg @section @code{C_LOC} --- Obtain the C address of an object
3224 1.1 mrg @fnindex C_LOC
3225 1.1 mrg @cindex procedure pointer, convert C to Fortran
3226 1.1 mrg
3227 1.1 mrg @table @asis
3228 1.1 mrg @item @emph{Description}:
3229 1.1 mrg @code{C_LOC(X)} determines the C address of the argument.
3230 1.1 mrg
3231 1.1 mrg @item @emph{Standard}:
3232 1.1 mrg Fortran 2003 and later
3233 1.1 mrg
3234 1.1 mrg @item @emph{Class}:
3235 1.1 mrg Inquiry function
3236 1.1 mrg
3237 1.1 mrg @item @emph{Syntax}:
3238 1.1 mrg @code{RESULT = C_LOC(X)}
3239 1.1 mrg
3240 1.1 mrg @item @emph{Arguments}:
3241 1.1 mrg @multitable @columnfractions .10 .75
3242 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.
3243 1.1 mrg
3244 1.1 mrg @end multitable
3245 1.1 mrg
3246 1.1 mrg @item @emph{Return value}:
3247 1.1 mrg The return value is of type @code{C_PTR} and contains the C address
3248 1.1 mrg of the argument.
3249 1.1 mrg
3250 1.1 mrg @item @emph{Example}:
3251 1.1 mrg @smallexample
3252 1.1 mrg subroutine association_test(a,b)
3253 1.1 mrg use iso_c_binding, only: c_associated, c_loc, c_ptr
3254 1.1 mrg implicit none
3255 1.1 mrg real, pointer :: a
3256 1.1 mrg type(c_ptr) :: b
3257 1.1 mrg if(c_associated(b, c_loc(a))) &
3258 1.1 mrg stop 'b and a do not point to same target'
3259 1.1 mrg end subroutine association_test
3260 1.1 mrg @end smallexample
3261 1.1 mrg
3262 1.1 mrg @item @emph{See also}:
3263 1.1 mrg @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
3264 1.1 mrg @end table
3265 1.1 mrg
3266 1.1 mrg
3267 1.1 mrg @node C_SIZEOF
3268 1.1 mrg @section @code{C_SIZEOF} --- Size in bytes of an expression
3269 1.1 mrg @fnindex C_SIZEOF
3270 1.1 mrg @cindex expression size
3271 1.1 mrg @cindex size of an expression
3272 1.1 mrg
3273 1.1 mrg @table @asis
3274 1.1 mrg @item @emph{Description}:
3275 1.1 mrg @code{C_SIZEOF(X)} calculates the number of bytes of storage the
3276 1.1 mrg expression @code{X} occupies.
3277 1.1 mrg
3278 1.1 mrg @item @emph{Standard}:
3279 1.1 mrg Fortran 2008
3280 1.1 mrg
3281 1.1 mrg @item @emph{Class}:
3282 1.1 mrg Inquiry function of the module @code{ISO_C_BINDING}
3283 1.1 mrg
3284 1.1 mrg @item @emph{Syntax}:
3285 1.1 mrg @code{N = C_SIZEOF(X)}
3286 1.1 mrg
3287 1.1 mrg @item @emph{Arguments}:
3288 1.1 mrg @multitable @columnfractions .15 .70
3289 1.1 mrg @item @var{X} @tab The argument shall be an interoperable data entity.
3290 1.1 mrg @end multitable
3291 1.1 mrg
3292 1.1 mrg @item @emph{Return value}:
3293 1.1 mrg The return value is of type integer and of the system-dependent kind
3294 1.1 mrg @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
3295 1.1 mrg number of bytes occupied by the argument. If the argument has the
3296 1.1 mrg @code{POINTER} attribute, the number of bytes of the storage area pointed
3297 1.1 mrg to is returned. If the argument is of a derived type with @code{POINTER}
3298 1.1 mrg or @code{ALLOCATABLE} components, the return value does not account for
3299 1.1 mrg the sizes of the data pointed to by these components.
3300 1.1 mrg
3301 1.1 mrg @item @emph{Example}:
3302 1.1 mrg @smallexample
3303 1.1 mrg use iso_c_binding
3304 1.1 mrg integer(c_int) :: i
3305 1.1 mrg real(c_float) :: r, s(5)
3306 1.1 mrg print *, (c_sizeof(s)/c_sizeof(r) == 5)
3307 1.1 mrg end
3308 1.1 mrg @end smallexample
3309 1.1 mrg The example will print @code{.TRUE.} unless you are using a platform
3310 1.1 mrg where default @code{REAL} variables are unusually padded.
3311 1.1 mrg
3312 1.1 mrg @item @emph{See also}:
3313 1.1 mrg @ref{SIZEOF}, @ref{STORAGE_SIZE}
3314 1.1 mrg @end table
3315 1.1 mrg
3316 1.1 mrg
3317 1.1 mrg @node CEILING
3318 1.1 mrg @section @code{CEILING} --- Integer ceiling function
3319 1.1 mrg @fnindex CEILING
3320 1.1 mrg @cindex ceiling
3321 1.1 mrg @cindex rounding, ceiling
3322 1.1 mrg
3323 1.1 mrg @table @asis
3324 1.1 mrg @item @emph{Description}:
3325 1.1 mrg @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
3326 1.1 mrg
3327 1.1 mrg @item @emph{Standard}:
3328 1.1 mrg Fortran 95 and later
3329 1.1 mrg
3330 1.1 mrg @item @emph{Class}:
3331 1.1 mrg Elemental function
3332 1.1 mrg
3333 1.1 mrg @item @emph{Syntax}:
3334 1.1 mrg @code{RESULT = CEILING(A [, KIND])}
3335 1.1 mrg
3336 1.1 mrg @item @emph{Arguments}:
3337 1.1 mrg @multitable @columnfractions .15 .70
3338 1.1 mrg @item @var{A} @tab The type shall be @code{REAL}.
3339 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3340 1.1 mrg expression indicating the kind parameter of the result.
3341 1.1 mrg @end multitable
3342 1.1 mrg
3343 1.1 mrg @item @emph{Return value}:
3344 1.1 mrg The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
3345 1.1 mrg and a default-kind @code{INTEGER} otherwise.
3346 1.1 mrg
3347 1.1 mrg @item @emph{Example}:
3348 1.1 mrg @smallexample
3349 1.1 mrg program test_ceiling
3350 1.1 mrg real :: x = 63.29
3351 1.1 mrg real :: y = -63.59
3352 1.1 mrg print *, ceiling(x) ! returns 64
3353 1.1 mrg print *, ceiling(y) ! returns -63
3354 1.1 mrg end program test_ceiling
3355 1.1 mrg @end smallexample
3356 1.1 mrg
3357 1.1 mrg @item @emph{See also}:
3358 1.1 mrg @ref{FLOOR}, @ref{NINT}
3359 1.1 mrg
3360 1.1 mrg @end table
3361 1.1 mrg
3362 1.1 mrg
3363 1.1 mrg
3364 1.1 mrg @node CHAR
3365 1.1 mrg @section @code{CHAR} --- Character conversion function
3366 1.1 mrg @fnindex CHAR
3367 1.1 mrg @cindex conversion, to character
3368 1.1 mrg
3369 1.1 mrg @table @asis
3370 1.1 mrg @item @emph{Description}:
3371 1.1 mrg @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
3372 1.1 mrg
3373 1.1 mrg @item @emph{Standard}:
3374 1.1 mrg Fortran 77 and later
3375 1.1 mrg
3376 1.1 mrg @item @emph{Class}:
3377 1.1 mrg Elemental function
3378 1.1 mrg
3379 1.1 mrg @item @emph{Syntax}:
3380 1.1 mrg @code{RESULT = CHAR(I [, KIND])}
3381 1.1 mrg
3382 1.1 mrg @item @emph{Arguments}:
3383 1.1 mrg @multitable @columnfractions .15 .70
3384 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
3385 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3386 1.1 mrg expression indicating the kind parameter of the result.
3387 1.1 mrg @end multitable
3388 1.1 mrg
3389 1.1 mrg @item @emph{Return value}:
3390 1.1 mrg The return value is of type @code{CHARACTER(1)}
3391 1.1 mrg
3392 1.1 mrg @item @emph{Example}:
3393 1.1 mrg @smallexample
3394 1.1 mrg program test_char
3395 1.1 mrg integer :: i = 74
3396 1.1 mrg character(1) :: c
3397 1.1 mrg c = char(i)
3398 1.1 mrg print *, i, c ! returns 'J'
3399 1.1 mrg end program test_char
3400 1.1 mrg @end smallexample
3401 1.1 mrg
3402 1.1 mrg @item @emph{Specific names}:
3403 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
3404 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
3405 1.1 mrg @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
3406 1.1 mrg @end multitable
3407 1.1 mrg
3408 1.1 mrg @item @emph{Note}:
3409 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values
3410 1.1 mrg and formatted string representations.
3411 1.1 mrg
3412 1.1 mrg @item @emph{See also}:
3413 1.1 mrg @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
3414 1.1 mrg
3415 1.1 mrg @end table
3416 1.1 mrg
3417 1.1 mrg
3418 1.1 mrg
3419 1.1 mrg @node CHDIR
3420 1.1 mrg @section @code{CHDIR} --- Change working directory
3421 1.1 mrg @fnindex CHDIR
3422 1.1 mrg @cindex system, working directory
3423 1.1 mrg
3424 1.1 mrg @table @asis
3425 1.1 mrg @item @emph{Description}:
3426 1.1 mrg Change current working directory to a specified path.
3427 1.1 mrg
3428 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
3429 1.1 mrg only one form can be used in any given program unit.
3430 1.1 mrg
3431 1.1 mrg @item @emph{Standard}:
3432 1.1 mrg GNU extension
3433 1.1 mrg
3434 1.1 mrg @item @emph{Class}:
3435 1.1 mrg Subroutine, function
3436 1.1 mrg
3437 1.1 mrg @item @emph{Syntax}:
3438 1.1 mrg @multitable @columnfractions .80
3439 1.1 mrg @item @code{CALL CHDIR(NAME [, STATUS])}
3440 1.1 mrg @item @code{STATUS = CHDIR(NAME)}
3441 1.1 mrg @end multitable
3442 1.1 mrg
3443 1.1 mrg @item @emph{Arguments}:
3444 1.1 mrg @multitable @columnfractions .15 .70
3445 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER} of default
3446 1.1 mrg kind and shall specify a valid path within the file system.
3447 1.1 mrg @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
3448 1.1 mrg kind. Returns 0 on success, and a system specific and nonzero error code
3449 1.1 mrg otherwise.
3450 1.1 mrg @end multitable
3451 1.1 mrg
3452 1.1 mrg @item @emph{Example}:
3453 1.1 mrg @smallexample
3454 1.1 mrg PROGRAM test_chdir
3455 1.1 mrg CHARACTER(len=255) :: path
3456 1.1 mrg CALL getcwd(path)
3457 1.1 mrg WRITE(*,*) TRIM(path)
3458 1.1 mrg CALL chdir("/tmp")
3459 1.1 mrg CALL getcwd(path)
3460 1.1 mrg WRITE(*,*) TRIM(path)
3461 1.1 mrg END PROGRAM
3462 1.1 mrg @end smallexample
3463 1.1 mrg
3464 1.1 mrg @item @emph{See also}:
3465 1.1 mrg @ref{GETCWD}
3466 1.1 mrg @end table
3467 1.1 mrg
3468 1.1 mrg
3469 1.1 mrg
3470 1.1 mrg @node CHMOD
3471 1.1 mrg @section @code{CHMOD} --- Change access permissions of files
3472 1.1 mrg @fnindex CHMOD
3473 1.1 mrg @cindex file system, change access mode
3474 1.1 mrg
3475 1.1 mrg @table @asis
3476 1.1 mrg @item @emph{Description}:
3477 1.1 mrg @code{CHMOD} changes the permissions of a file.
3478 1.1 mrg
3479 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
3480 1.1 mrg only one form can be used in any given program unit.
3481 1.1 mrg
3482 1.1 mrg @item @emph{Standard}:
3483 1.1 mrg GNU extension
3484 1.1 mrg
3485 1.1 mrg @item @emph{Class}:
3486 1.1 mrg Subroutine, function
3487 1.1 mrg
3488 1.1 mrg @item @emph{Syntax}:
3489 1.1 mrg @multitable @columnfractions .80
3490 1.1 mrg @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
3491 1.1 mrg @item @code{STATUS = CHMOD(NAME, MODE)}
3492 1.1 mrg @end multitable
3493 1.1 mrg
3494 1.1 mrg @item @emph{Arguments}:
3495 1.1 mrg @multitable @columnfractions .15 .70
3496 1.1 mrg
3497 1.1 mrg @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
3498 1.1 mrg file name. Trailing blanks are ignored unless the character
3499 1.1 mrg @code{achar(0)} is present, then all characters up to and excluding
3500 1.1 mrg @code{achar(0)} are used as the file name.
3501 1.1 mrg
3502 1.1 mrg @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
3503 1.1 mrg file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
3504 1.1 mrg as defined by the POSIX standard. The argument shall either be a string of
3505 1.1 mrg a nonnegative octal number or a symbolic mode.
3506 1.1 mrg
3507 1.1 mrg @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
3508 1.1 mrg @code{0} on success and nonzero otherwise.
3509 1.1 mrg @end multitable
3510 1.1 mrg
3511 1.1 mrg @item @emph{Return value}:
3512 1.1 mrg In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
3513 1.1 mrg otherwise.
3514 1.1 mrg
3515 1.1 mrg @item @emph{Example}:
3516 1.1 mrg @code{CHMOD} as subroutine
3517 1.1 mrg @smallexample
3518 1.1 mrg program chmod_test
3519 1.1 mrg implicit none
3520 1.1 mrg integer :: status
3521 1.1 mrg call chmod('test.dat','u+x',status)
3522 1.1 mrg print *, 'Status: ', status
3523 1.1 mrg end program chmod_test
3524 1.1 mrg @end smallexample
3525 1.1 mrg @code{CHMOD} as function:
3526 1.1 mrg @smallexample
3527 1.1 mrg program chmod_test
3528 1.1 mrg implicit none
3529 1.1 mrg integer :: status
3530 1.1 mrg status = chmod('test.dat','u+x')
3531 1.1 mrg print *, 'Status: ', status
3532 1.1 mrg end program chmod_test
3533 1.1 mrg @end smallexample
3534 1.1 mrg
3535 1.1 mrg @end table
3536 1.1 mrg
3537 1.1 mrg
3538 1.1 mrg
3539 1.1 mrg @node CMPLX
3540 1.1 mrg @section @code{CMPLX} --- Complex conversion function
3541 1.1 mrg @fnindex CMPLX
3542 1.1 mrg @cindex complex numbers, conversion to
3543 1.1 mrg @cindex conversion, to complex
3544 1.1 mrg
3545 1.1 mrg @table @asis
3546 1.1 mrg @item @emph{Description}:
3547 1.1 mrg @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
3548 1.1 mrg the real component. If @var{Y} is present it is converted to the imaginary
3549 1.1 mrg component. If @var{Y} is not present then the imaginary component is set to
3550 1.1 mrg 0.0. If @var{X} is complex then @var{Y} must not be present.
3551 1.1 mrg
3552 1.1 mrg @item @emph{Standard}:
3553 1.1 mrg Fortran 77 and later
3554 1.1 mrg
3555 1.1 mrg @item @emph{Class}:
3556 1.1 mrg Elemental function
3557 1.1 mrg
3558 1.1 mrg @item @emph{Syntax}:
3559 1.1 mrg @code{RESULT = CMPLX(X [, Y [, KIND]])}
3560 1.1 mrg
3561 1.1 mrg @item @emph{Arguments}:
3562 1.1 mrg @multitable @columnfractions .15 .70
3563 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3564 1.1 mrg or @code{COMPLEX}.
3565 1.1 mrg @item @var{Y} @tab (Optional; only allowed if @var{X} is not
3566 1.1 mrg @code{COMPLEX}.) May be @code{INTEGER} or @code{REAL}.
3567 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3568 1.1 mrg expression indicating the kind parameter of the result.
3569 1.1 mrg @end multitable
3570 1.1 mrg
3571 1.1 mrg @item @emph{Return value}:
3572 1.1 mrg The return value is of @code{COMPLEX} type, with a kind equal to
3573 1.1 mrg @var{KIND} if it is specified. If @var{KIND} is not specified, the
3574 1.1 mrg result is of the default @code{COMPLEX} kind, regardless of the kinds of
3575 1.1 mrg @var{X} and @var{Y}.
3576 1.1 mrg
3577 1.1 mrg @item @emph{Example}:
3578 1.1 mrg @smallexample
3579 1.1 mrg program test_cmplx
3580 1.1 mrg integer :: i = 42
3581 1.1 mrg real :: x = 3.14
3582 1.1 mrg complex :: z
3583 1.1 mrg z = cmplx(i, x)
3584 1.1 mrg print *, z, cmplx(x)
3585 1.1 mrg end program test_cmplx
3586 1.1 mrg @end smallexample
3587 1.1 mrg
3588 1.1 mrg @item @emph{See also}:
3589 1.1 mrg @ref{COMPLEX}
3590 1.1 mrg @end table
3591 1.1 mrg
3592 1.1 mrg
3593 1.1 mrg
3594 1.1 mrg @node CO_BROADCAST
3595 1.1 mrg @section @code{CO_BROADCAST} --- Copy a value to all images the current set of images
3596 1.1 mrg @fnindex CO_BROADCAST
3597 1.1 mrg @cindex Collectives, value broadcasting
3598 1.1 mrg
3599 1.1 mrg @table @asis
3600 1.1 mrg @item @emph{Description}:
3601 1.1 mrg @code{CO_BROADCAST} copies the value of argument @var{A} on the image with
3602 1.1 mrg image index @code{SOURCE_IMAGE} to all images in the current team. @var{A}
3603 1.1 mrg becomes defined as if by intrinsic assignment. If the execution was
3604 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the
3605 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3606 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error.
3607 1.1 mrg
3608 1.1 mrg @item @emph{Standard}:
3609 1.1 mrg Technical Specification (TS) 18508 or later
3610 1.1 mrg
3611 1.1 mrg @item @emph{Class}:
3612 1.1 mrg Collective subroutine
3613 1.1 mrg
3614 1.1 mrg @item @emph{Syntax}:
3615 1.1 mrg @code{CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])}
3616 1.1 mrg
3617 1.1 mrg @item @emph{Arguments}:
3618 1.1 mrg @multitable @columnfractions .15 .70
3619 1.1 mrg @item @var{A} @tab INTENT(INOUT) argument; shall have the same
3620 1.1 mrg dynamic type and type paramters on all images of the current team. If it
3621 1.1 mrg is an array, it shall have the same shape on all images.
3622 1.1 mrg @item @var{SOURCE_IMAGE} @tab a scalar integer expression.
3623 1.1 mrg It shall have the same the same value on all images and refer to an
3624 1.1 mrg image of the current team.
3625 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3626 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3627 1.1 mrg @end multitable
3628 1.1 mrg
3629 1.1 mrg @item @emph{Example}:
3630 1.1 mrg @smallexample
3631 1.1 mrg program test
3632 1.1 mrg integer :: val(3)
3633 1.1 mrg if (this_image() == 1) then
3634 1.1 mrg val = [1, 5, 3]
3635 1.1 mrg end if
3636 1.1 mrg call co_broadcast (val, source_image=1)
3637 1.1 mrg print *, this_image, ":", val
3638 1.1 mrg end program test
3639 1.1 mrg @end smallexample
3640 1.1 mrg
3641 1.1 mrg @item @emph{See also}:
3642 1.1 mrg @ref{CO_MAX}, @ref{CO_MIN}, @ref{CO_SUM}, @ref{CO_REDUCE}
3643 1.1 mrg @end table
3644 1.1 mrg
3645 1.1 mrg
3646 1.1 mrg
3647 1.1 mrg @node CO_MAX
3648 1.1 mrg @section @code{CO_MAX} --- Maximal value on the current set of images
3649 1.1 mrg @fnindex CO_MAX
3650 1.1 mrg @cindex Collectives, maximal value
3651 1.1 mrg
3652 1.1 mrg @table @asis
3653 1.1 mrg @item @emph{Description}:
3654 1.1 mrg @code{CO_MAX} determines element-wise the maximal value of @var{A} on all
3655 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the maximum
3656 1.1 mrg values are returned in @var{A} on the specified image only and the value
3657 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3658 1.1 mrg not present, the value is returned on all images. If the execution was
3659 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the
3660 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3661 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error.
3662 1.1 mrg
3663 1.1 mrg @item @emph{Standard}:
3664 1.1 mrg Technical Specification (TS) 18508 or later
3665 1.1 mrg
3666 1.1 mrg @item @emph{Class}:
3667 1.1 mrg Collective subroutine
3668 1.1 mrg
3669 1.1 mrg @item @emph{Syntax}:
3670 1.1 mrg @code{CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG])}
3671 1.1 mrg
3672 1.1 mrg @item @emph{Arguments}:
3673 1.1 mrg @multitable @columnfractions .15 .70
3674 1.1 mrg @item @var{A} @tab shall be an integer, real or character variable,
3675 1.1 mrg which has the same type and type parameters on all images of the team.
3676 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3677 1.1 mrg present, it shall have the same the same value on all images and refer to an
3678 1.1 mrg image of the current team.
3679 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3680 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3681 1.1 mrg @end multitable
3682 1.1 mrg
3683 1.1 mrg @item @emph{Example}:
3684 1.1 mrg @smallexample
3685 1.1 mrg program test
3686 1.1 mrg integer :: val
3687 1.1 mrg val = this_image ()
3688 1.1 mrg call co_max (val, result_image=1)
3689 1.1 mrg if (this_image() == 1) then
3690 1.1 mrg write(*,*) "Maximal value", val ! prints num_images()
3691 1.1 mrg end if
3692 1.1 mrg end program test
3693 1.1 mrg @end smallexample
3694 1.1 mrg
3695 1.1 mrg @item @emph{See also}:
3696 1.1 mrg @ref{CO_MIN}, @ref{CO_SUM}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3697 1.1 mrg @end table
3698 1.1 mrg
3699 1.1 mrg
3700 1.1 mrg
3701 1.1 mrg @node CO_MIN
3702 1.1 mrg @section @code{CO_MIN} --- Minimal value on the current set of images
3703 1.1 mrg @fnindex CO_MIN
3704 1.1 mrg @cindex Collectives, minimal value
3705 1.1 mrg
3706 1.1 mrg @table @asis
3707 1.1 mrg @item @emph{Description}:
3708 1.1 mrg @code{CO_MIN} determines element-wise the minimal value of @var{A} on all
3709 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the minimal
3710 1.1 mrg values are returned in @var{A} on the specified image only and the value
3711 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3712 1.1 mrg not present, the value is returned on all images. If the execution was
3713 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the
3714 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3715 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error.
3716 1.1 mrg
3717 1.1 mrg @item @emph{Standard}:
3718 1.1 mrg Technical Specification (TS) 18508 or later
3719 1.1 mrg
3720 1.1 mrg @item @emph{Class}:
3721 1.1 mrg Collective subroutine
3722 1.1 mrg
3723 1.1 mrg @item @emph{Syntax}:
3724 1.1 mrg @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3725 1.1 mrg
3726 1.1 mrg @item @emph{Arguments}:
3727 1.1 mrg @multitable @columnfractions .15 .70
3728 1.1 mrg @item @var{A} @tab shall be an integer, real or character variable,
3729 1.1 mrg which has the same type and type parameters on all images of the team.
3730 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3731 1.1 mrg present, it shall have the same the same value on all images and refer to an
3732 1.1 mrg image of the current team.
3733 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3734 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3735 1.1 mrg @end multitable
3736 1.1 mrg
3737 1.1 mrg @item @emph{Example}:
3738 1.1 mrg @smallexample
3739 1.1 mrg program test
3740 1.1 mrg integer :: val
3741 1.1 mrg val = this_image ()
3742 1.1 mrg call co_min (val, result_image=1)
3743 1.1 mrg if (this_image() == 1) then
3744 1.1 mrg write(*,*) "Minimal value", val ! prints 1
3745 1.1 mrg end if
3746 1.1 mrg end program test
3747 1.1 mrg @end smallexample
3748 1.1 mrg
3749 1.1 mrg @item @emph{See also}:
3750 1.1 mrg @ref{CO_MAX}, @ref{CO_SUM}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3751 1.1 mrg @end table
3752 1.1 mrg
3753 1.1 mrg
3754 1.1 mrg
3755 1.1 mrg @node CO_REDUCE
3756 1.1 mrg @section @code{CO_REDUCE} --- Reduction of values on the current set of images
3757 1.1 mrg @fnindex CO_REDUCE
3758 1.1 mrg @cindex Collectives, generic reduction
3759 1.1 mrg
3760 1.1 mrg @table @asis
3761 1.1 mrg @item @emph{Description}:
3762 1.1 mrg @code{CO_REDUCE} determines element-wise the reduction of the value of @var{A}
3763 1.1 mrg on all images of the current team. The pure function passed as @var{OPERATOR}
3764 1.1 mrg is used to pairwise reduce the values of @var{A} by passing either the value
3765 1.1 mrg of @var{A} of different images or the result values of such a reduction as
3766 1.1 mrg argument. If @var{A} is an array, the deduction is done element wise. If
3767 1.1 mrg @var{RESULT_IMAGE} is present, the result values are returned in @var{A} on
3768 1.1 mrg the specified image only and the value of @var{A} on the other images become
3769 1.1 mrg undefined. If @var{RESULT_IMAGE} is not present, the value is returned on all
3770 1.1 mrg images. If the execution was successful and @var{STAT} is present, it is
3771 1.1 mrg assigned the value zero. If the execution failed, @var{STAT} gets assigned
3772 1.1 mrg a nonzero value and, if present, @var{ERRMSG} gets assigned a value describing
3773 1.1 mrg the occurred error.
3774 1.1 mrg
3775 1.1 mrg @item @emph{Standard}:
3776 1.1 mrg Technical Specification (TS) 18508 or later
3777 1.1 mrg
3778 1.1 mrg @item @emph{Class}:
3779 1.1 mrg Collective subroutine
3780 1.1 mrg
3781 1.1 mrg @item @emph{Syntax}:
3782 1.1 mrg @code{CALL CO_REDUCE(A, OPERATOR, [, RESULT_IMAGE, STAT, ERRMSG])}
3783 1.1 mrg
3784 1.1 mrg @item @emph{Arguments}:
3785 1.1 mrg @multitable @columnfractions .15 .70
3786 1.1 mrg @item @var{A} @tab is an @code{INTENT(INOUT)} argument and shall be
3787 1.1 mrg nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer,
3788 1.1 mrg it shall be associated. @var{A} shall have the same type and type parameters on
3789 1.1 mrg all images of the team; if it is an array, it shall have the same shape on all
3790 1.1 mrg images.
3791 1.1 mrg @item @var{OPERATOR} @tab pure function with two scalar nonallocatable
3792 1.1 mrg arguments, which shall be nonpolymorphic and have the same type and type
3793 1.1 mrg parameters as @var{A}. The function shall return a nonallocatable scalar of
3794 1.1 mrg the same type and type parameters as @var{A}. The function shall be the same on
3795 1.1 mrg all images and with regards to the arguments mathematically commutative and
3796 1.1 mrg associative. Note that @var{OPERATOR} may not be an elemental function, unless
3797 1.1 mrg it is an intrisic function.
3798 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3799 1.1 mrg present, it shall have the same the same value on all images and refer to an
3800 1.1 mrg image of the current team.
3801 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3802 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3803 1.1 mrg @end multitable
3804 1.1 mrg
3805 1.1 mrg @item @emph{Example}:
3806 1.1 mrg @smallexample
3807 1.1 mrg program test
3808 1.1 mrg integer :: val
3809 1.1 mrg val = this_image ()
3810 1.1 mrg call co_reduce (val, result_image=1, operator=myprod)
3811 1.1 mrg if (this_image() == 1) then
3812 1.1 mrg write(*,*) "Product value", val ! prints num_images() factorial
3813 1.1 mrg end if
3814 1.1 mrg contains
3815 1.1 mrg pure function myprod(a, b)
3816 1.1 mrg integer, value :: a, b
3817 1.1 mrg integer :: myprod
3818 1.1 mrg myprod = a * b
3819 1.1 mrg end function myprod
3820 1.1 mrg end program test
3821 1.1 mrg @end smallexample
3822 1.1 mrg
3823 1.1 mrg @item @emph{Note}:
3824 1.1 mrg While the rules permit in principle an intrinsic function, none of the
3825 1.1 mrg intrinsics in the standard fulfill the criteria of having a specific
3826 1.1 mrg function, which takes two arguments of the same type and returning that
3827 1.1 mrg type as result.
3828 1.1 mrg
3829 1.1 mrg @item @emph{See also}:
3830 1.1 mrg @ref{CO_MIN}, @ref{CO_MAX}, @ref{CO_SUM}, @ref{CO_BROADCAST}
3831 1.1 mrg @end table
3832 1.1 mrg
3833 1.1 mrg
3834 1.1 mrg
3835 1.1 mrg @node CO_SUM
3836 1.1 mrg @section @code{CO_SUM} --- Sum of values on the current set of images
3837 1.1 mrg @fnindex CO_SUM
3838 1.1 mrg @cindex Collectives, sum of values
3839 1.1 mrg
3840 1.1 mrg @table @asis
3841 1.1 mrg @item @emph{Description}:
3842 1.1 mrg @code{CO_SUM} sums up the values of each element of @var{A} on all
3843 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the summed-up
3844 1.1 mrg values are returned in @var{A} on the specified image only and the value
3845 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3846 1.1 mrg not present, the value is returned on all images. If the execution was
3847 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the
3848 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3849 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error.
3850 1.1 mrg
3851 1.1 mrg @item @emph{Standard}:
3852 1.1 mrg Technical Specification (TS) 18508 or later
3853 1.1 mrg
3854 1.1 mrg @item @emph{Class}:
3855 1.1 mrg Collective subroutine
3856 1.1 mrg
3857 1.1 mrg @item @emph{Syntax}:
3858 1.1 mrg @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3859 1.1 mrg
3860 1.1 mrg @item @emph{Arguments}:
3861 1.1 mrg @multitable @columnfractions .15 .70
3862 1.1 mrg @item @var{A} @tab shall be an integer, real or complex variable,
3863 1.1 mrg which has the same type and type parameters on all images of the team.
3864 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3865 1.1 mrg present, it shall have the same the same value on all images and refer to an
3866 1.1 mrg image of the current team.
3867 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable
3868 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable
3869 1.1 mrg @end multitable
3870 1.1 mrg
3871 1.1 mrg @item @emph{Example}:
3872 1.1 mrg @smallexample
3873 1.1 mrg program test
3874 1.1 mrg integer :: val
3875 1.1 mrg val = this_image ()
3876 1.1 mrg call co_sum (val, result_image=1)
3877 1.1 mrg if (this_image() == 1) then
3878 1.1 mrg write(*,*) "The sum is ", val ! prints (n**2 + n)/2, with n = num_images()
3879 1.1 mrg end if
3880 1.1 mrg end program test
3881 1.1 mrg @end smallexample
3882 1.1 mrg
3883 1.1 mrg @item @emph{See also}:
3884 1.1 mrg @ref{CO_MAX}, @ref{CO_MIN}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3885 1.1 mrg @end table
3886 1.1 mrg
3887 1.1 mrg
3888 1.1 mrg
3889 1.1 mrg @node COMMAND_ARGUMENT_COUNT
3890 1.1 mrg @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
3891 1.1 mrg @fnindex COMMAND_ARGUMENT_COUNT
3892 1.1 mrg @cindex command-line arguments
3893 1.1 mrg @cindex command-line arguments, number of
3894 1.1 mrg @cindex arguments, to program
3895 1.1 mrg
3896 1.1 mrg @table @asis
3897 1.1 mrg @item @emph{Description}:
3898 1.1 mrg @code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the
3899 1.1 mrg command line when the containing program was invoked.
3900 1.1 mrg
3901 1.1 mrg @item @emph{Standard}:
3902 1.1 mrg Fortran 2003 and later
3903 1.1 mrg
3904 1.1 mrg @item @emph{Class}:
3905 1.1 mrg Inquiry function
3906 1.1 mrg
3907 1.1 mrg @item @emph{Syntax}:
3908 1.1 mrg @code{RESULT = COMMAND_ARGUMENT_COUNT()}
3909 1.1 mrg
3910 1.1 mrg @item @emph{Arguments}:
3911 1.1 mrg @multitable @columnfractions .15 .70
3912 1.1 mrg @item None
3913 1.1 mrg @end multitable
3914 1.1 mrg
3915 1.1 mrg @item @emph{Return value}:
3916 1.1 mrg The return value is an @code{INTEGER} of default kind.
3917 1.1 mrg
3918 1.1 mrg @item @emph{Example}:
3919 1.1 mrg @smallexample
3920 1.1 mrg program test_command_argument_count
3921 1.1 mrg integer :: count
3922 1.1 mrg count = command_argument_count()
3923 1.1 mrg print *, count
3924 1.1 mrg end program test_command_argument_count
3925 1.1 mrg @end smallexample
3926 1.1 mrg
3927 1.1 mrg @item @emph{See also}:
3928 1.1 mrg @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
3929 1.1 mrg @end table
3930 1.1 mrg
3931 1.1 mrg
3932 1.1 mrg
3933 1.1 mrg @node COMPILER_OPTIONS
3934 1.1 mrg @section @code{COMPILER_OPTIONS} --- Options passed to the compiler
3935 1.1 mrg @fnindex COMPILER_OPTIONS
3936 1.1 mrg @cindex flags inquiry function
3937 1.1 mrg @cindex options inquiry function
3938 1.1 mrg @cindex compiler flags inquiry function
3939 1.1 mrg
3940 1.1 mrg @table @asis
3941 1.1 mrg @item @emph{Description}:
3942 1.1 mrg @code{COMPILER_OPTIONS} returns a string with the options used for
3943 1.1 mrg compiling.
3944 1.1 mrg
3945 1.1 mrg @item @emph{Standard}:
3946 1.1 mrg Fortran 2008
3947 1.1 mrg
3948 1.1 mrg @item @emph{Class}:
3949 1.1 mrg Inquiry function of the module @code{ISO_FORTRAN_ENV}
3950 1.1 mrg
3951 1.1 mrg @item @emph{Syntax}:
3952 1.1 mrg @code{STR = COMPILER_OPTIONS()}
3953 1.1 mrg
3954 1.1 mrg @item @emph{Arguments}:
3955 1.1 mrg None.
3956 1.1 mrg
3957 1.1 mrg @item @emph{Return value}:
3958 1.1 mrg The return value is a default-kind string with system-dependent length.
3959 1.1 mrg It contains the compiler flags used to compile the file, which called
3960 1.1 mrg the @code{COMPILER_OPTIONS} intrinsic.
3961 1.1 mrg
3962 1.1 mrg @item @emph{Example}:
3963 1.1 mrg @smallexample
3964 1.1 mrg use iso_fortran_env
3965 1.1 mrg print '(4a)', 'This file was compiled by ', &
3966 1.1 mrg compiler_version(), ' using the options ', &
3967 1.1 mrg compiler_options()
3968 1.1 mrg end
3969 1.1 mrg @end smallexample
3970 1.1 mrg
3971 1.1 mrg @item @emph{See also}:
3972 1.1 mrg @ref{COMPILER_VERSION}, @ref{ISO_FORTRAN_ENV}
3973 1.1 mrg @end table
3974 1.1 mrg
3975 1.1 mrg
3976 1.1 mrg
3977 1.1 mrg @node COMPILER_VERSION
3978 1.1 mrg @section @code{COMPILER_VERSION} --- Compiler version string
3979 1.1 mrg @fnindex COMPILER_VERSION
3980 1.1 mrg @cindex compiler, name and version
3981 1.1 mrg @cindex version of the compiler
3982 1.1 mrg
3983 1.1 mrg @table @asis
3984 1.1 mrg @item @emph{Description}:
3985 1.1 mrg @code{COMPILER_VERSION} returns a string with the name and the
3986 1.1 mrg version of the compiler.
3987 1.1 mrg
3988 1.1 mrg @item @emph{Standard}:
3989 1.1 mrg Fortran 2008
3990 1.1 mrg
3991 1.1 mrg @item @emph{Class}:
3992 1.1 mrg Inquiry function of the module @code{ISO_FORTRAN_ENV}
3993 1.1 mrg
3994 1.1 mrg @item @emph{Syntax}:
3995 1.1 mrg @code{STR = COMPILER_VERSION()}
3996 1.1 mrg
3997 1.1 mrg @item @emph{Arguments}:
3998 1.1 mrg None.
3999 1.1 mrg
4000 1.1 mrg @item @emph{Return value}:
4001 1.1 mrg The return value is a default-kind string with system-dependent length.
4002 1.1 mrg It contains the name of the compiler and its version number.
4003 1.1 mrg
4004 1.1 mrg @item @emph{Example}:
4005 1.1 mrg @smallexample
4006 1.1 mrg use iso_fortran_env
4007 1.1 mrg print '(4a)', 'This file was compiled by ', &
4008 1.1 mrg compiler_version(), ' using the options ', &
4009 1.1 mrg compiler_options()
4010 1.1 mrg end
4011 1.1 mrg @end smallexample
4012 1.1 mrg
4013 1.1 mrg @item @emph{See also}:
4014 1.1 mrg @ref{COMPILER_OPTIONS}, @ref{ISO_FORTRAN_ENV}
4015 1.1 mrg @end table
4016 1.1 mrg
4017 1.1 mrg
4018 1.1 mrg
4019 1.1 mrg @node COMPLEX
4020 1.1 mrg @section @code{COMPLEX} --- Complex conversion function
4021 1.1 mrg @fnindex COMPLEX
4022 1.1 mrg @cindex complex numbers, conversion to
4023 1.1 mrg @cindex conversion, to complex
4024 1.1 mrg
4025 1.1 mrg @table @asis
4026 1.1 mrg @item @emph{Description}:
4027 1.1 mrg @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
4028 1.1 mrg to the real component and @var{Y} is converted to the imaginary
4029 1.1 mrg component.
4030 1.1 mrg
4031 1.1 mrg @item @emph{Standard}:
4032 1.1 mrg GNU extension
4033 1.1 mrg
4034 1.1 mrg @item @emph{Class}:
4035 1.1 mrg Elemental function
4036 1.1 mrg
4037 1.1 mrg @item @emph{Syntax}:
4038 1.1 mrg @code{RESULT = COMPLEX(X, Y)}
4039 1.1 mrg
4040 1.1 mrg @item @emph{Arguments}:
4041 1.1 mrg @multitable @columnfractions .15 .70
4042 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4043 1.1 mrg @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
4044 1.1 mrg @end multitable
4045 1.1 mrg
4046 1.1 mrg @item @emph{Return value}:
4047 1.1 mrg If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
4048 1.1 mrg value is of default @code{COMPLEX} type.
4049 1.1 mrg
4050 1.1 mrg If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
4051 1.1 mrg type and one is of @code{INTEGER} type, then the return value is of
4052 1.1 mrg @code{COMPLEX} type with a kind equal to that of the @code{REAL}
4053 1.1 mrg argument with the highest precision.
4054 1.1 mrg
4055 1.1 mrg @item @emph{Example}:
4056 1.1 mrg @smallexample
4057 1.1 mrg program test_complex
4058 1.1 mrg integer :: i = 42
4059 1.1 mrg real :: x = 3.14
4060 1.1 mrg print *, complex(i, x)
4061 1.1 mrg end program test_complex
4062 1.1 mrg @end smallexample
4063 1.1 mrg
4064 1.1 mrg @item @emph{See also}:
4065 1.1 mrg @ref{CMPLX}
4066 1.1 mrg @end table
4067 1.1 mrg
4068 1.1 mrg
4069 1.1 mrg
4070 1.1 mrg @node CONJG
4071 1.1 mrg @section @code{CONJG} --- Complex conjugate function
4072 1.1 mrg @fnindex CONJG
4073 1.1 mrg @fnindex DCONJG
4074 1.1 mrg @cindex complex conjugate
4075 1.1 mrg
4076 1.1 mrg @table @asis
4077 1.1 mrg @item @emph{Description}:
4078 1.1 mrg @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
4079 1.1 mrg then the result is @code{(x, -y)}
4080 1.1 mrg
4081 1.1 mrg @item @emph{Standard}:
4082 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
4083 1.1 mrg
4084 1.1 mrg @item @emph{Class}:
4085 1.1 mrg Elemental function
4086 1.1 mrg
4087 1.1 mrg @item @emph{Syntax}:
4088 1.1 mrg @code{Z = CONJG(Z)}
4089 1.1 mrg
4090 1.1 mrg @item @emph{Arguments}:
4091 1.1 mrg @multitable @columnfractions .15 .70
4092 1.1 mrg @item @var{Z} @tab The type shall be @code{COMPLEX}.
4093 1.1 mrg @end multitable
4094 1.1 mrg
4095 1.1 mrg @item @emph{Return value}:
4096 1.1 mrg The return value is of type @code{COMPLEX}.
4097 1.1 mrg
4098 1.1 mrg @item @emph{Example}:
4099 1.1 mrg @smallexample
4100 1.1 mrg program test_conjg
4101 1.1 mrg complex :: z = (2.0, 3.0)
4102 1.1 mrg complex(8) :: dz = (2.71_8, -3.14_8)
4103 1.1 mrg z= conjg(z)
4104 1.1 mrg print *, z
4105 1.1 mrg dz = dconjg(dz)
4106 1.1 mrg print *, dz
4107 1.1 mrg end program test_conjg
4108 1.1 mrg @end smallexample
4109 1.1 mrg
4110 1.1 mrg @item @emph{Specific names}:
4111 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4112 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4113 1.1 mrg @item @code{CONJG(Z)} @tab @code{COMPLEX Z} @tab @code{COMPLEX} @tab GNU extension
4114 1.1 mrg @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
4115 1.1 mrg @end multitable
4116 1.1 mrg @end table
4117 1.1 mrg
4118 1.1 mrg
4119 1.1 mrg
4120 1.1 mrg @node COS
4121 1.1 mrg @section @code{COS} --- Cosine function
4122 1.1 mrg @fnindex COS
4123 1.1 mrg @fnindex DCOS
4124 1.1 mrg @fnindex CCOS
4125 1.1 mrg @fnindex ZCOS
4126 1.1 mrg @fnindex CDCOS
4127 1.1 mrg @cindex trigonometric function, cosine
4128 1.1 mrg @cindex cosine
4129 1.1 mrg
4130 1.1 mrg @table @asis
4131 1.1 mrg @item @emph{Description}:
4132 1.1 mrg @code{COS(X)} computes the cosine of @var{X}.
4133 1.1 mrg
4134 1.1 mrg @item @emph{Standard}:
4135 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
4136 1.1 mrg
4137 1.1 mrg @item @emph{Class}:
4138 1.1 mrg Elemental function
4139 1.1 mrg
4140 1.1 mrg @item @emph{Syntax}:
4141 1.1 mrg @code{RESULT = COS(X)}
4142 1.1 mrg
4143 1.1 mrg @item @emph{Arguments}:
4144 1.1 mrg @multitable @columnfractions .15 .70
4145 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
4146 1.1 mrg @code{COMPLEX}.
4147 1.1 mrg @end multitable
4148 1.1 mrg
4149 1.1 mrg @item @emph{Return value}:
4150 1.1 mrg The return value is of the same type and kind as @var{X}. The real part
4151 1.1 mrg of the result is in radians. If @var{X} is of the type @code{REAL},
4152 1.1 mrg the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
4153 1.1 mrg
4154 1.1 mrg @item @emph{Example}:
4155 1.1 mrg @smallexample
4156 1.1 mrg program test_cos
4157 1.1 mrg real :: x = 0.0
4158 1.1 mrg x = cos(x)
4159 1.1 mrg end program test_cos
4160 1.1 mrg @end smallexample
4161 1.1 mrg
4162 1.1 mrg @item @emph{Specific names}:
4163 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4164 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4165 1.1 mrg @item @code{COS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4166 1.1 mrg @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4167 1.1 mrg @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
4168 1.1 mrg @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4169 1.1 mrg @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4170 1.1 mrg @end multitable
4171 1.1 mrg
4172 1.1 mrg @item @emph{See also}:
4173 1.1 mrg Inverse function: @ref{ACOS}
4174 1.1 mrg Degrees function: @ref{COSD}
4175 1.1 mrg
4176 1.1 mrg @end table
4177 1.1 mrg
4178 1.1 mrg
4179 1.1 mrg
4180 1.1 mrg @node COSD
4181 1.1 mrg @section @code{COSD} --- Cosine function, degrees
4182 1.1 mrg @fnindex COSD
4183 1.1 mrg @fnindex DCOSD
4184 1.1 mrg @fnindex CCOSD
4185 1.1 mrg @fnindex ZCOSD
4186 1.1 mrg @fnindex CDCOSD
4187 1.1 mrg @cindex trigonometric function, cosine, degrees
4188 1.1 mrg @cindex cosine, degrees
4189 1.1 mrg
4190 1.1 mrg @table @asis
4191 1.1 mrg @item @emph{Description}:
4192 1.1 mrg @code{COSD(X)} computes the cosine of @var{X} in degrees.
4193 1.1 mrg
4194 1.1 mrg This function is for compatibility only and should be avoided in favor of
4195 1.1 mrg standard constructs wherever possible.
4196 1.1 mrg
4197 1.1 mrg @item @emph{Standard}:
4198 1.1 mrg GNU Extension, enabled with @option{-fdec-math}.
4199 1.1 mrg
4200 1.1 mrg @item @emph{Class}:
4201 1.1 mrg Elemental function
4202 1.1 mrg
4203 1.1 mrg @item @emph{Syntax}:
4204 1.1 mrg @code{RESULT = COSD(X)}
4205 1.1 mrg
4206 1.1 mrg @item @emph{Arguments}:
4207 1.1 mrg @multitable @columnfractions .15 .70
4208 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
4209 1.1 mrg @code{COMPLEX}.
4210 1.1 mrg @end multitable
4211 1.1 mrg
4212 1.1 mrg @item @emph{Return value}:
4213 1.1 mrg The return value is of the same type and kind as @var{X}. The real part
4214 1.1 mrg of the result is in degrees. If @var{X} is of the type @code{REAL},
4215 1.1 mrg the return value lies in the range @math{ -1 \leq \cosd (x) \leq 1}.
4216 1.1 mrg
4217 1.1 mrg @item @emph{Example}:
4218 1.1 mrg @smallexample
4219 1.1 mrg program test_cosd
4220 1.1 mrg real :: x = 0.0
4221 1.1 mrg x = cosd(x)
4222 1.1 mrg end program test_cosd
4223 1.1 mrg @end smallexample
4224 1.1 mrg
4225 1.1 mrg @item @emph{Specific names}:
4226 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4227 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4228 1.1 mrg @item @code{COSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4229 1.1 mrg @item @code{DCOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4230 1.1 mrg @item @code{CCOSD(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU Extension
4231 1.1 mrg @item @code{ZCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4232 1.1 mrg @item @code{CDCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4233 1.1 mrg @end multitable
4234 1.1 mrg
4235 1.1 mrg @item @emph{See also}:
4236 1.1 mrg Inverse function: @ref{ACOSD}
4237 1.1 mrg Radians function: @ref{COS}
4238 1.1 mrg
4239 1.1 mrg @end table
4240 1.1 mrg
4241 1.1 mrg
4242 1.1 mrg
4243 1.1 mrg @node COSH
4244 1.1 mrg @section @code{COSH} --- Hyperbolic cosine function
4245 1.1 mrg @fnindex COSH
4246 1.1 mrg @fnindex DCOSH
4247 1.1 mrg @cindex hyperbolic cosine
4248 1.1 mrg @cindex hyperbolic function, cosine
4249 1.1 mrg @cindex cosine, hyperbolic
4250 1.1 mrg
4251 1.1 mrg @table @asis
4252 1.1 mrg @item @emph{Description}:
4253 1.1 mrg @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
4254 1.1 mrg
4255 1.1 mrg @item @emph{Standard}:
4256 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
4257 1.1 mrg
4258 1.1 mrg @item @emph{Class}:
4259 1.1 mrg Elemental function
4260 1.1 mrg
4261 1.1 mrg @item @emph{Syntax}:
4262 1.1 mrg @code{X = COSH(X)}
4263 1.1 mrg
4264 1.1 mrg @item @emph{Arguments}:
4265 1.1 mrg @multitable @columnfractions .15 .70
4266 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4267 1.1 mrg @end multitable
4268 1.1 mrg
4269 1.1 mrg @item @emph{Return value}:
4270 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is
4271 1.1 mrg complex, the imaginary part of the result is in radians. If @var{X}
4272 1.1 mrg is @code{REAL}, the return value has a lower bound of one,
4273 1.1 mrg @math{\cosh (x) \geq 1}.
4274 1.1 mrg
4275 1.1 mrg @item @emph{Example}:
4276 1.1 mrg @smallexample
4277 1.1 mrg program test_cosh
4278 1.1 mrg real(8) :: x = 1.0_8
4279 1.1 mrg x = cosh(x)
4280 1.1 mrg end program test_cosh
4281 1.1 mrg @end smallexample
4282 1.1 mrg
4283 1.1 mrg @item @emph{Specific names}:
4284 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4285 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4286 1.1 mrg @item @code{COSH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4287 1.1 mrg @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4288 1.1 mrg @end multitable
4289 1.1 mrg
4290 1.1 mrg @item @emph{See also}:
4291 1.1 mrg Inverse function: @ref{ACOSH}
4292 1.1 mrg
4293 1.1 mrg @end table
4294 1.1 mrg
4295 1.1 mrg
4296 1.1 mrg
4297 1.1 mrg @node COTAN
4298 1.1 mrg @section @code{COTAN} --- Cotangent function
4299 1.1 mrg @fnindex COTAN
4300 1.1 mrg @fnindex DCOTAN
4301 1.1 mrg @cindex trigonometric function, cotangent
4302 1.1 mrg @cindex cotangent
4303 1.1 mrg
4304 1.1 mrg @table @asis
4305 1.1 mrg @item @emph{Description}:
4306 1.1 mrg @code{COTAN(X)} computes the cotangent of @var{X}. Equivalent to @code{COS(x)}
4307 1.1 mrg divided by @code{SIN(x)}, or @code{1 / TAN(x)}.
4308 1.1 mrg
4309 1.1 mrg This function is for compatibility only and should be avoided in favor of
4310 1.1 mrg standard constructs wherever possible.
4311 1.1 mrg
4312 1.1 mrg @item @emph{Standard}:
4313 1.1 mrg GNU Extension, enabled with @option{-fdec-math}.
4314 1.1 mrg
4315 1.1 mrg @item @emph{Class}:
4316 1.1 mrg Elemental function
4317 1.1 mrg
4318 1.1 mrg @item @emph{Syntax}:
4319 1.1 mrg @code{RESULT = COTAN(X)}
4320 1.1 mrg
4321 1.1 mrg @item @emph{Arguments}:
4322 1.1 mrg @multitable @columnfractions .15 .70
4323 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4324 1.1 mrg @end multitable
4325 1.1 mrg
4326 1.1 mrg @item @emph{Return value}:
4327 1.1 mrg The return value has same type and kind as @var{X}, and its value is in radians.
4328 1.1 mrg
4329 1.1 mrg @item @emph{Example}:
4330 1.1 mrg @smallexample
4331 1.1 mrg program test_cotan
4332 1.1 mrg real(8) :: x = 0.165_8
4333 1.1 mrg x = cotan(x)
4334 1.1 mrg end program test_cotan
4335 1.1 mrg @end smallexample
4336 1.1 mrg
4337 1.1 mrg @item @emph{Specific names}:
4338 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4339 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4340 1.1 mrg @item @code{COTAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4341 1.1 mrg @item @code{DCOTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4342 1.1 mrg @end multitable
4343 1.1 mrg
4344 1.1 mrg @item @emph{See also}:
4345 1.1 mrg Converse function: @ref{TAN}
4346 1.1 mrg Degrees function: @ref{COTAND}
4347 1.1 mrg @end table
4348 1.1 mrg
4349 1.1 mrg
4350 1.1 mrg
4351 1.1 mrg @node COTAND
4352 1.1 mrg @section @code{COTAND} --- Cotangent function, degrees
4353 1.1 mrg @fnindex COTAND
4354 1.1 mrg @fnindex DCOTAND
4355 1.1 mrg @cindex trigonometric function, cotangent, degrees
4356 1.1 mrg @cindex cotangent, degrees
4357 1.1 mrg
4358 1.1 mrg @table @asis
4359 1.1 mrg @item @emph{Description}:
4360 1.1 mrg @code{COTAND(X)} computes the cotangent of @var{X} in degrees. Equivalent to
4361 1.1 mrg @code{COSD(x)} divided by @code{SIND(x)}, or @code{1 / TAND(x)}.
4362 1.1 mrg
4363 1.1 mrg @item @emph{Standard}:
4364 1.1 mrg GNU Extension, enabled with @option{-fdec-math}.
4365 1.1 mrg
4366 1.1 mrg This function is for compatibility only and should be avoided in favor of
4367 1.1 mrg standard constructs wherever possible.
4368 1.1 mrg
4369 1.1 mrg @item @emph{Class}:
4370 1.1 mrg Elemental function
4371 1.1 mrg
4372 1.1 mrg @item @emph{Syntax}:
4373 1.1 mrg @code{RESULT = COTAND(X)}
4374 1.1 mrg
4375 1.1 mrg @item @emph{Arguments}:
4376 1.1 mrg @multitable @columnfractions .15 .70
4377 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4378 1.1 mrg @end multitable
4379 1.1 mrg
4380 1.1 mrg @item @emph{Return value}:
4381 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees.
4382 1.1 mrg
4383 1.1 mrg @item @emph{Example}:
4384 1.1 mrg @smallexample
4385 1.1 mrg program test_cotand
4386 1.1 mrg real(8) :: x = 0.165_8
4387 1.1 mrg x = cotand(x)
4388 1.1 mrg end program test_cotand
4389 1.1 mrg @end smallexample
4390 1.1 mrg
4391 1.1 mrg @item @emph{Specific names}:
4392 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4393 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4394 1.1 mrg @item @code{COTAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4395 1.1 mrg @item @code{DCOTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4396 1.1 mrg @end multitable
4397 1.1 mrg
4398 1.1 mrg @item @emph{See also}:
4399 1.1 mrg Converse function: @ref{TAND}
4400 1.1 mrg Radians function: @ref{COTAN}
4401 1.1 mrg
4402 1.1 mrg @end table
4403 1.1 mrg
4404 1.1 mrg
4405 1.1 mrg
4406 1.1 mrg @node COUNT
4407 1.1 mrg @section @code{COUNT} --- Count function
4408 1.1 mrg @fnindex COUNT
4409 1.1 mrg @cindex array, conditionally count elements
4410 1.1 mrg @cindex array, element counting
4411 1.1 mrg @cindex array, number of elements
4412 1.1 mrg
4413 1.1 mrg @table @asis
4414 1.1 mrg @item @emph{Description}:
4415 1.1 mrg
4416 1.1 mrg Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
4417 1.1 mrg or, if the @var{DIM} argument is supplied, counts the number of
4418 1.1 mrg elements along each row of the array in the @var{DIM} direction.
4419 1.1 mrg If the array has zero size, or all of the elements of @var{MASK} are
4420 1.1 mrg @code{.FALSE.}, then the result is @code{0}.
4421 1.1 mrg
4422 1.1 mrg @item @emph{Standard}:
4423 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
4424 1.1 mrg
4425 1.1 mrg @item @emph{Class}:
4426 1.1 mrg Transformational function
4427 1.1 mrg
4428 1.1 mrg @item @emph{Syntax}:
4429 1.1 mrg @code{RESULT = COUNT(MASK [, DIM, KIND])}
4430 1.1 mrg
4431 1.1 mrg @item @emph{Arguments}:
4432 1.1 mrg @multitable @columnfractions .15 .70
4433 1.1 mrg @item @var{MASK} @tab The type shall be @code{LOGICAL}.
4434 1.1 mrg @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
4435 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4436 1.1 mrg expression indicating the kind parameter of the result.
4437 1.1 mrg @end multitable
4438 1.1 mrg
4439 1.1 mrg @item @emph{Return value}:
4440 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
4441 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
4442 1.1 mrg If @var{DIM} is present, the result is an array with a rank one less
4443 1.1 mrg than the rank of @var{ARRAY}, and a size corresponding to the shape
4444 1.1 mrg of @var{ARRAY} with the @var{DIM} dimension removed.
4445 1.1 mrg
4446 1.1 mrg @item @emph{Example}:
4447 1.1 mrg @smallexample
4448 1.1 mrg program test_count
4449 1.1 mrg integer, dimension(2,3) :: a, b
4450 1.1 mrg logical, dimension(2,3) :: mask
4451 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
4452 1.1 mrg b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
4453 1.1 mrg print '(3i3)', a(1,:)
4454 1.1 mrg print '(3i3)', a(2,:)
4455 1.1 mrg print *
4456 1.1 mrg print '(3i3)', b(1,:)
4457 1.1 mrg print '(3i3)', b(2,:)
4458 1.1 mrg print *
4459 1.1 mrg mask = a.ne.b
4460 1.1 mrg print '(3l3)', mask(1,:)
4461 1.1 mrg print '(3l3)', mask(2,:)
4462 1.1 mrg print *
4463 1.1 mrg print '(3i3)', count(mask)
4464 1.1 mrg print *
4465 1.1 mrg print '(3i3)', count(mask, 1)
4466 1.1 mrg print *
4467 1.1 mrg print '(3i3)', count(mask, 2)
4468 1.1 mrg end program test_count
4469 1.1 mrg @end smallexample
4470 1.1 mrg @end table
4471 1.1 mrg
4472 1.1 mrg
4473 1.1 mrg
4474 1.1 mrg @node CPU_TIME
4475 1.1 mrg @section @code{CPU_TIME} --- CPU elapsed time in seconds
4476 1.1 mrg @fnindex CPU_TIME
4477 1.1 mrg @cindex time, elapsed
4478 1.1 mrg
4479 1.1 mrg @table @asis
4480 1.1 mrg @item @emph{Description}:
4481 1.1 mrg Returns a @code{REAL} value representing the elapsed CPU time in
4482 1.1 mrg seconds. This is useful for testing segments of code to determine
4483 1.1 mrg execution time.
4484 1.1 mrg
4485 1.1 mrg If a time source is available, time will be reported with microsecond
4486 1.1 mrg resolution. If no time source is available, @var{TIME} is set to
4487 1.1 mrg @code{-1.0}.
4488 1.1 mrg
4489 1.1 mrg Note that @var{TIME} may contain a, system dependent, arbitrary offset
4490 1.1 mrg and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
4491 1.1 mrg value is meaningless, only differences between subsequent calls to
4492 1.1 mrg this subroutine, as shown in the example below, should be used.
4493 1.1 mrg
4494 1.1 mrg
4495 1.1 mrg @item @emph{Standard}:
4496 1.1 mrg Fortran 95 and later
4497 1.1 mrg
4498 1.1 mrg @item @emph{Class}:
4499 1.1 mrg Subroutine
4500 1.1 mrg
4501 1.1 mrg @item @emph{Syntax}:
4502 1.1 mrg @code{CALL CPU_TIME(TIME)}
4503 1.1 mrg
4504 1.1 mrg @item @emph{Arguments}:
4505 1.1 mrg @multitable @columnfractions .15 .70
4506 1.1 mrg @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
4507 1.1 mrg @end multitable
4508 1.1 mrg
4509 1.1 mrg @item @emph{Return value}:
4510 1.1 mrg None
4511 1.1 mrg
4512 1.1 mrg @item @emph{Example}:
4513 1.1 mrg @smallexample
4514 1.1 mrg program test_cpu_time
4515 1.1 mrg real :: start, finish
4516 1.1 mrg call cpu_time(start)
4517 1.1 mrg ! put code to test here
4518 1.1 mrg call cpu_time(finish)
4519 1.1 mrg print '("Time = ",f6.3," seconds.")',finish-start
4520 1.1 mrg end program test_cpu_time
4521 1.1 mrg @end smallexample
4522 1.1 mrg
4523 1.1 mrg @item @emph{See also}:
4524 1.1 mrg @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
4525 1.1 mrg @end table
4526 1.1 mrg
4527 1.1 mrg
4528 1.1 mrg
4529 1.1 mrg @node CSHIFT
4530 1.1 mrg @section @code{CSHIFT} --- Circular shift elements of an array
4531 1.1 mrg @fnindex CSHIFT
4532 1.1 mrg @cindex array, shift circularly
4533 1.1 mrg @cindex array, permutation
4534 1.1 mrg @cindex array, rotate
4535 1.1 mrg
4536 1.1 mrg @table @asis
4537 1.1 mrg @item @emph{Description}:
4538 1.1 mrg @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
4539 1.1 mrg @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
4540 1.1 mrg taken to be @code{1}. @var{DIM} is a scalar of type @code{INTEGER} in the
4541 1.1 mrg range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
4542 1.1 mrg If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
4543 1.1 mrg by @var{SHIFT} places. If rank is greater than one, then all complete rank one
4544 1.1 mrg sections of @var{ARRAY} along the given dimension are shifted. Elements
4545 1.1 mrg shifted out one end of each rank one section are shifted back in the other end.
4546 1.1 mrg
4547 1.1 mrg @item @emph{Standard}:
4548 1.1 mrg Fortran 95 and later
4549 1.1 mrg
4550 1.1 mrg @item @emph{Class}:
4551 1.1 mrg Transformational function
4552 1.1 mrg
4553 1.1 mrg @item @emph{Syntax}:
4554 1.1 mrg @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
4555 1.1 mrg
4556 1.1 mrg @item @emph{Arguments}:
4557 1.1 mrg @multitable @columnfractions .15 .70
4558 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type.
4559 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
4560 1.1 mrg @item @var{DIM} @tab The type shall be @code{INTEGER}.
4561 1.1 mrg @end multitable
4562 1.1 mrg
4563 1.1 mrg @item @emph{Return value}:
4564 1.1 mrg Returns an array of same type and rank as the @var{ARRAY} argument.
4565 1.1 mrg
4566 1.1 mrg @item @emph{Example}:
4567 1.1 mrg @smallexample
4568 1.1 mrg program test_cshift
4569 1.1 mrg integer, dimension(3,3) :: a
4570 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4571 1.1 mrg print '(3i3)', a(1,:)
4572 1.1 mrg print '(3i3)', a(2,:)
4573 1.1 mrg print '(3i3)', a(3,:)
4574 1.1 mrg a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
4575 1.1 mrg print *
4576 1.1 mrg print '(3i3)', a(1,:)
4577 1.1 mrg print '(3i3)', a(2,:)
4578 1.1 mrg print '(3i3)', a(3,:)
4579 1.1 mrg end program test_cshift
4580 1.1 mrg @end smallexample
4581 1.1 mrg @end table
4582 1.1 mrg
4583 1.1 mrg
4584 1.1 mrg
4585 1.1 mrg @node CTIME
4586 1.1 mrg @section @code{CTIME} --- Convert a time into a string
4587 1.1 mrg @fnindex CTIME
4588 1.1 mrg @cindex time, conversion to string
4589 1.1 mrg @cindex conversion, to string
4590 1.1 mrg
4591 1.1 mrg @table @asis
4592 1.1 mrg @item @emph{Description}:
4593 1.1 mrg @code{CTIME} converts a system time value, such as returned by
4594 1.1 mrg @ref{TIME8}, to a string. The output will be of the form @samp{Sat
4595 1.1 mrg Aug 19 18:13:14 1995}.
4596 1.1 mrg
4597 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
4598 1.1 mrg only one form can be used in any given program unit.
4599 1.1 mrg
4600 1.1 mrg @item @emph{Standard}:
4601 1.1 mrg GNU extension
4602 1.1 mrg
4603 1.1 mrg @item @emph{Class}:
4604 1.1 mrg Subroutine, function
4605 1.1 mrg
4606 1.1 mrg @item @emph{Syntax}:
4607 1.1 mrg @multitable @columnfractions .80
4608 1.1 mrg @item @code{CALL CTIME(TIME, RESULT)}.
4609 1.1 mrg @item @code{RESULT = CTIME(TIME)}.
4610 1.1 mrg @end multitable
4611 1.1 mrg
4612 1.1 mrg @item @emph{Arguments}:
4613 1.1 mrg @multitable @columnfractions .15 .70
4614 1.1 mrg @item @var{TIME} @tab The type shall be of type @code{INTEGER}.
4615 1.1 mrg @item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and
4616 1.1 mrg of default kind. It is an @code{INTENT(OUT)} argument. If the length
4617 1.1 mrg of this variable is too short for the time and date string to fit
4618 1.1 mrg completely, it will be blank on procedure return.
4619 1.1 mrg @end multitable
4620 1.1 mrg
4621 1.1 mrg @item @emph{Return value}:
4622 1.1 mrg The converted date and time as a string.
4623 1.1 mrg
4624 1.1 mrg @item @emph{Example}:
4625 1.1 mrg @smallexample
4626 1.1 mrg program test_ctime
4627 1.1 mrg integer(8) :: i
4628 1.1 mrg character(len=30) :: date
4629 1.1 mrg i = time8()
4630 1.1 mrg
4631 1.1 mrg ! Do something, main part of the program
4632 1.1 mrg
4633 1.1 mrg call ctime(i,date)
4634 1.1 mrg print *, 'Program was started on ', date
4635 1.1 mrg end program test_ctime
4636 1.1 mrg @end smallexample
4637 1.1 mrg
4638 1.1 mrg @item @emph{See Also}:
4639 1.1 mrg @ref{DATE_AND_TIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4640 1.1 mrg @end table
4641 1.1 mrg
4642 1.1 mrg
4643 1.1 mrg
4644 1.1 mrg @node DATE_AND_TIME
4645 1.1 mrg @section @code{DATE_AND_TIME} --- Date and time subroutine
4646 1.1 mrg @fnindex DATE_AND_TIME
4647 1.1 mrg @cindex date, current
4648 1.1 mrg @cindex current date
4649 1.1 mrg @cindex time, current
4650 1.1 mrg @cindex current time
4651 1.1 mrg
4652 1.1 mrg @table @asis
4653 1.1 mrg @item @emph{Description}:
4654 1.1 mrg @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
4655 1.1 mrg time information from the real-time system clock. @var{DATE} is
4656 1.1 mrg @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
4657 1.1 mrg has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
4658 1.1 mrg representing the difference with respect to Coordinated Universal Time (UTC).
4659 1.1 mrg Unavailable time and date parameters return blanks.
4660 1.1 mrg
4661 1.1 mrg @var{VALUES} is @code{INTENT(OUT)} and provides the following:
4662 1.1 mrg
4663 1.1 mrg @multitable @columnfractions .15 .30 .40
4664 1.1 mrg @item @tab @code{VALUE(1)}: @tab The year
4665 1.1 mrg @item @tab @code{VALUE(2)}: @tab The month
4666 1.1 mrg @item @tab @code{VALUE(3)}: @tab The day of the month
4667 1.1 mrg @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
4668 1.1 mrg @item @tab @code{VALUE(5)}: @tab The hour of the day
4669 1.1 mrg @item @tab @code{VALUE(6)}: @tab The minutes of the hour
4670 1.1 mrg @item @tab @code{VALUE(7)}: @tab The seconds of the minute
4671 1.1 mrg @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
4672 1.1 mrg @end multitable
4673 1.1 mrg
4674 1.1 mrg @item @emph{Standard}:
4675 1.1 mrg Fortran 95 and later
4676 1.1 mrg
4677 1.1 mrg @item @emph{Class}:
4678 1.1 mrg Subroutine
4679 1.1 mrg
4680 1.1 mrg @item @emph{Syntax}:
4681 1.1 mrg @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
4682 1.1 mrg
4683 1.1 mrg @item @emph{Arguments}:
4684 1.1 mrg @multitable @columnfractions .15 .70
4685 1.1 mrg @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
4686 1.1 mrg or larger, and of default kind.
4687 1.1 mrg @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
4688 1.1 mrg or larger, and of default kind.
4689 1.1 mrg @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
4690 1.1 mrg or larger, and of default kind.
4691 1.1 mrg @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
4692 1.1 mrg @end multitable
4693 1.1 mrg
4694 1.1 mrg @item @emph{Return value}:
4695 1.1 mrg None
4696 1.1 mrg
4697 1.1 mrg @item @emph{Example}:
4698 1.1 mrg @smallexample
4699 1.1 mrg program test_time_and_date
4700 1.1 mrg character(8) :: date
4701 1.1 mrg character(10) :: time
4702 1.1 mrg character(5) :: zone
4703 1.1 mrg integer,dimension(8) :: values
4704 1.1 mrg ! using keyword arguments
4705 1.1 mrg call date_and_time(date,time,zone,values)
4706 1.1 mrg call date_and_time(DATE=date,ZONE=zone)
4707 1.1 mrg call date_and_time(TIME=time)
4708 1.1 mrg call date_and_time(VALUES=values)
4709 1.1 mrg print '(a,2x,a,2x,a)', date, time, zone
4710 1.1 mrg print '(8i5)', values
4711 1.1 mrg end program test_time_and_date
4712 1.1 mrg @end smallexample
4713 1.1 mrg
4714 1.1 mrg @item @emph{See also}:
4715 1.1 mrg @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
4716 1.1 mrg @end table
4717 1.1 mrg
4718 1.1 mrg
4719 1.1 mrg
4720 1.1 mrg @node DBLE
4721 1.1 mrg @section @code{DBLE} --- Double conversion function
4722 1.1 mrg @fnindex DBLE
4723 1.1 mrg @cindex conversion, to real
4724 1.1 mrg
4725 1.1 mrg @table @asis
4726 1.1 mrg @item @emph{Description}:
4727 1.1 mrg @code{DBLE(A)} Converts @var{A} to double precision real type.
4728 1.1 mrg
4729 1.1 mrg @item @emph{Standard}:
4730 1.1 mrg Fortran 77 and later
4731 1.1 mrg
4732 1.1 mrg @item @emph{Class}:
4733 1.1 mrg Elemental function
4734 1.1 mrg
4735 1.1 mrg @item @emph{Syntax}:
4736 1.1 mrg @code{RESULT = DBLE(A)}
4737 1.1 mrg
4738 1.1 mrg @item @emph{Arguments}:
4739 1.1 mrg @multitable @columnfractions .15 .70
4740 1.1 mrg @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
4741 1.1 mrg or @code{COMPLEX}.
4742 1.1 mrg @end multitable
4743 1.1 mrg
4744 1.1 mrg @item @emph{Return value}:
4745 1.1 mrg The return value is of type double precision real.
4746 1.1 mrg
4747 1.1 mrg @item @emph{Example}:
4748 1.1 mrg @smallexample
4749 1.1 mrg program test_dble
4750 1.1 mrg real :: x = 2.18
4751 1.1 mrg integer :: i = 5
4752 1.1 mrg complex :: z = (2.3,1.14)
4753 1.1 mrg print *, dble(x), dble(i), dble(z)
4754 1.1 mrg end program test_dble
4755 1.1 mrg @end smallexample
4756 1.1 mrg
4757 1.1 mrg @item @emph{See also}:
4758 1.1 mrg @ref{REAL}
4759 1.1 mrg @end table
4760 1.1 mrg
4761 1.1 mrg
4762 1.1 mrg
4763 1.1 mrg @node DCMPLX
4764 1.1 mrg @section @code{DCMPLX} --- Double complex conversion function
4765 1.1 mrg @fnindex DCMPLX
4766 1.1 mrg @cindex complex numbers, conversion to
4767 1.1 mrg @cindex conversion, to complex
4768 1.1 mrg
4769 1.1 mrg @table @asis
4770 1.1 mrg @item @emph{Description}:
4771 1.1 mrg @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
4772 1.1 mrg converted to the real component. If @var{Y} is present it is converted to the
4773 1.1 mrg imaginary component. If @var{Y} is not present then the imaginary component is
4774 1.1 mrg set to 0.0. If @var{X} is complex then @var{Y} must not be present.
4775 1.1 mrg
4776 1.1 mrg @item @emph{Standard}:
4777 1.1 mrg GNU extension
4778 1.1 mrg
4779 1.1 mrg @item @emph{Class}:
4780 1.1 mrg Elemental function
4781 1.1 mrg
4782 1.1 mrg @item @emph{Syntax}:
4783 1.1 mrg @code{RESULT = DCMPLX(X [, Y])}
4784 1.1 mrg
4785 1.1 mrg @item @emph{Arguments}:
4786 1.1 mrg @multitable @columnfractions .15 .70
4787 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
4788 1.1 mrg or @code{COMPLEX}.
4789 1.1 mrg @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
4790 1.1 mrg @code{INTEGER} or @code{REAL}.
4791 1.1 mrg @end multitable
4792 1.1 mrg
4793 1.1 mrg @item @emph{Return value}:
4794 1.1 mrg The return value is of type @code{COMPLEX(8)}
4795 1.1 mrg
4796 1.1 mrg @item @emph{Example}:
4797 1.1 mrg @smallexample
4798 1.1 mrg program test_dcmplx
4799 1.1 mrg integer :: i = 42
4800 1.1 mrg real :: x = 3.14
4801 1.1 mrg complex :: z
4802 1.1 mrg z = cmplx(i, x)
4803 1.1 mrg print *, dcmplx(i)
4804 1.1 mrg print *, dcmplx(x)
4805 1.1 mrg print *, dcmplx(z)
4806 1.1 mrg print *, dcmplx(x,i)
4807 1.1 mrg end program test_dcmplx
4808 1.1 mrg @end smallexample
4809 1.1 mrg @end table
4810 1.1 mrg
4811 1.1 mrg
4812 1.1 mrg @node DIGITS
4813 1.1 mrg @section @code{DIGITS} --- Significant binary digits function
4814 1.1 mrg @fnindex DIGITS
4815 1.1 mrg @cindex model representation, significant digits
4816 1.1 mrg
4817 1.1 mrg @table @asis
4818 1.1 mrg @item @emph{Description}:
4819 1.1 mrg @code{DIGITS(X)} returns the number of significant binary digits of the internal
4820 1.1 mrg model representation of @var{X}. For example, on a system using a 32-bit
4821 1.1 mrg floating point representation, a default real number would likely return 24.
4822 1.1 mrg
4823 1.1 mrg @item @emph{Standard}:
4824 1.1 mrg Fortran 95 and later
4825 1.1 mrg
4826 1.1 mrg @item @emph{Class}:
4827 1.1 mrg Inquiry function
4828 1.1 mrg
4829 1.1 mrg @item @emph{Syntax}:
4830 1.1 mrg @code{RESULT = DIGITS(X)}
4831 1.1 mrg
4832 1.1 mrg @item @emph{Arguments}:
4833 1.1 mrg @multitable @columnfractions .15 .70
4834 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4835 1.1 mrg @end multitable
4836 1.1 mrg
4837 1.1 mrg @item @emph{Return value}:
4838 1.1 mrg The return value is of type @code{INTEGER}.
4839 1.1 mrg
4840 1.1 mrg @item @emph{Example}:
4841 1.1 mrg @smallexample
4842 1.1 mrg program test_digits
4843 1.1 mrg integer :: i = 12345
4844 1.1 mrg real :: x = 3.143
4845 1.1 mrg real(8) :: y = 2.33
4846 1.1 mrg print *, digits(i)
4847 1.1 mrg print *, digits(x)
4848 1.1 mrg print *, digits(y)
4849 1.1 mrg end program test_digits
4850 1.1 mrg @end smallexample
4851 1.1 mrg @end table
4852 1.1 mrg
4853 1.1 mrg
4854 1.1 mrg
4855 1.1 mrg @node DIM
4856 1.1 mrg @section @code{DIM} --- Positive difference
4857 1.1 mrg @fnindex DIM
4858 1.1 mrg @fnindex IDIM
4859 1.1 mrg @fnindex DDIM
4860 1.1 mrg @cindex positive difference
4861 1.1 mrg
4862 1.1 mrg @table @asis
4863 1.1 mrg @item @emph{Description}:
4864 1.1 mrg @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
4865 1.1 mrg otherwise returns zero.
4866 1.1 mrg
4867 1.1 mrg @item @emph{Standard}:
4868 1.1 mrg Fortran 77 and later
4869 1.1 mrg
4870 1.1 mrg @item @emph{Class}:
4871 1.1 mrg Elemental function
4872 1.1 mrg
4873 1.1 mrg @item @emph{Syntax}:
4874 1.1 mrg @code{RESULT = DIM(X, Y)}
4875 1.1 mrg
4876 1.1 mrg @item @emph{Arguments}:
4877 1.1 mrg @multitable @columnfractions .15 .70
4878 1.1 mrg @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
4879 1.1 mrg @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
4880 1.1 mrg @end multitable
4881 1.1 mrg
4882 1.1 mrg @item @emph{Return value}:
4883 1.1 mrg The return value is of type @code{INTEGER} or @code{REAL}.
4884 1.1 mrg
4885 1.1 mrg @item @emph{Example}:
4886 1.1 mrg @smallexample
4887 1.1 mrg program test_dim
4888 1.1 mrg integer :: i
4889 1.1 mrg real(8) :: x
4890 1.1 mrg i = dim(4, 15)
4891 1.1 mrg x = dim(4.345_8, 2.111_8)
4892 1.1 mrg print *, i
4893 1.1 mrg print *, x
4894 1.1 mrg end program test_dim
4895 1.1 mrg @end smallexample
4896 1.1 mrg
4897 1.1 mrg @item @emph{Specific names}:
4898 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
4899 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
4900 1.1 mrg @item @code{DIM(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
4901 1.1 mrg @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
4902 1.1 mrg @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
4903 1.1 mrg @end multitable
4904 1.1 mrg @end table
4905 1.1 mrg
4906 1.1 mrg
4907 1.1 mrg
4908 1.1 mrg @node DOT_PRODUCT
4909 1.1 mrg @section @code{DOT_PRODUCT} --- Dot product function
4910 1.1 mrg @fnindex DOT_PRODUCT
4911 1.1 mrg @cindex dot product
4912 1.1 mrg @cindex vector product
4913 1.1 mrg @cindex product, vector
4914 1.1 mrg
4915 1.1 mrg @table @asis
4916 1.1 mrg @item @emph{Description}:
4917 1.1 mrg @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
4918 1.1 mrg of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be
4919 1.1 mrg either numeric or logical and must be arrays of rank one and of equal size. If
4920 1.1 mrg the vectors are @code{INTEGER} or @code{REAL}, the result is
4921 1.1 mrg @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
4922 1.1 mrg is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
4923 1.1 mrg the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.
4924 1.1 mrg
4925 1.1 mrg @item @emph{Standard}:
4926 1.1 mrg Fortran 95 and later
4927 1.1 mrg
4928 1.1 mrg @item @emph{Class}:
4929 1.1 mrg Transformational function
4930 1.1 mrg
4931 1.1 mrg @item @emph{Syntax}:
4932 1.1 mrg @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
4933 1.1 mrg
4934 1.1 mrg @item @emph{Arguments}:
4935 1.1 mrg @multitable @columnfractions .15 .70
4936 1.1 mrg @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
4937 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.
4938 1.1 mrg @end multitable
4939 1.1 mrg
4940 1.1 mrg @item @emph{Return value}:
4941 1.1 mrg If the arguments are numeric, the return value is a scalar of numeric type,
4942 1.1 mrg @code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are
4943 1.1 mrg @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
4944 1.1 mrg
4945 1.1 mrg @item @emph{Example}:
4946 1.1 mrg @smallexample
4947 1.1 mrg program test_dot_prod
4948 1.1 mrg integer, dimension(3) :: a, b
4949 1.1 mrg a = (/ 1, 2, 3 /)
4950 1.1 mrg b = (/ 4, 5, 6 /)
4951 1.1 mrg print '(3i3)', a
4952 1.1 mrg print *
4953 1.1 mrg print '(3i3)', b
4954 1.1 mrg print *
4955 1.1 mrg print *, dot_product(a,b)
4956 1.1 mrg end program test_dot_prod
4957 1.1 mrg @end smallexample
4958 1.1 mrg @end table
4959 1.1 mrg
4960 1.1 mrg
4961 1.1 mrg
4962 1.1 mrg @node DPROD
4963 1.1 mrg @section @code{DPROD} --- Double product function
4964 1.1 mrg @fnindex DPROD
4965 1.1 mrg @cindex product, double-precision
4966 1.1 mrg
4967 1.1 mrg @table @asis
4968 1.1 mrg @item @emph{Description}:
4969 1.1 mrg @code{DPROD(X,Y)} returns the product @code{X*Y}.
4970 1.1 mrg
4971 1.1 mrg @item @emph{Standard}:
4972 1.1 mrg Fortran 77 and later
4973 1.1 mrg
4974 1.1 mrg @item @emph{Class}:
4975 1.1 mrg Elemental function
4976 1.1 mrg
4977 1.1 mrg @item @emph{Syntax}:
4978 1.1 mrg @code{RESULT = DPROD(X, Y)}
4979 1.1 mrg
4980 1.1 mrg @item @emph{Arguments}:
4981 1.1 mrg @multitable @columnfractions .15 .70
4982 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
4983 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}.
4984 1.1 mrg @end multitable
4985 1.1 mrg
4986 1.1 mrg @item @emph{Return value}:
4987 1.1 mrg The return value is of type @code{REAL(8)}.
4988 1.1 mrg
4989 1.1 mrg @item @emph{Example}:
4990 1.1 mrg @smallexample
4991 1.1 mrg program test_dprod
4992 1.1 mrg real :: x = 5.2
4993 1.1 mrg real :: y = 2.3
4994 1.1 mrg real(8) :: d
4995 1.1 mrg d = dprod(x,y)
4996 1.1 mrg print *, d
4997 1.1 mrg end program test_dprod
4998 1.1 mrg @end smallexample
4999 1.1 mrg
5000 1.1 mrg @item @emph{Specific names}:
5001 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5002 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5003 1.1 mrg @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
5004 1.1 mrg @end multitable
5005 1.1 mrg
5006 1.1 mrg @end table
5007 1.1 mrg
5008 1.1 mrg
5009 1.1 mrg @node DREAL
5010 1.1 mrg @section @code{DREAL} --- Double real part function
5011 1.1 mrg @fnindex DREAL
5012 1.1 mrg @cindex complex numbers, real part
5013 1.1 mrg
5014 1.1 mrg @table @asis
5015 1.1 mrg @item @emph{Description}:
5016 1.1 mrg @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
5017 1.1 mrg
5018 1.1 mrg @item @emph{Standard}:
5019 1.1 mrg GNU extension
5020 1.1 mrg
5021 1.1 mrg @item @emph{Class}:
5022 1.1 mrg Elemental function
5023 1.1 mrg
5024 1.1 mrg @item @emph{Syntax}:
5025 1.1 mrg @code{RESULT = DREAL(A)}
5026 1.1 mrg
5027 1.1 mrg @item @emph{Arguments}:
5028 1.1 mrg @multitable @columnfractions .15 .70
5029 1.1 mrg @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
5030 1.1 mrg @end multitable
5031 1.1 mrg
5032 1.1 mrg @item @emph{Return value}:
5033 1.1 mrg The return value is of type @code{REAL(8)}.
5034 1.1 mrg
5035 1.1 mrg @item @emph{Example}:
5036 1.1 mrg @smallexample
5037 1.1 mrg program test_dreal
5038 1.1 mrg complex(8) :: z = (1.3_8,7.2_8)
5039 1.1 mrg print *, dreal(z)
5040 1.1 mrg end program test_dreal
5041 1.1 mrg @end smallexample
5042 1.1 mrg
5043 1.1 mrg @item @emph{See also}:
5044 1.1 mrg @ref{AIMAG}
5045 1.1 mrg
5046 1.1 mrg @end table
5047 1.1 mrg
5048 1.1 mrg
5049 1.1 mrg
5050 1.1 mrg @node DSHIFTL
5051 1.1 mrg @section @code{DSHIFTL} --- Combined left shift
5052 1.1 mrg @fnindex DSHIFTL
5053 1.1 mrg @cindex left shift, combined
5054 1.1 mrg @cindex shift, left
5055 1.1 mrg
5056 1.1 mrg @table @asis
5057 1.1 mrg @item @emph{Description}:
5058 1.1 mrg @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5059 1.1 mrg rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
5060 1.1 mrg bits of @var{J}, and the remaining bits are the rightmost bits of
5061 1.1 mrg @var{I}.
5062 1.1 mrg
5063 1.1 mrg @item @emph{Standard}:
5064 1.1 mrg Fortran 2008 and later
5065 1.1 mrg
5066 1.1 mrg @item @emph{Class}:
5067 1.1 mrg Elemental function
5068 1.1 mrg
5069 1.1 mrg @item @emph{Syntax}:
5070 1.1 mrg @code{RESULT = DSHIFTL(I, J, SHIFT)}
5071 1.1 mrg
5072 1.1 mrg @item @emph{Arguments}:
5073 1.1 mrg @multitable @columnfractions .15 .70
5074 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5075 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5076 1.1 mrg If both @var{I} and @var{J} have integer type, then they shall have
5077 1.1 mrg the same kind type parameter. @var{I} and @var{J} shall not both be
5078 1.1 mrg BOZ constants.
5079 1.1 mrg @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5080 1.1 mrg be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5081 1.1 mrg shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5082 1.1 mrg @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5083 1.1 mrg @end multitable
5084 1.1 mrg
5085 1.1 mrg @item @emph{Return value}:
5086 1.1 mrg If either @var{I} or @var{J} is a BOZ constant, it is first converted
5087 1.1 mrg as if by the intrinsic function @code{INT} to an integer type with the
5088 1.1 mrg kind type parameter of the other.
5089 1.1 mrg
5090 1.1 mrg @item @emph{See also}:
5091 1.1 mrg @ref{DSHIFTR}
5092 1.1 mrg @end table
5093 1.1 mrg
5094 1.1 mrg
5095 1.1 mrg @node DSHIFTR
5096 1.1 mrg @section @code{DSHIFTR} --- Combined right shift
5097 1.1 mrg @fnindex DSHIFTR
5098 1.1 mrg @cindex right shift, combined
5099 1.1 mrg @cindex shift, right
5100 1.1 mrg
5101 1.1 mrg @table @asis
5102 1.1 mrg @item @emph{Description}:
5103 1.1 mrg @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5104 1.1 mrg leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
5105 1.1 mrg bits of @var{I}, and the remaining bits are the leftmost bits of
5106 1.1 mrg @var{J}.
5107 1.1 mrg
5108 1.1 mrg @item @emph{Standard}:
5109 1.1 mrg Fortran 2008 and later
5110 1.1 mrg
5111 1.1 mrg @item @emph{Class}:
5112 1.1 mrg Elemental function
5113 1.1 mrg
5114 1.1 mrg @item @emph{Syntax}:
5115 1.1 mrg @code{RESULT = DSHIFTR(I, J, SHIFT)}
5116 1.1 mrg
5117 1.1 mrg @item @emph{Arguments}:
5118 1.1 mrg @multitable @columnfractions .15 .70
5119 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5120 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5121 1.1 mrg If both @var{I} and @var{J} have integer type, then they shall have
5122 1.1 mrg the same kind type parameter. @var{I} and @var{J} shall not both be
5123 1.1 mrg BOZ constants.
5124 1.1 mrg @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5125 1.1 mrg be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5126 1.1 mrg shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5127 1.1 mrg @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5128 1.1 mrg @end multitable
5129 1.1 mrg
5130 1.1 mrg @item @emph{Return value}:
5131 1.1 mrg If either @var{I} or @var{J} is a BOZ constant, it is first converted
5132 1.1 mrg as if by the intrinsic function @code{INT} to an integer type with the
5133 1.1 mrg kind type parameter of the other.
5134 1.1 mrg
5135 1.1 mrg @item @emph{See also}:
5136 1.1 mrg @ref{DSHIFTL}
5137 1.1 mrg @end table
5138 1.1 mrg
5139 1.1 mrg
5140 1.1 mrg @node DTIME
5141 1.1 mrg @section @code{DTIME} --- Execution time subroutine (or function)
5142 1.1 mrg @fnindex DTIME
5143 1.1 mrg @cindex time, elapsed
5144 1.1 mrg @cindex elapsed time
5145 1.1 mrg
5146 1.1 mrg @table @asis
5147 1.1 mrg @item @emph{Description}:
5148 1.1 mrg @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
5149 1.1 mrg since the start of the process's execution in @var{TIME}. @var{VALUES}
5150 1.1 mrg returns the user and system components of this time in @code{VALUES(1)} and
5151 1.1 mrg @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
5152 1.1 mrg VALUES(2)}.
5153 1.1 mrg
5154 1.1 mrg Subsequent invocations of @code{DTIME} return values accumulated since the
5155 1.1 mrg previous invocation.
5156 1.1 mrg
5157 1.1 mrg On some systems, the underlying timings are represented using types with
5158 1.1 mrg sufficiently small limits that overflows (wrap around) are possible, such as
5159 1.1 mrg 32-bit types. Therefore, the values returned by this intrinsic might be, or
5160 1.1 mrg become, negative, or numerically less than previous values, during a single
5161 1.1 mrg run of the compiled program.
5162 1.1 mrg
5163 1.1 mrg Please note, that this implementation is thread safe if used within OpenMP
5164 1.1 mrg directives, i.e., its state will be consistent while called from multiple
5165 1.1 mrg threads. However, if @code{DTIME} is called from multiple threads, the result
5166 1.1 mrg is still the time since the last invocation. This may not give the intended
5167 1.1 mrg results. If possible, use @code{CPU_TIME} instead.
5168 1.1 mrg
5169 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
5170 1.1 mrg only one form can be used in any given program unit.
5171 1.1 mrg
5172 1.1 mrg @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5173 1.1 mrg
5174 1.1 mrg @multitable @columnfractions .15 .30 .40
5175 1.1 mrg @item @tab @code{VALUES(1)}: @tab User time in seconds.
5176 1.1 mrg @item @tab @code{VALUES(2)}: @tab System time in seconds.
5177 1.1 mrg @item @tab @code{TIME}: @tab Run time since start in seconds.
5178 1.1 mrg @end multitable
5179 1.1 mrg
5180 1.1 mrg @item @emph{Standard}:
5181 1.1 mrg GNU extension
5182 1.1 mrg
5183 1.1 mrg @item @emph{Class}:
5184 1.1 mrg Subroutine, function
5185 1.1 mrg
5186 1.1 mrg @item @emph{Syntax}:
5187 1.1 mrg @multitable @columnfractions .80
5188 1.1 mrg @item @code{CALL DTIME(VALUES, TIME)}.
5189 1.1 mrg @item @code{TIME = DTIME(VALUES)}, (not recommended).
5190 1.1 mrg @end multitable
5191 1.1 mrg
5192 1.1 mrg @item @emph{Arguments}:
5193 1.1 mrg @multitable @columnfractions .15 .70
5194 1.1 mrg @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5195 1.1 mrg @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5196 1.1 mrg @end multitable
5197 1.1 mrg
5198 1.1 mrg @item @emph{Return value}:
5199 1.1 mrg Elapsed time in seconds since the last invocation or since the start of program
5200 1.1 mrg execution if not called before.
5201 1.1 mrg
5202 1.1 mrg @item @emph{Example}:
5203 1.1 mrg @smallexample
5204 1.1 mrg program test_dtime
5205 1.1 mrg integer(8) :: i, j
5206 1.1 mrg real, dimension(2) :: tarray
5207 1.1 mrg real :: result
5208 1.1 mrg call dtime(tarray, result)
5209 1.1 mrg print *, result
5210 1.1 mrg print *, tarray(1)
5211 1.1 mrg print *, tarray(2)
5212 1.1 mrg do i=1,100000000 ! Just a delay
5213 1.1 mrg j = i * i - i
5214 1.1 mrg end do
5215 1.1 mrg call dtime(tarray, result)
5216 1.1 mrg print *, result
5217 1.1 mrg print *, tarray(1)
5218 1.1 mrg print *, tarray(2)
5219 1.1 mrg end program test_dtime
5220 1.1 mrg @end smallexample
5221 1.1 mrg
5222 1.1 mrg @item @emph{See also}:
5223 1.1 mrg @ref{CPU_TIME}
5224 1.1 mrg
5225 1.1 mrg @end table
5226 1.1 mrg
5227 1.1 mrg
5228 1.1 mrg
5229 1.1 mrg @node EOSHIFT
5230 1.1 mrg @section @code{EOSHIFT} --- End-off shift elements of an array
5231 1.1 mrg @fnindex EOSHIFT
5232 1.1 mrg @cindex array, shift
5233 1.1 mrg
5234 1.1 mrg @table @asis
5235 1.1 mrg @item @emph{Description}:
5236 1.1 mrg @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
5237 1.1 mrg elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
5238 1.1 mrg omitted it is taken to be @code{1}. @var{DIM} is a scalar of type
5239 1.1 mrg @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
5240 1.1 mrg rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
5241 1.1 mrg @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
5242 1.1 mrg then all complete rank one sections of @var{ARRAY} along the given dimension are
5243 1.1 mrg shifted. Elements shifted out one end of each rank one section are dropped. If
5244 1.1 mrg @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
5245 1.1 mrg is copied back in the other end. If @var{BOUNDARY} is not present then the
5246 1.1 mrg following are copied in depending on the type of @var{ARRAY}.
5247 1.1 mrg
5248 1.1 mrg @multitable @columnfractions .15 .80
5249 1.1 mrg @item @emph{Array Type} @tab @emph{Boundary Value}
5250 1.1 mrg @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
5251 1.1 mrg @item Logical @tab @code{.FALSE.}.
5252 1.1 mrg @item Character(@var{len}) @tab @var{len} blanks.
5253 1.1 mrg @end multitable
5254 1.1 mrg
5255 1.1 mrg @item @emph{Standard}:
5256 1.1 mrg Fortran 95 and later
5257 1.1 mrg
5258 1.1 mrg @item @emph{Class}:
5259 1.1 mrg Transformational function
5260 1.1 mrg
5261 1.1 mrg @item @emph{Syntax}:
5262 1.1 mrg @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
5263 1.1 mrg
5264 1.1 mrg @item @emph{Arguments}:
5265 1.1 mrg @multitable @columnfractions .15 .70
5266 1.1 mrg @item @var{ARRAY} @tab May be any type, not scalar.
5267 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
5268 1.1 mrg @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
5269 1.1 mrg @item @var{DIM} @tab The type shall be @code{INTEGER}.
5270 1.1 mrg @end multitable
5271 1.1 mrg
5272 1.1 mrg @item @emph{Return value}:
5273 1.1 mrg Returns an array of same type and rank as the @var{ARRAY} argument.
5274 1.1 mrg
5275 1.1 mrg @item @emph{Example}:
5276 1.1 mrg @smallexample
5277 1.1 mrg program test_eoshift
5278 1.1 mrg integer, dimension(3,3) :: a
5279 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
5280 1.1 mrg print '(3i3)', a(1,:)
5281 1.1 mrg print '(3i3)', a(2,:)
5282 1.1 mrg print '(3i3)', a(3,:)
5283 1.1 mrg a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
5284 1.1 mrg print *
5285 1.1 mrg print '(3i3)', a(1,:)
5286 1.1 mrg print '(3i3)', a(2,:)
5287 1.1 mrg print '(3i3)', a(3,:)
5288 1.1 mrg end program test_eoshift
5289 1.1 mrg @end smallexample
5290 1.1 mrg @end table
5291 1.1 mrg
5292 1.1 mrg
5293 1.1 mrg
5294 1.1 mrg @node EPSILON
5295 1.1 mrg @section @code{EPSILON} --- Epsilon function
5296 1.1 mrg @fnindex EPSILON
5297 1.1 mrg @cindex model representation, epsilon
5298 1.1 mrg
5299 1.1 mrg @table @asis
5300 1.1 mrg @item @emph{Description}:
5301 1.1 mrg @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
5302 1.1 mrg as @var{X} such that @math{1 + E > 1}.
5303 1.1 mrg
5304 1.1 mrg @item @emph{Standard}:
5305 1.1 mrg Fortran 95 and later
5306 1.1 mrg
5307 1.1 mrg @item @emph{Class}:
5308 1.1 mrg Inquiry function
5309 1.1 mrg
5310 1.1 mrg @item @emph{Syntax}:
5311 1.1 mrg @code{RESULT = EPSILON(X)}
5312 1.1 mrg
5313 1.1 mrg @item @emph{Arguments}:
5314 1.1 mrg @multitable @columnfractions .15 .70
5315 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5316 1.1 mrg @end multitable
5317 1.1 mrg
5318 1.1 mrg @item @emph{Return value}:
5319 1.1 mrg The return value is of same type as the argument.
5320 1.1 mrg
5321 1.1 mrg @item @emph{Example}:
5322 1.1 mrg @smallexample
5323 1.1 mrg program test_epsilon
5324 1.1 mrg real :: x = 3.143
5325 1.1 mrg real(8) :: y = 2.33
5326 1.1 mrg print *, EPSILON(x)
5327 1.1 mrg print *, EPSILON(y)
5328 1.1 mrg end program test_epsilon
5329 1.1 mrg @end smallexample
5330 1.1 mrg @end table
5331 1.1 mrg
5332 1.1 mrg
5333 1.1 mrg
5334 1.1 mrg @node ERF
5335 1.1 mrg @section @code{ERF} --- Error function
5336 1.1 mrg @fnindex ERF
5337 1.1 mrg @cindex error function
5338 1.1 mrg
5339 1.1 mrg @table @asis
5340 1.1 mrg @item @emph{Description}:
5341 1.1 mrg @code{ERF(X)} computes the error function of @var{X}.
5342 1.1 mrg
5343 1.1 mrg @item @emph{Standard}:
5344 1.1 mrg Fortran 2008 and later
5345 1.1 mrg
5346 1.1 mrg @item @emph{Class}:
5347 1.1 mrg Elemental function
5348 1.1 mrg
5349 1.1 mrg @item @emph{Syntax}:
5350 1.1 mrg @code{RESULT = ERF(X)}
5351 1.1 mrg
5352 1.1 mrg @item @emph{Arguments}:
5353 1.1 mrg @multitable @columnfractions .15 .70
5354 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5355 1.1 mrg @end multitable
5356 1.1 mrg
5357 1.1 mrg @item @emph{Return value}:
5358 1.1 mrg The return value is of type @code{REAL}, of the same kind as
5359 1.1 mrg @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
5360 1.1 mrg
5361 1.1 mrg @item @emph{Example}:
5362 1.1 mrg @smallexample
5363 1.1 mrg program test_erf
5364 1.1 mrg real(8) :: x = 0.17_8
5365 1.1 mrg x = erf(x)
5366 1.1 mrg end program test_erf
5367 1.1 mrg @end smallexample
5368 1.1 mrg
5369 1.1 mrg @item @emph{Specific names}:
5370 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5371 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5372 1.1 mrg @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5373 1.1 mrg @end multitable
5374 1.1 mrg @end table
5375 1.1 mrg
5376 1.1 mrg
5377 1.1 mrg
5378 1.1 mrg @node ERFC
5379 1.1 mrg @section @code{ERFC} --- Error function
5380 1.1 mrg @fnindex ERFC
5381 1.1 mrg @cindex error function, complementary
5382 1.1 mrg
5383 1.1 mrg @table @asis
5384 1.1 mrg @item @emph{Description}:
5385 1.1 mrg @code{ERFC(X)} computes the complementary error function of @var{X}.
5386 1.1 mrg
5387 1.1 mrg @item @emph{Standard}:
5388 1.1 mrg Fortran 2008 and later
5389 1.1 mrg
5390 1.1 mrg @item @emph{Class}:
5391 1.1 mrg Elemental function
5392 1.1 mrg
5393 1.1 mrg @item @emph{Syntax}:
5394 1.1 mrg @code{RESULT = ERFC(X)}
5395 1.1 mrg
5396 1.1 mrg @item @emph{Arguments}:
5397 1.1 mrg @multitable @columnfractions .15 .70
5398 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5399 1.1 mrg @end multitable
5400 1.1 mrg
5401 1.1 mrg @item @emph{Return value}:
5402 1.1 mrg The return value is of type @code{REAL} and of the same kind as @var{X}.
5403 1.1 mrg It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
5404 1.1 mrg
5405 1.1 mrg @item @emph{Example}:
5406 1.1 mrg @smallexample
5407 1.1 mrg program test_erfc
5408 1.1 mrg real(8) :: x = 0.17_8
5409 1.1 mrg x = erfc(x)
5410 1.1 mrg end program test_erfc
5411 1.1 mrg @end smallexample
5412 1.1 mrg
5413 1.1 mrg @item @emph{Specific names}:
5414 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5415 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5416 1.1 mrg @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5417 1.1 mrg @end multitable
5418 1.1 mrg @end table
5419 1.1 mrg
5420 1.1 mrg
5421 1.1 mrg
5422 1.1 mrg @node ERFC_SCALED
5423 1.1 mrg @section @code{ERFC_SCALED} --- Error function
5424 1.1 mrg @fnindex ERFC_SCALED
5425 1.1 mrg @cindex error function, complementary, exponentially-scaled
5426 1.1 mrg
5427 1.1 mrg @table @asis
5428 1.1 mrg @item @emph{Description}:
5429 1.1 mrg @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
5430 1.1 mrg error function of @var{X}.
5431 1.1 mrg
5432 1.1 mrg @item @emph{Standard}:
5433 1.1 mrg Fortran 2008 and later
5434 1.1 mrg
5435 1.1 mrg @item @emph{Class}:
5436 1.1 mrg Elemental function
5437 1.1 mrg
5438 1.1 mrg @item @emph{Syntax}:
5439 1.1 mrg @code{RESULT = ERFC_SCALED(X)}
5440 1.1 mrg
5441 1.1 mrg @item @emph{Arguments}:
5442 1.1 mrg @multitable @columnfractions .15 .70
5443 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5444 1.1 mrg @end multitable
5445 1.1 mrg
5446 1.1 mrg @item @emph{Return value}:
5447 1.1 mrg The return value is of type @code{REAL} and of the same kind as @var{X}.
5448 1.1 mrg
5449 1.1 mrg @item @emph{Example}:
5450 1.1 mrg @smallexample
5451 1.1 mrg program test_erfc_scaled
5452 1.1 mrg real(8) :: x = 0.17_8
5453 1.1 mrg x = erfc_scaled(x)
5454 1.1 mrg end program test_erfc_scaled
5455 1.1 mrg @end smallexample
5456 1.1 mrg @end table
5457 1.1 mrg
5458 1.1 mrg
5459 1.1 mrg
5460 1.1 mrg @node ETIME
5461 1.1 mrg @section @code{ETIME} --- Execution time subroutine (or function)
5462 1.1 mrg @fnindex ETIME
5463 1.1 mrg @cindex time, elapsed
5464 1.1 mrg
5465 1.1 mrg @table @asis
5466 1.1 mrg @item @emph{Description}:
5467 1.1 mrg @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
5468 1.1 mrg since the start of the process's execution in @var{TIME}. @var{VALUES}
5469 1.1 mrg returns the user and system components of this time in @code{VALUES(1)} and
5470 1.1 mrg @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
5471 1.1 mrg
5472 1.1 mrg On some systems, the underlying timings are represented using types with
5473 1.1 mrg sufficiently small limits that overflows (wrap around) are possible, such as
5474 1.1 mrg 32-bit types. Therefore, the values returned by this intrinsic might be, or
5475 1.1 mrg become, negative, or numerically less than previous values, during a single
5476 1.1 mrg run of the compiled program.
5477 1.1 mrg
5478 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
5479 1.1 mrg only one form can be used in any given program unit.
5480 1.1 mrg
5481 1.1 mrg @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5482 1.1 mrg
5483 1.1 mrg @multitable @columnfractions .15 .30 .60
5484 1.1 mrg @item @tab @code{VALUES(1)}: @tab User time in seconds.
5485 1.1 mrg @item @tab @code{VALUES(2)}: @tab System time in seconds.
5486 1.1 mrg @item @tab @code{TIME}: @tab Run time since start in seconds.
5487 1.1 mrg @end multitable
5488 1.1 mrg
5489 1.1 mrg @item @emph{Standard}:
5490 1.1 mrg GNU extension
5491 1.1 mrg
5492 1.1 mrg @item @emph{Class}:
5493 1.1 mrg Subroutine, function
5494 1.1 mrg
5495 1.1 mrg @item @emph{Syntax}:
5496 1.1 mrg @multitable @columnfractions .80
5497 1.1 mrg @item @code{CALL ETIME(VALUES, TIME)}.
5498 1.1 mrg @item @code{TIME = ETIME(VALUES)}, (not recommended).
5499 1.1 mrg @end multitable
5500 1.1 mrg
5501 1.1 mrg @item @emph{Arguments}:
5502 1.1 mrg @multitable @columnfractions .15 .70
5503 1.1 mrg @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5504 1.1 mrg @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5505 1.1 mrg @end multitable
5506 1.1 mrg
5507 1.1 mrg @item @emph{Return value}:
5508 1.1 mrg Elapsed time in seconds since the start of program execution.
5509 1.1 mrg
5510 1.1 mrg @item @emph{Example}:
5511 1.1 mrg @smallexample
5512 1.1 mrg program test_etime
5513 1.1 mrg integer(8) :: i, j
5514 1.1 mrg real, dimension(2) :: tarray
5515 1.1 mrg real :: result
5516 1.1 mrg call ETIME(tarray, result)
5517 1.1 mrg print *, result
5518 1.1 mrg print *, tarray(1)
5519 1.1 mrg print *, tarray(2)
5520 1.1 mrg do i=1,100000000 ! Just a delay
5521 1.1 mrg j = i * i - i
5522 1.1 mrg end do
5523 1.1 mrg call ETIME(tarray, result)
5524 1.1 mrg print *, result
5525 1.1 mrg print *, tarray(1)
5526 1.1 mrg print *, tarray(2)
5527 1.1 mrg end program test_etime
5528 1.1 mrg @end smallexample
5529 1.1 mrg
5530 1.1 mrg @item @emph{See also}:
5531 1.1 mrg @ref{CPU_TIME}
5532 1.1 mrg
5533 1.1 mrg @end table
5534 1.1 mrg
5535 1.1 mrg
5536 1.1 mrg
5537 1.1 mrg @node EVENT_QUERY
5538 1.1 mrg @section @code{EVENT_QUERY} --- Query whether a coarray event has occurred
5539 1.1 mrg @fnindex EVENT_QUERY
5540 1.1 mrg @cindex Events, EVENT_QUERY
5541 1.1 mrg
5542 1.1 mrg @table @asis
5543 1.1 mrg @item @emph{Description}:
5544 1.1 mrg @code{EVENT_QUERY} assignes the number of events to @var{COUNT} which have been
5545 1.1 mrg posted to the @var{EVENT} variable and not yet been removed by calling
5546 1.1 mrg @code{EVENT WAIT}. When @var{STAT} is present and the invocation was successful,
5547 1.1 mrg it is assigned the value 0. If it is present and the invocation has failed,
5548 1.1 mrg it is assigned a positive value and @var{COUNT} is assigned the value @math{-1}.
5549 1.1 mrg
5550 1.1 mrg @item @emph{Standard}:
5551 1.1 mrg TS 18508 or later
5552 1.1 mrg
5553 1.1 mrg @item @emph{Class}:
5554 1.1 mrg subroutine
5555 1.1 mrg
5556 1.1 mrg @item @emph{Syntax}:
5557 1.1 mrg @code{CALL EVENT_QUERY (EVENT, COUNT [, STAT])}
5558 1.1 mrg
5559 1.1 mrg @item @emph{Arguments}:
5560 1.1 mrg @multitable @columnfractions .15 .70
5561 1.1 mrg @item @var{EVENT} @tab (intent(IN)) Scalar of type @code{EVENT_TYPE},
5562 1.1 mrg defined in @code{ISO_FORTRAN_ENV}; shall not be coindexed.
5563 1.1 mrg @item @var{COUNT} @tab (intent(out))Scalar integer with at least the
5564 1.1 mrg precision of default integer.
5565 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
5566 1.1 mrg @end multitable
5567 1.1 mrg
5568 1.1 mrg @item @emph{Example}:
5569 1.1 mrg @smallexample
5570 1.1 mrg program atomic
5571 1.1 mrg use iso_fortran_env
5572 1.1 mrg implicit none
5573 1.1 mrg type(event_type) :: event_value_has_been_set[*]
5574 1.1 mrg integer :: cnt
5575 1.1 mrg if (this_image() == 1) then
5576 1.1 mrg call event_query (event_value_has_been_set, cnt)
5577 1.1 mrg if (cnt > 0) write(*,*) "Value has been set"
5578 1.1 mrg elseif (this_image() == 2) then
5579 1.1 mrg event post (event_value_has_been_set[1])
5580 1.1 mrg end if
5581 1.1 mrg end program atomic
5582 1.1 mrg @end smallexample
5583 1.1 mrg
5584 1.1 mrg @end table
5585 1.1 mrg
5586 1.1 mrg
5587 1.1 mrg
5588 1.1 mrg @node EXECUTE_COMMAND_LINE
5589 1.1 mrg @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
5590 1.1 mrg @fnindex EXECUTE_COMMAND_LINE
5591 1.1 mrg @cindex system, system call
5592 1.1 mrg @cindex command line
5593 1.1 mrg
5594 1.1 mrg @table @asis
5595 1.1 mrg @item @emph{Description}:
5596 1.1 mrg @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
5597 1.1 mrg asynchronously.
5598 1.1 mrg
5599 1.1 mrg The @code{COMMAND} argument is passed to the shell and executed (The
5600 1.1 mrg shell is @code{sh} on Unix systems, and @code{cmd.exe} on Windows.).
5601 1.1 mrg If @code{WAIT} is present and has the value false, the execution of
5602 1.1 mrg the command is asynchronous if the system supports it; otherwise, the
5603 1.1 mrg command is executed synchronously using the C library's @code{system}
5604 1.1 mrg call.
5605 1.1 mrg
5606 1.1 mrg The three last arguments allow the user to get status information. After
5607 1.1 mrg synchronous execution, @code{EXITSTAT} contains the integer exit code of
5608 1.1 mrg the command, as returned by @code{system}. @code{CMDSTAT} is set to zero
5609 1.1 mrg if the command line was executed (whatever its exit status was).
5610 1.1 mrg @code{CMDMSG} is assigned an error message if an error has occurred.
5611 1.1 mrg
5612 1.1 mrg Note that the @code{system} function need not be thread-safe. It is
5613 1.1 mrg the responsibility of the user to ensure that @code{system} is not
5614 1.1 mrg called concurrently.
5615 1.1 mrg
5616 1.1 mrg For asynchronous execution on supported targets, the POSIX
5617 1.1 mrg @code{posix_spawn} or @code{fork} functions are used. Also, a signal
5618 1.1 mrg handler for the @code{SIGCHLD} signal is installed.
5619 1.1 mrg
5620 1.1 mrg @item @emph{Standard}:
5621 1.1 mrg Fortran 2008 and later
5622 1.1 mrg
5623 1.1 mrg @item @emph{Class}:
5624 1.1 mrg Subroutine
5625 1.1 mrg
5626 1.1 mrg @item @emph{Syntax}:
5627 1.1 mrg @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
5628 1.1 mrg
5629 1.1 mrg @item @emph{Arguments}:
5630 1.1 mrg @multitable @columnfractions .15 .70
5631 1.1 mrg @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
5632 1.1 mrg @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
5633 1.1 mrg @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5634 1.1 mrg default kind.
5635 1.1 mrg @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5636 1.1 mrg default kind.
5637 1.1 mrg @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
5638 1.1 mrg default kind.
5639 1.1 mrg @end multitable
5640 1.1 mrg
5641 1.1 mrg @item @emph{Example}:
5642 1.1 mrg @smallexample
5643 1.1 mrg program test_exec
5644 1.1 mrg integer :: i
5645 1.1 mrg
5646 1.1 mrg call execute_command_line ("external_prog.exe", exitstat=i)
5647 1.1 mrg print *, "Exit status of external_prog.exe was ", i
5648 1.1 mrg
5649 1.1 mrg call execute_command_line ("reindex_files.exe", wait=.false.)
5650 1.1 mrg print *, "Now reindexing files in the background"
5651 1.1 mrg
5652 1.1 mrg end program test_exec
5653 1.1 mrg @end smallexample
5654 1.1 mrg
5655 1.1 mrg
5656 1.1 mrg @item @emph{Note}:
5657 1.1 mrg
5658 1.1 mrg Because this intrinsic is implemented in terms of the @code{system}
5659 1.1 mrg function call, its behavior with respect to signaling is processor
5660 1.1 mrg dependent. In particular, on POSIX-compliant systems, the SIGINT and
5661 1.1 mrg SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
5662 1.1 mrg such, if the parent process is terminated, the child process might not be
5663 1.1 mrg terminated alongside.
5664 1.1 mrg
5665 1.1 mrg
5666 1.1 mrg @item @emph{See also}:
5667 1.1 mrg @ref{SYSTEM}
5668 1.1 mrg @end table
5669 1.1 mrg
5670 1.1 mrg
5671 1.1 mrg
5672 1.1 mrg @node EXIT
5673 1.1 mrg @section @code{EXIT} --- Exit the program with status.
5674 1.1 mrg @fnindex EXIT
5675 1.1 mrg @cindex program termination
5676 1.1 mrg @cindex terminate program
5677 1.1 mrg
5678 1.1 mrg @table @asis
5679 1.1 mrg @item @emph{Description}:
5680 1.1 mrg @code{EXIT} causes immediate termination of the program with status. If status
5681 1.1 mrg is omitted it returns the canonical @emph{success} for the system. All Fortran
5682 1.1 mrg I/O units are closed.
5683 1.1 mrg
5684 1.1 mrg @item @emph{Standard}:
5685 1.1 mrg GNU extension
5686 1.1 mrg
5687 1.1 mrg @item @emph{Class}:
5688 1.1 mrg Subroutine
5689 1.1 mrg
5690 1.1 mrg @item @emph{Syntax}:
5691 1.1 mrg @code{CALL EXIT([STATUS])}
5692 1.1 mrg
5693 1.1 mrg @item @emph{Arguments}:
5694 1.1 mrg @multitable @columnfractions .15 .70
5695 1.1 mrg @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
5696 1.1 mrg @end multitable
5697 1.1 mrg
5698 1.1 mrg @item @emph{Return value}:
5699 1.1 mrg @code{STATUS} is passed to the parent process on exit.
5700 1.1 mrg
5701 1.1 mrg @item @emph{Example}:
5702 1.1 mrg @smallexample
5703 1.1 mrg program test_exit
5704 1.1 mrg integer :: STATUS = 0
5705 1.1 mrg print *, 'This program is going to exit.'
5706 1.1 mrg call EXIT(STATUS)
5707 1.1 mrg end program test_exit
5708 1.1 mrg @end smallexample
5709 1.1 mrg
5710 1.1 mrg @item @emph{See also}:
5711 1.1 mrg @ref{ABORT}, @ref{KILL}
5712 1.1 mrg @end table
5713 1.1 mrg
5714 1.1 mrg
5715 1.1 mrg
5716 1.1 mrg @node EXP
5717 1.1 mrg @section @code{EXP} --- Exponential function
5718 1.1 mrg @fnindex EXP
5719 1.1 mrg @fnindex DEXP
5720 1.1 mrg @fnindex CEXP
5721 1.1 mrg @fnindex ZEXP
5722 1.1 mrg @fnindex CDEXP
5723 1.1 mrg @cindex exponential function
5724 1.1 mrg @cindex logarithm function, inverse
5725 1.1 mrg
5726 1.1 mrg @table @asis
5727 1.1 mrg @item @emph{Description}:
5728 1.1 mrg @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
5729 1.1 mrg
5730 1.1 mrg @item @emph{Standard}:
5731 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
5732 1.1 mrg
5733 1.1 mrg @item @emph{Class}:
5734 1.1 mrg Elemental function
5735 1.1 mrg
5736 1.1 mrg @item @emph{Syntax}:
5737 1.1 mrg @code{RESULT = EXP(X)}
5738 1.1 mrg
5739 1.1 mrg @item @emph{Arguments}:
5740 1.1 mrg @multitable @columnfractions .15 .70
5741 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
5742 1.1 mrg @code{COMPLEX}.
5743 1.1 mrg @end multitable
5744 1.1 mrg
5745 1.1 mrg @item @emph{Return value}:
5746 1.1 mrg The return value has same type and kind as @var{X}.
5747 1.1 mrg
5748 1.1 mrg @item @emph{Example}:
5749 1.1 mrg @smallexample
5750 1.1 mrg program test_exp
5751 1.1 mrg real :: x = 1.0
5752 1.1 mrg x = exp(x)
5753 1.1 mrg end program test_exp
5754 1.1 mrg @end smallexample
5755 1.1 mrg
5756 1.1 mrg @item @emph{Specific names}:
5757 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
5758 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
5759 1.1 mrg @item @code{EXP(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
5760 1.1 mrg @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
5761 1.1 mrg @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
5762 1.1 mrg @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5763 1.1 mrg @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5764 1.1 mrg @end multitable
5765 1.1 mrg @end table
5766 1.1 mrg
5767 1.1 mrg
5768 1.1 mrg
5769 1.1 mrg @node EXPONENT
5770 1.1 mrg @section @code{EXPONENT} --- Exponent function
5771 1.1 mrg @fnindex EXPONENT
5772 1.1 mrg @cindex real number, exponent
5773 1.1 mrg @cindex floating point, exponent
5774 1.1 mrg
5775 1.1 mrg @table @asis
5776 1.1 mrg @item @emph{Description}:
5777 1.1 mrg @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
5778 1.1 mrg is zero the value returned is zero.
5779 1.1 mrg
5780 1.1 mrg @item @emph{Standard}:
5781 1.1 mrg Fortran 95 and later
5782 1.1 mrg
5783 1.1 mrg @item @emph{Class}:
5784 1.1 mrg Elemental function
5785 1.1 mrg
5786 1.1 mrg @item @emph{Syntax}:
5787 1.1 mrg @code{RESULT = EXPONENT(X)}
5788 1.1 mrg
5789 1.1 mrg @item @emph{Arguments}:
5790 1.1 mrg @multitable @columnfractions .15 .70
5791 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
5792 1.1 mrg @end multitable
5793 1.1 mrg
5794 1.1 mrg @item @emph{Return value}:
5795 1.1 mrg The return value is of type default @code{INTEGER}.
5796 1.1 mrg
5797 1.1 mrg @item @emph{Example}:
5798 1.1 mrg @smallexample
5799 1.1 mrg program test_exponent
5800 1.1 mrg real :: x = 1.0
5801 1.1 mrg integer :: i
5802 1.1 mrg i = exponent(x)
5803 1.1 mrg print *, i
5804 1.1 mrg print *, exponent(0.0)
5805 1.1 mrg end program test_exponent
5806 1.1 mrg @end smallexample
5807 1.1 mrg @end table
5808 1.1 mrg
5809 1.1 mrg
5810 1.1 mrg
5811 1.1 mrg @node EXTENDS_TYPE_OF
5812 1.1 mrg @section @code{EXTENDS_TYPE_OF} --- Query dynamic type for extension
5813 1.1 mrg @fnindex EXTENDS_TYPE_OF
5814 1.1 mrg
5815 1.1 mrg @table @asis
5816 1.1 mrg @item @emph{Description}:
5817 1.1 mrg Query dynamic type for extension.
5818 1.1 mrg
5819 1.1 mrg @item @emph{Standard}:
5820 1.1 mrg Fortran 2003 and later
5821 1.1 mrg
5822 1.1 mrg @item @emph{Class}:
5823 1.1 mrg Inquiry function
5824 1.1 mrg
5825 1.1 mrg @item @emph{Syntax}:
5826 1.1 mrg @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
5827 1.1 mrg
5828 1.1 mrg @item @emph{Arguments}:
5829 1.1 mrg @multitable @columnfractions .15 .70
5830 1.1 mrg @item @var{A} @tab Shall be an object of extensible declared type or
5831 1.1 mrg unlimited polymorphic.
5832 1.1 mrg @item @var{MOLD} @tab Shall be an object of extensible declared type or
5833 1.1 mrg unlimited polymorphic.
5834 1.1 mrg @end multitable
5835 1.1 mrg
5836 1.1 mrg @item @emph{Return value}:
5837 1.1 mrg The return value is a scalar of type default logical. It is true if and only if
5838 1.1 mrg the dynamic type of A is an extension type of the dynamic type of MOLD.
5839 1.1 mrg
5840 1.1 mrg
5841 1.1 mrg @item @emph{See also}:
5842 1.1 mrg @ref{SAME_TYPE_AS}
5843 1.1 mrg @end table
5844 1.1 mrg
5845 1.1 mrg
5846 1.1 mrg
5847 1.1 mrg @node FDATE
5848 1.1 mrg @section @code{FDATE} --- Get the current time as a string
5849 1.1 mrg @fnindex FDATE
5850 1.1 mrg @cindex time, current
5851 1.1 mrg @cindex current time
5852 1.1 mrg @cindex date, current
5853 1.1 mrg @cindex current date
5854 1.1 mrg
5855 1.1 mrg @table @asis
5856 1.1 mrg @item @emph{Description}:
5857 1.1 mrg @code{FDATE(DATE)} returns the current date (using the same format as
5858 1.1 mrg @ref{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
5859 1.1 mrg TIME())}.
5860 1.1 mrg
5861 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
5862 1.1 mrg only one form can be used in any given program unit.
5863 1.1 mrg
5864 1.1 mrg @item @emph{Standard}:
5865 1.1 mrg GNU extension
5866 1.1 mrg
5867 1.1 mrg @item @emph{Class}:
5868 1.1 mrg Subroutine, function
5869 1.1 mrg
5870 1.1 mrg @item @emph{Syntax}:
5871 1.1 mrg @multitable @columnfractions .80
5872 1.1 mrg @item @code{CALL FDATE(DATE)}.
5873 1.1 mrg @item @code{DATE = FDATE()}.
5874 1.1 mrg @end multitable
5875 1.1 mrg
5876 1.1 mrg @item @emph{Arguments}:
5877 1.1 mrg @multitable @columnfractions .15 .70
5878 1.1 mrg @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
5879 1.1 mrg default kind. It is an @code{INTENT(OUT)} argument. If the length of
5880 1.1 mrg this variable is too short for the date and time string to fit
5881 1.1 mrg completely, it will be blank on procedure return.
5882 1.1 mrg @end multitable
5883 1.1 mrg
5884 1.1 mrg @item @emph{Return value}:
5885 1.1 mrg The current date and time as a string.
5886 1.1 mrg
5887 1.1 mrg @item @emph{Example}:
5888 1.1 mrg @smallexample
5889 1.1 mrg program test_fdate
5890 1.1 mrg integer(8) :: i, j
5891 1.1 mrg character(len=30) :: date
5892 1.1 mrg call fdate(date)
5893 1.1 mrg print *, 'Program started on ', date
5894 1.1 mrg do i = 1, 100000000 ! Just a delay
5895 1.1 mrg j = i * i - i
5896 1.1 mrg end do
5897 1.1 mrg call fdate(date)
5898 1.1 mrg print *, 'Program ended on ', date
5899 1.1 mrg end program test_fdate
5900 1.1 mrg @end smallexample
5901 1.1 mrg
5902 1.1 mrg @item @emph{See also}:
5903 1.1 mrg @ref{DATE_AND_TIME}, @ref{CTIME}
5904 1.1 mrg @end table
5905 1.1 mrg
5906 1.1 mrg
5907 1.1 mrg @node FGET
5908 1.1 mrg @section @code{FGET} --- Read a single character in stream mode from stdin
5909 1.1 mrg @fnindex FGET
5910 1.1 mrg @cindex read character, stream mode
5911 1.1 mrg @cindex stream mode, read character
5912 1.1 mrg @cindex file operation, read character
5913 1.1 mrg
5914 1.1 mrg @table @asis
5915 1.1 mrg @item @emph{Description}:
5916 1.1 mrg Read a single character in stream mode from stdin by bypassing normal
5917 1.1 mrg formatted output. Stream I/O should not be mixed with normal record-oriented
5918 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable.
5919 1.1 mrg
5920 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
5921 1.1 mrg only one form can be used in any given program unit.
5922 1.1 mrg
5923 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with
5924 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
5925 1.1 mrg Programmers should consider the use of new stream IO feature in new code
5926 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
5927 1.1 mrg
5928 1.1 mrg @item @emph{Standard}:
5929 1.1 mrg GNU extension
5930 1.1 mrg
5931 1.1 mrg @item @emph{Class}:
5932 1.1 mrg Subroutine, function
5933 1.1 mrg
5934 1.1 mrg @item @emph{Syntax}:
5935 1.1 mrg @multitable @columnfractions .80
5936 1.1 mrg @item @code{CALL FGET(C [, STATUS])}
5937 1.1 mrg @item @code{STATUS = FGET(C)}
5938 1.1 mrg @end multitable
5939 1.1 mrg
5940 1.1 mrg @item @emph{Arguments}:
5941 1.1 mrg @multitable @columnfractions .15 .70
5942 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default
5943 1.1 mrg kind.
5944 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5945 1.1 mrg Returns 0 on success, -1 on end-of-file, and a system specific positive
5946 1.1 mrg error code otherwise.
5947 1.1 mrg @end multitable
5948 1.1 mrg
5949 1.1 mrg @item @emph{Example}:
5950 1.1 mrg @smallexample
5951 1.1 mrg PROGRAM test_fget
5952 1.1 mrg INTEGER, PARAMETER :: strlen = 100
5953 1.1 mrg INTEGER :: status, i = 1
5954 1.1 mrg CHARACTER(len=strlen) :: str = ""
5955 1.1 mrg
5956 1.1 mrg WRITE (*,*) 'Enter text:'
5957 1.1 mrg DO
5958 1.1 mrg CALL fget(str(i:i), status)
5959 1.1 mrg if (status /= 0 .OR. i > strlen) exit
5960 1.1 mrg i = i + 1
5961 1.1 mrg END DO
5962 1.1 mrg WRITE (*,*) TRIM(str)
5963 1.1 mrg END PROGRAM
5964 1.1 mrg @end smallexample
5965 1.1 mrg
5966 1.1 mrg @item @emph{See also}:
5967 1.1 mrg @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
5968 1.1 mrg @end table
5969 1.1 mrg
5970 1.1 mrg
5971 1.1 mrg
5972 1.1 mrg @node FGETC
5973 1.1 mrg @section @code{FGETC} --- Read a single character in stream mode
5974 1.1 mrg @fnindex FGETC
5975 1.1 mrg @cindex read character, stream mode
5976 1.1 mrg @cindex stream mode, read character
5977 1.1 mrg @cindex file operation, read character
5978 1.1 mrg
5979 1.1 mrg @table @asis
5980 1.1 mrg @item @emph{Description}:
5981 1.1 mrg Read a single character in stream mode by bypassing normal formatted output.
5982 1.1 mrg Stream I/O should not be mixed with normal record-oriented (formatted or
5983 1.1 mrg unformatted) I/O on the same unit; the results are unpredictable.
5984 1.1 mrg
5985 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
5986 1.1 mrg only one form can be used in any given program unit.
5987 1.1 mrg
5988 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility
5989 1.1 mrg with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
5990 1.1 mrg Programmers should consider the use of new stream IO feature in new code
5991 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
5992 1.1 mrg
5993 1.1 mrg @item @emph{Standard}:
5994 1.1 mrg GNU extension
5995 1.1 mrg
5996 1.1 mrg @item @emph{Class}:
5997 1.1 mrg Subroutine, function
5998 1.1 mrg
5999 1.1 mrg @item @emph{Syntax}:
6000 1.1 mrg @multitable @columnfractions .80
6001 1.1 mrg @item @code{CALL FGETC(UNIT, C [, STATUS])}
6002 1.1 mrg @item @code{STATUS = FGETC(UNIT, C)}
6003 1.1 mrg @end multitable
6004 1.1 mrg
6005 1.1 mrg @item @emph{Arguments}:
6006 1.1 mrg @multitable @columnfractions .15 .70
6007 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6008 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6009 1.1 mrg kind.
6010 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6011 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive
6012 1.1 mrg error code otherwise.
6013 1.1 mrg @end multitable
6014 1.1 mrg
6015 1.1 mrg @item @emph{Example}:
6016 1.1 mrg @smallexample
6017 1.1 mrg PROGRAM test_fgetc
6018 1.1 mrg INTEGER :: fd = 42, status
6019 1.1 mrg CHARACTER :: c
6020 1.1 mrg
6021 1.1 mrg OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
6022 1.1 mrg DO
6023 1.1 mrg CALL fgetc(fd, c, status)
6024 1.1 mrg IF (status /= 0) EXIT
6025 1.1 mrg call fput(c)
6026 1.1 mrg END DO
6027 1.1 mrg CLOSE(UNIT=fd)
6028 1.1 mrg END PROGRAM
6029 1.1 mrg @end smallexample
6030 1.1 mrg
6031 1.1 mrg @item @emph{See also}:
6032 1.1 mrg @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
6033 1.1 mrg @end table
6034 1.1 mrg
6035 1.1 mrg @node FINDLOC
6036 1.1 mrg @section @code{FINDLOC} --- Search an array for a value
6037 1.1 mrg @fnindex FINDLOC
6038 1.1 mrg @cindex findloc
6039 1.1 mrg
6040 1.1 mrg @table @asis
6041 1.1 mrg @item @emph{Description}:
6042 1.1 mrg Determines the location of the element in the array with the value
6043 1.1 mrg given in the @var{VALUE} argument, or, if the @var{DIM} argument is
6044 1.1 mrg supplied, determines the locations of the maximum element along each
6045 1.1 mrg row of the array in the @var{DIM} direction. If @var{MASK} is
6046 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are
6047 1.1 mrg considered. If more than one element in the array has the value
6048 1.1 mrg @var{VALUE}, the location returned is that of the first such element
6049 1.1 mrg in array element order if the @var{BACK} is not present or if it is
6050 1.1 mrg @code{.FALSE.}. If @var{BACK} is true, the location returned is that
6051 1.1 mrg of the last such element. If the array has zero size, or all of the
6052 1.1 mrg elements of @var{MASK} are @code{.FALSE.}, then the result is an array
6053 1.1 mrg of zeroes. Similarly, if @var{DIM} is supplied and all of the
6054 1.1 mrg elements of @var{MASK} along a given row are zero, the result value
6055 1.1 mrg for that row is zero.
6056 1.1 mrg
6057 1.1 mrg @item @emph{Standard}:
6058 1.1 mrg Fortran 2008 and later.
6059 1.1 mrg
6060 1.1 mrg @item @emph{Class}:
6061 1.1 mrg Transformational function
6062 1.1 mrg
6063 1.1 mrg @item @emph{Syntax}:
6064 1.1 mrg @multitable @columnfractions .80
6065 1.1 mrg @item @code{RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND] [,BACK])}
6066 1.1 mrg @item @code{RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND] [,BACK])}
6067 1.1 mrg @end multitable
6068 1.1 mrg
6069 1.1 mrg @item @emph{Arguments}:
6070 1.1 mrg @multitable @columnfractions .15 .70
6071 1.1 mrg @item @var{ARRAY} @tab Shall be an array of intrinsic type.
6072 1.1 mrg @item @var{VALUE} @tab A scalar of intrinsic type which is in type
6073 1.1 mrg conformance with @var{ARRAY}.
6074 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
6075 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
6076 1.1 mrg inclusive. It may not be an optional dummy argument.
6077 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6078 1.1 mrg expression indicating the kind parameter of the result.
6079 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
6080 1.1 mrg @end multitable
6081 1.1 mrg
6082 1.1 mrg @item @emph{Return value}:
6083 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length
6084 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6085 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a
6086 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM}
6087 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6088 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND}
6089 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it
6090 1.1 mrg is of default kind.
6091 1.1 mrg
6092 1.1 mrg @item @emph{See also}:
6093 1.1 mrg @ref{MAXLOC}, @ref{MINLOC}
6094 1.1 mrg
6095 1.1 mrg @end table
6096 1.1 mrg
6097 1.1 mrg @node FLOOR
6098 1.1 mrg @section @code{FLOOR} --- Integer floor function
6099 1.1 mrg @fnindex FLOOR
6100 1.1 mrg @cindex floor
6101 1.1 mrg @cindex rounding, floor
6102 1.1 mrg
6103 1.1 mrg @table @asis
6104 1.1 mrg @item @emph{Description}:
6105 1.1 mrg @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
6106 1.1 mrg
6107 1.1 mrg @item @emph{Standard}:
6108 1.1 mrg Fortran 95 and later
6109 1.1 mrg
6110 1.1 mrg @item @emph{Class}:
6111 1.1 mrg Elemental function
6112 1.1 mrg
6113 1.1 mrg @item @emph{Syntax}:
6114 1.1 mrg @code{RESULT = FLOOR(A [, KIND])}
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{A} @tab The type shall be @code{REAL}.
6119 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6120 1.1 mrg expression indicating the kind parameter of the result.
6121 1.1 mrg @end multitable
6122 1.1 mrg
6123 1.1 mrg @item @emph{Return value}:
6124 1.1 mrg The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
6125 1.1 mrg and of default-kind @code{INTEGER} otherwise.
6126 1.1 mrg
6127 1.1 mrg @item @emph{Example}:
6128 1.1 mrg @smallexample
6129 1.1 mrg program test_floor
6130 1.1 mrg real :: x = 63.29
6131 1.1 mrg real :: y = -63.59
6132 1.1 mrg print *, floor(x) ! returns 63
6133 1.1 mrg print *, floor(y) ! returns -64
6134 1.1 mrg end program test_floor
6135 1.1 mrg @end smallexample
6136 1.1 mrg
6137 1.1 mrg @item @emph{See also}:
6138 1.1 mrg @ref{CEILING}, @ref{NINT}
6139 1.1 mrg
6140 1.1 mrg @end table
6141 1.1 mrg
6142 1.1 mrg
6143 1.1 mrg
6144 1.1 mrg @node FLUSH
6145 1.1 mrg @section @code{FLUSH} --- Flush I/O unit(s)
6146 1.1 mrg @fnindex FLUSH
6147 1.1 mrg @cindex file operation, flush
6148 1.1 mrg
6149 1.1 mrg @table @asis
6150 1.1 mrg @item @emph{Description}:
6151 1.1 mrg Flushes Fortran unit(s) currently open for output. Without the optional
6152 1.1 mrg argument, all units are flushed, otherwise just the unit specified.
6153 1.1 mrg
6154 1.1 mrg @item @emph{Standard}:
6155 1.1 mrg GNU extension
6156 1.1 mrg
6157 1.1 mrg @item @emph{Class}:
6158 1.1 mrg Subroutine
6159 1.1 mrg
6160 1.1 mrg @item @emph{Syntax}:
6161 1.1 mrg @code{CALL FLUSH(UNIT)}
6162 1.1 mrg
6163 1.1 mrg @item @emph{Arguments}:
6164 1.1 mrg @multitable @columnfractions .15 .70
6165 1.1 mrg @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
6166 1.1 mrg @end multitable
6167 1.1 mrg
6168 1.1 mrg @item @emph{Note}:
6169 1.1 mrg Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
6170 1.1 mrg statement that should be preferred over the @code{FLUSH} intrinsic.
6171 1.1 mrg
6172 1.1 mrg The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
6173 1.1 mrg have identical effect: they flush the runtime library's I/O buffer so
6174 1.1 mrg that the data becomes visible to other processes. This does not guarantee
6175 1.1 mrg that the data is committed to disk.
6176 1.1 mrg
6177 1.1 mrg On POSIX systems, you can request that all data is transferred to the
6178 1.1 mrg storage device by calling the @code{fsync} function, with the POSIX file
6179 1.1 mrg descriptor of the I/O unit as argument (retrieved with GNU intrinsic
6180 1.1 mrg @code{FNUM}). The following example shows how:
6181 1.1 mrg
6182 1.1 mrg @smallexample
6183 1.1 mrg ! Declare the interface for POSIX fsync function
6184 1.1 mrg interface
6185 1.1 mrg function fsync (fd) bind(c,name="fsync")
6186 1.1 mrg use iso_c_binding, only: c_int
6187 1.1 mrg integer(c_int), value :: fd
6188 1.1 mrg integer(c_int) :: fsync
6189 1.1 mrg end function fsync
6190 1.1 mrg end interface
6191 1.1 mrg
6192 1.1 mrg ! Variable declaration
6193 1.1 mrg integer :: ret
6194 1.1 mrg
6195 1.1 mrg ! Opening unit 10
6196 1.1 mrg open (10,file="foo")
6197 1.1 mrg
6198 1.1 mrg ! ...
6199 1.1 mrg ! Perform I/O on unit 10
6200 1.1 mrg ! ...
6201 1.1 mrg
6202 1.1 mrg ! Flush and sync
6203 1.1 mrg flush(10)
6204 1.1 mrg ret = fsync(fnum(10))
6205 1.1 mrg
6206 1.1 mrg ! Handle possible error
6207 1.1 mrg if (ret /= 0) stop "Error calling FSYNC"
6208 1.1 mrg @end smallexample
6209 1.1 mrg
6210 1.1 mrg @end table
6211 1.1 mrg
6212 1.1 mrg
6213 1.1 mrg
6214 1.1 mrg @node FNUM
6215 1.1 mrg @section @code{FNUM} --- File number function
6216 1.1 mrg @fnindex FNUM
6217 1.1 mrg @cindex file operation, file number
6218 1.1 mrg
6219 1.1 mrg @table @asis
6220 1.1 mrg @item @emph{Description}:
6221 1.1 mrg @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
6222 1.1 mrg open Fortran I/O unit @code{UNIT}.
6223 1.1 mrg
6224 1.1 mrg @item @emph{Standard}:
6225 1.1 mrg GNU extension
6226 1.1 mrg
6227 1.1 mrg @item @emph{Class}:
6228 1.1 mrg Function
6229 1.1 mrg
6230 1.1 mrg @item @emph{Syntax}:
6231 1.1 mrg @code{RESULT = FNUM(UNIT)}
6232 1.1 mrg
6233 1.1 mrg @item @emph{Arguments}:
6234 1.1 mrg @multitable @columnfractions .15 .70
6235 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}.
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}
6240 1.1 mrg
6241 1.1 mrg @item @emph{Example}:
6242 1.1 mrg @smallexample
6243 1.1 mrg program test_fnum
6244 1.1 mrg integer :: i
6245 1.1 mrg open (unit=10, status = "scratch")
6246 1.1 mrg i = fnum(10)
6247 1.1 mrg print *, i
6248 1.1 mrg close (10)
6249 1.1 mrg end program test_fnum
6250 1.1 mrg @end smallexample
6251 1.1 mrg @end table
6252 1.1 mrg
6253 1.1 mrg
6254 1.1 mrg
6255 1.1 mrg @node FPUT
6256 1.1 mrg @section @code{FPUT} --- Write a single character in stream mode to stdout
6257 1.1 mrg @fnindex FPUT
6258 1.1 mrg @cindex write character, stream mode
6259 1.1 mrg @cindex stream mode, write character
6260 1.1 mrg @cindex file operation, write character
6261 1.1 mrg
6262 1.1 mrg @table @asis
6263 1.1 mrg @item @emph{Description}:
6264 1.1 mrg Write a single character in stream mode to stdout by bypassing normal
6265 1.1 mrg formatted output. Stream I/O should not be mixed with normal record-oriented
6266 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6267 1.1 mrg
6268 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6269 1.1 mrg only one form can be used in any given program unit.
6270 1.1 mrg
6271 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6272 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6273 1.1 mrg Programmers should consider the use of new stream IO feature in new code
6274 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
6275 1.1 mrg
6276 1.1 mrg @item @emph{Standard}:
6277 1.1 mrg GNU extension
6278 1.1 mrg
6279 1.1 mrg @item @emph{Class}:
6280 1.1 mrg Subroutine, function
6281 1.1 mrg
6282 1.1 mrg @item @emph{Syntax}:
6283 1.1 mrg @multitable @columnfractions .80
6284 1.1 mrg @item @code{CALL FPUT(C [, STATUS])}
6285 1.1 mrg @item @code{STATUS = FPUT(C)}
6286 1.1 mrg @end multitable
6287 1.1 mrg
6288 1.1 mrg @item @emph{Arguments}:
6289 1.1 mrg @multitable @columnfractions .15 .70
6290 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6291 1.1 mrg kind.
6292 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6293 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive
6294 1.1 mrg error code otherwise.
6295 1.1 mrg @end multitable
6296 1.1 mrg
6297 1.1 mrg @item @emph{Example}:
6298 1.1 mrg @smallexample
6299 1.1 mrg PROGRAM test_fput
6300 1.1 mrg CHARACTER(len=10) :: str = "gfortran"
6301 1.1 mrg INTEGER :: i
6302 1.1 mrg DO i = 1, len_trim(str)
6303 1.1 mrg CALL fput(str(i:i))
6304 1.1 mrg END DO
6305 1.1 mrg END PROGRAM
6306 1.1 mrg @end smallexample
6307 1.1 mrg
6308 1.1 mrg @item @emph{See also}:
6309 1.1 mrg @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
6310 1.1 mrg @end table
6311 1.1 mrg
6312 1.1 mrg
6313 1.1 mrg
6314 1.1 mrg @node FPUTC
6315 1.1 mrg @section @code{FPUTC} --- Write a single character in stream mode
6316 1.1 mrg @fnindex FPUTC
6317 1.1 mrg @cindex write character, stream mode
6318 1.1 mrg @cindex stream mode, write character
6319 1.1 mrg @cindex file operation, write character
6320 1.1 mrg
6321 1.1 mrg @table @asis
6322 1.1 mrg @item @emph{Description}:
6323 1.1 mrg Write a single character in stream mode by bypassing normal formatted
6324 1.1 mrg output. Stream I/O should not be mixed with normal record-oriented
6325 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6326 1.1 mrg
6327 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6328 1.1 mrg only one form can be used in any given program unit.
6329 1.1 mrg
6330 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6331 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6332 1.1 mrg Programmers should consider the use of new stream IO feature in new code
6333 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
6334 1.1 mrg
6335 1.1 mrg @item @emph{Standard}:
6336 1.1 mrg GNU extension
6337 1.1 mrg
6338 1.1 mrg @item @emph{Class}:
6339 1.1 mrg Subroutine, function
6340 1.1 mrg
6341 1.1 mrg @item @emph{Syntax}:
6342 1.1 mrg @multitable @columnfractions .80
6343 1.1 mrg @item @code{CALL FPUTC(UNIT, C [, STATUS])}
6344 1.1 mrg @item @code{STATUS = FPUTC(UNIT, C)}
6345 1.1 mrg @end multitable
6346 1.1 mrg
6347 1.1 mrg @item @emph{Arguments}:
6348 1.1 mrg @multitable @columnfractions .15 .70
6349 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6350 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6351 1.1 mrg kind.
6352 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6353 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive
6354 1.1 mrg error code otherwise.
6355 1.1 mrg @end multitable
6356 1.1 mrg
6357 1.1 mrg @item @emph{Example}:
6358 1.1 mrg @smallexample
6359 1.1 mrg PROGRAM test_fputc
6360 1.1 mrg CHARACTER(len=10) :: str = "gfortran"
6361 1.1 mrg INTEGER :: fd = 42, i
6362 1.1 mrg
6363 1.1 mrg OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
6364 1.1 mrg DO i = 1, len_trim(str)
6365 1.1 mrg CALL fputc(fd, str(i:i))
6366 1.1 mrg END DO
6367 1.1 mrg CLOSE(fd)
6368 1.1 mrg END PROGRAM
6369 1.1 mrg @end smallexample
6370 1.1 mrg
6371 1.1 mrg @item @emph{See also}:
6372 1.1 mrg @ref{FPUT}, @ref{FGET}, @ref{FGETC}
6373 1.1 mrg @end table
6374 1.1 mrg
6375 1.1 mrg
6376 1.1 mrg
6377 1.1 mrg @node FRACTION
6378 1.1 mrg @section @code{FRACTION} --- Fractional part of the model representation
6379 1.1 mrg @fnindex FRACTION
6380 1.1 mrg @cindex real number, fraction
6381 1.1 mrg @cindex floating point, fraction
6382 1.1 mrg
6383 1.1 mrg @table @asis
6384 1.1 mrg @item @emph{Description}:
6385 1.1 mrg @code{FRACTION(X)} returns the fractional part of the model
6386 1.1 mrg representation of @code{X}.
6387 1.1 mrg
6388 1.1 mrg @item @emph{Standard}:
6389 1.1 mrg Fortran 95 and later
6390 1.1 mrg
6391 1.1 mrg @item @emph{Class}:
6392 1.1 mrg Elemental function
6393 1.1 mrg
6394 1.1 mrg @item @emph{Syntax}:
6395 1.1 mrg @code{Y = FRACTION(X)}
6396 1.1 mrg
6397 1.1 mrg @item @emph{Arguments}:
6398 1.1 mrg @multitable @columnfractions .15 .70
6399 1.1 mrg @item @var{X} @tab The type of the argument shall be a @code{REAL}.
6400 1.1 mrg @end multitable
6401 1.1 mrg
6402 1.1 mrg @item @emph{Return value}:
6403 1.1 mrg The return value is of the same type and kind as the argument.
6404 1.1 mrg The fractional part of the model representation of @code{X} is returned;
6405 1.1 mrg it is @code{X * RADIX(X)**(-EXPONENT(X))}.
6406 1.1 mrg
6407 1.1 mrg @item @emph{Example}:
6408 1.1 mrg @smallexample
6409 1.1 mrg program test_fraction
6410 1.1 mrg real :: x
6411 1.1 mrg x = 178.1387e-4
6412 1.1 mrg print *, fraction(x), x * radix(x)**(-exponent(x))
6413 1.1 mrg end program test_fraction
6414 1.1 mrg @end smallexample
6415 1.1 mrg
6416 1.1 mrg @end table
6417 1.1 mrg
6418 1.1 mrg
6419 1.1 mrg
6420 1.1 mrg @node FREE
6421 1.1 mrg @section @code{FREE} --- Frees memory
6422 1.1 mrg @fnindex FREE
6423 1.1 mrg @cindex pointer, cray
6424 1.1 mrg
6425 1.1 mrg @table @asis
6426 1.1 mrg @item @emph{Description}:
6427 1.1 mrg Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
6428 1.1 mrg intrinsic is an extension intended to be used with Cray pointers, and is
6429 1.1 mrg provided in GNU Fortran to allow user to compile legacy code. For
6430 1.1 mrg new code using Fortran 95 pointers, the memory de-allocation intrinsic is
6431 1.1 mrg @code{DEALLOCATE}.
6432 1.1 mrg
6433 1.1 mrg @item @emph{Standard}:
6434 1.1 mrg GNU extension
6435 1.1 mrg
6436 1.1 mrg @item @emph{Class}:
6437 1.1 mrg Subroutine
6438 1.1 mrg
6439 1.1 mrg @item @emph{Syntax}:
6440 1.1 mrg @code{CALL FREE(PTR)}
6441 1.1 mrg
6442 1.1 mrg @item @emph{Arguments}:
6443 1.1 mrg @multitable @columnfractions .15 .70
6444 1.1 mrg @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
6445 1.1 mrg location of the memory that should be de-allocated.
6446 1.1 mrg @end multitable
6447 1.1 mrg
6448 1.1 mrg @item @emph{Return value}:
6449 1.1 mrg None
6450 1.1 mrg
6451 1.1 mrg @item @emph{Example}:
6452 1.1 mrg See @code{MALLOC} for an example.
6453 1.1 mrg
6454 1.1 mrg @item @emph{See also}:
6455 1.1 mrg @ref{MALLOC}
6456 1.1 mrg @end table
6457 1.1 mrg
6458 1.1 mrg
6459 1.1 mrg
6460 1.1 mrg @node FSEEK
6461 1.1 mrg @section @code{FSEEK} --- Low level file positioning subroutine
6462 1.1 mrg @fnindex FSEEK
6463 1.1 mrg @cindex file operation, seek
6464 1.1 mrg @cindex file operation, position
6465 1.1 mrg
6466 1.1 mrg @table @asis
6467 1.1 mrg @item @emph{Description}:
6468 1.1 mrg Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
6469 1.1 mrg is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
6470 1.1 mrg if set to 1, @var{OFFSET} is taken to be relative to the current position
6471 1.1 mrg @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
6472 1.1 mrg On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
6473 1.1 mrg fails silently.
6474 1.1 mrg
6475 1.1 mrg This intrinsic routine is not fully backwards compatible with @command{g77}.
6476 1.1 mrg In @command{g77}, the @code{FSEEK} takes a statement label instead of a
6477 1.1 mrg @var{STATUS} variable. If FSEEK is used in old code, change
6478 1.1 mrg @smallexample
6479 1.1 mrg CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
6480 1.1 mrg @end smallexample
6481 1.1 mrg to
6482 1.1 mrg @smallexample
6483 1.1 mrg INTEGER :: status
6484 1.1 mrg CALL FSEEK(UNIT, OFFSET, WHENCE, status)
6485 1.1 mrg IF (status /= 0) GOTO label
6486 1.1 mrg @end smallexample
6487 1.1 mrg
6488 1.1 mrg Please note that GNU Fortran provides the Fortran 2003 Stream facility.
6489 1.1 mrg Programmers should consider the use of new stream IO feature in new code
6490 1.1 mrg for future portability. See also @ref{Fortran 2003 status}.
6491 1.1 mrg
6492 1.1 mrg @item @emph{Standard}:
6493 1.1 mrg GNU extension
6494 1.1 mrg
6495 1.1 mrg @item @emph{Class}:
6496 1.1 mrg Subroutine
6497 1.1 mrg
6498 1.1 mrg @item @emph{Syntax}:
6499 1.1 mrg @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
6500 1.1 mrg
6501 1.1 mrg @item @emph{Arguments}:
6502 1.1 mrg @multitable @columnfractions .15 .70
6503 1.1 mrg @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
6504 1.1 mrg @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
6505 1.1 mrg @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
6506 1.1 mrg Its value shall be either 0, 1 or 2.
6507 1.1 mrg @item @var{STATUS} @tab (Optional) shall be a scalar of type
6508 1.1 mrg @code{INTEGER(4)}.
6509 1.1 mrg @end multitable
6510 1.1 mrg
6511 1.1 mrg @item @emph{Example}:
6512 1.1 mrg @smallexample
6513 1.1 mrg PROGRAM test_fseek
6514 1.1 mrg INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
6515 1.1 mrg INTEGER :: fd, offset, ierr
6516 1.1 mrg
6517 1.1 mrg ierr = 0
6518 1.1 mrg offset = 5
6519 1.1 mrg fd = 10
6520 1.1 mrg
6521 1.1 mrg OPEN(UNIT=fd, FILE="fseek.test")
6522 1.1 mrg CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
6523 1.1 mrg print *, FTELL(fd), ierr
6524 1.1 mrg
6525 1.1 mrg CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
6526 1.1 mrg print *, FTELL(fd), ierr
6527 1.1 mrg
6528 1.1 mrg CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
6529 1.1 mrg print *, FTELL(fd), ierr
6530 1.1 mrg
6531 1.1 mrg CLOSE(UNIT=fd)
6532 1.1 mrg END PROGRAM
6533 1.1 mrg @end smallexample
6534 1.1 mrg
6535 1.1 mrg @item @emph{See also}:
6536 1.1 mrg @ref{FTELL}
6537 1.1 mrg @end table
6538 1.1 mrg
6539 1.1 mrg
6540 1.1 mrg
6541 1.1 mrg @node FSTAT
6542 1.1 mrg @section @code{FSTAT} --- Get file status
6543 1.1 mrg @fnindex FSTAT
6544 1.1 mrg @cindex file system, file status
6545 1.1 mrg
6546 1.1 mrg @table @asis
6547 1.1 mrg @item @emph{Description}:
6548 1.1 mrg @code{FSTAT} is identical to @ref{STAT}, except that information about an
6549 1.1 mrg already opened file is obtained.
6550 1.1 mrg
6551 1.1 mrg The elements in @code{VALUES} are the same as described by @ref{STAT}.
6552 1.1 mrg
6553 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6554 1.1 mrg only one form can be used in any given program unit.
6555 1.1 mrg
6556 1.1 mrg @item @emph{Standard}:
6557 1.1 mrg GNU extension
6558 1.1 mrg
6559 1.1 mrg @item @emph{Class}:
6560 1.1 mrg Subroutine, function
6561 1.1 mrg
6562 1.1 mrg @item @emph{Syntax}:
6563 1.1 mrg @multitable @columnfractions .80
6564 1.1 mrg @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
6565 1.1 mrg @item @code{STATUS = FSTAT(UNIT, VALUES)}
6566 1.1 mrg @end multitable
6567 1.1 mrg
6568 1.1 mrg @item @emph{Arguments}:
6569 1.1 mrg @multitable @columnfractions .15 .70
6570 1.1 mrg @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
6571 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6572 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6573 1.1 mrg on success and a system specific error code otherwise.
6574 1.1 mrg @end multitable
6575 1.1 mrg
6576 1.1 mrg @item @emph{Example}:
6577 1.1 mrg See @ref{STAT} for an example.
6578 1.1 mrg
6579 1.1 mrg @item @emph{See also}:
6580 1.1 mrg To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
6581 1.1 mrg @end table
6582 1.1 mrg
6583 1.1 mrg
6584 1.1 mrg
6585 1.1 mrg @node FTELL
6586 1.1 mrg @section @code{FTELL} --- Current stream position
6587 1.1 mrg @fnindex FTELL
6588 1.1 mrg @cindex file operation, position
6589 1.1 mrg
6590 1.1 mrg @table @asis
6591 1.1 mrg @item @emph{Description}:
6592 1.1 mrg Retrieves the current position within an open file.
6593 1.1 mrg
6594 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6595 1.1 mrg only one form can be used in any given program unit.
6596 1.1 mrg
6597 1.1 mrg @item @emph{Standard}:
6598 1.1 mrg GNU extension
6599 1.1 mrg
6600 1.1 mrg @item @emph{Class}:
6601 1.1 mrg Subroutine, function
6602 1.1 mrg
6603 1.1 mrg @item @emph{Syntax}:
6604 1.1 mrg @multitable @columnfractions .80
6605 1.1 mrg @item @code{CALL FTELL(UNIT, OFFSET)}
6606 1.1 mrg @item @code{OFFSET = FTELL(UNIT)}
6607 1.1 mrg @end multitable
6608 1.1 mrg
6609 1.1 mrg @item @emph{Arguments}:
6610 1.1 mrg @multitable @columnfractions .15 .70
6611 1.1 mrg @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
6612 1.1 mrg @item @var{UNIT} @tab Shall of type @code{INTEGER}.
6613 1.1 mrg @end multitable
6614 1.1 mrg
6615 1.1 mrg @item @emph{Return value}:
6616 1.1 mrg In either syntax, @var{OFFSET} is set to the current offset of unit
6617 1.1 mrg number @var{UNIT}, or to @math{-1} if the unit is not currently open.
6618 1.1 mrg
6619 1.1 mrg @item @emph{Example}:
6620 1.1 mrg @smallexample
6621 1.1 mrg PROGRAM test_ftell
6622 1.1 mrg INTEGER :: i
6623 1.1 mrg OPEN(10, FILE="temp.dat")
6624 1.1 mrg CALL ftell(10,i)
6625 1.1 mrg WRITE(*,*) i
6626 1.1 mrg END PROGRAM
6627 1.1 mrg @end smallexample
6628 1.1 mrg
6629 1.1 mrg @item @emph{See also}:
6630 1.1 mrg @ref{FSEEK}
6631 1.1 mrg @end table
6632 1.1 mrg
6633 1.1 mrg
6634 1.1 mrg
6635 1.1 mrg @node GAMMA
6636 1.1 mrg @section @code{GAMMA} --- Gamma function
6637 1.1 mrg @fnindex GAMMA
6638 1.1 mrg @fnindex DGAMMA
6639 1.1 mrg @cindex Gamma function
6640 1.1 mrg @cindex Factorial function
6641 1.1 mrg
6642 1.1 mrg @table @asis
6643 1.1 mrg @item @emph{Description}:
6644 1.1 mrg @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
6645 1.1 mrg integer values of @var{X} the Gamma function simplifies to the factorial
6646 1.1 mrg function @math{\Gamma(x)=(x-1)!}.
6647 1.1 mrg
6648 1.1 mrg @tex
6649 1.1 mrg $$
6650 1.1 mrg \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
6651 1.1 mrg $$
6652 1.1 mrg @end tex
6653 1.1 mrg
6654 1.1 mrg @item @emph{Standard}:
6655 1.1 mrg Fortran 2008 and later
6656 1.1 mrg
6657 1.1 mrg @item @emph{Class}:
6658 1.1 mrg Elemental function
6659 1.1 mrg
6660 1.1 mrg @item @emph{Syntax}:
6661 1.1 mrg @code{X = GAMMA(X)}
6662 1.1 mrg
6663 1.1 mrg @item @emph{Arguments}:
6664 1.1 mrg @multitable @columnfractions .15 .70
6665 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} and neither zero
6666 1.1 mrg nor a negative integer.
6667 1.1 mrg @end multitable
6668 1.1 mrg
6669 1.1 mrg @item @emph{Return value}:
6670 1.1 mrg The return value is of type @code{REAL} of the same kind as @var{X}.
6671 1.1 mrg
6672 1.1 mrg @item @emph{Example}:
6673 1.1 mrg @smallexample
6674 1.1 mrg program test_gamma
6675 1.1 mrg real :: x = 1.0
6676 1.1 mrg x = gamma(x) ! returns 1.0
6677 1.1 mrg end program test_gamma
6678 1.1 mrg @end smallexample
6679 1.1 mrg
6680 1.1 mrg @item @emph{Specific names}:
6681 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
6682 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
6683 1.1 mrg @item @code{GAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
6684 1.1 mrg @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
6685 1.1 mrg @end multitable
6686 1.1 mrg
6687 1.1 mrg @item @emph{See also}:
6688 1.1 mrg Logarithm of the Gamma function: @ref{LOG_GAMMA}
6689 1.1 mrg
6690 1.1 mrg @end table
6691 1.1 mrg
6692 1.1 mrg
6693 1.1 mrg
6694 1.1 mrg @node GERROR
6695 1.1 mrg @section @code{GERROR} --- Get last system error message
6696 1.1 mrg @fnindex GERROR
6697 1.1 mrg @cindex system, error handling
6698 1.1 mrg
6699 1.1 mrg @table @asis
6700 1.1 mrg @item @emph{Description}:
6701 1.1 mrg Returns the system error message corresponding to the last system error.
6702 1.1 mrg This resembles the functionality of @code{strerror(3)} in C.
6703 1.1 mrg
6704 1.1 mrg @item @emph{Standard}:
6705 1.1 mrg GNU extension
6706 1.1 mrg
6707 1.1 mrg @item @emph{Class}:
6708 1.1 mrg Subroutine
6709 1.1 mrg
6710 1.1 mrg @item @emph{Syntax}:
6711 1.1 mrg @code{CALL GERROR(RESULT)}
6712 1.1 mrg
6713 1.1 mrg @item @emph{Arguments}:
6714 1.1 mrg @multitable @columnfractions .15 .70
6715 1.1 mrg @item @var{RESULT} @tab Shall of type @code{CHARACTER} and of default
6716 1.1 mrg @end multitable
6717 1.1 mrg
6718 1.1 mrg @item @emph{Example}:
6719 1.1 mrg @smallexample
6720 1.1 mrg PROGRAM test_gerror
6721 1.1 mrg CHARACTER(len=100) :: msg
6722 1.1 mrg CALL gerror(msg)
6723 1.1 mrg WRITE(*,*) msg
6724 1.1 mrg END PROGRAM
6725 1.1 mrg @end smallexample
6726 1.1 mrg
6727 1.1 mrg @item @emph{See also}:
6728 1.1 mrg @ref{IERRNO}, @ref{PERROR}
6729 1.1 mrg @end table
6730 1.1 mrg
6731 1.1 mrg
6732 1.1 mrg
6733 1.1 mrg @node GETARG
6734 1.1 mrg @section @code{GETARG} --- Get command line arguments
6735 1.1 mrg @fnindex GETARG
6736 1.1 mrg @cindex command-line arguments
6737 1.1 mrg @cindex arguments, to program
6738 1.1 mrg
6739 1.1 mrg @table @asis
6740 1.1 mrg @item @emph{Description}:
6741 1.1 mrg Retrieve the @var{POS}-th argument that was passed on the
6742 1.1 mrg command line when the containing program was invoked.
6743 1.1 mrg
6744 1.1 mrg This intrinsic routine is provided for backwards compatibility with
6745 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
6746 1.1 mrg the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
6747 1.1 mrg standard.
6748 1.1 mrg
6749 1.1 mrg @item @emph{Standard}:
6750 1.1 mrg GNU extension
6751 1.1 mrg
6752 1.1 mrg @item @emph{Class}:
6753 1.1 mrg Subroutine
6754 1.1 mrg
6755 1.1 mrg @item @emph{Syntax}:
6756 1.1 mrg @code{CALL GETARG(POS, VALUE)}
6757 1.1 mrg
6758 1.1 mrg @item @emph{Arguments}:
6759 1.1 mrg @multitable @columnfractions .15 .70
6760 1.1 mrg @item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than
6761 1.1 mrg the default integer kind; @math{@var{POS} \geq 0}
6762 1.1 mrg @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
6763 1.1 mrg kind.
6764 1.1 mrg @item @var{VALUE} @tab Shall be of type @code{CHARACTER}.
6765 1.1 mrg @end multitable
6766 1.1 mrg
6767 1.1 mrg @item @emph{Return value}:
6768 1.1 mrg After @code{GETARG} returns, the @var{VALUE} argument holds the
6769 1.1 mrg @var{POS}th command line argument. If @var{VALUE} cannot hold the
6770 1.1 mrg argument, it is truncated to fit the length of @var{VALUE}. If there are
6771 1.1 mrg less than @var{POS} arguments specified at the command line, @var{VALUE}
6772 1.1 mrg will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
6773 1.1 mrg to the name of the program (on systems that support this feature).
6774 1.1 mrg
6775 1.1 mrg @item @emph{Example}:
6776 1.1 mrg @smallexample
6777 1.1 mrg PROGRAM test_getarg
6778 1.1 mrg INTEGER :: i
6779 1.1 mrg CHARACTER(len=32) :: arg
6780 1.1 mrg
6781 1.1 mrg DO i = 1, iargc()
6782 1.1 mrg CALL getarg(i, arg)
6783 1.1 mrg WRITE (*,*) arg
6784 1.1 mrg END DO
6785 1.1 mrg END PROGRAM
6786 1.1 mrg @end smallexample
6787 1.1 mrg
6788 1.1 mrg @item @emph{See also}:
6789 1.1 mrg GNU Fortran 77 compatibility function: @ref{IARGC}
6790 1.1 mrg
6791 1.1 mrg Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
6792 1.1 mrg @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6793 1.1 mrg @end table
6794 1.1 mrg
6795 1.1 mrg
6796 1.1 mrg
6797 1.1 mrg @node GET_COMMAND
6798 1.1 mrg @section @code{GET_COMMAND} --- Get the entire command line
6799 1.1 mrg @fnindex GET_COMMAND
6800 1.1 mrg @cindex command-line arguments
6801 1.1 mrg @cindex arguments, to program
6802 1.1 mrg
6803 1.1 mrg @table @asis
6804 1.1 mrg @item @emph{Description}:
6805 1.1 mrg Retrieve the entire command line that was used to invoke the program.
6806 1.1 mrg
6807 1.1 mrg @item @emph{Standard}:
6808 1.1 mrg Fortran 2003 and later
6809 1.1 mrg
6810 1.1 mrg @item @emph{Class}:
6811 1.1 mrg Subroutine
6812 1.1 mrg
6813 1.1 mrg @item @emph{Syntax}:
6814 1.1 mrg @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
6815 1.1 mrg
6816 1.1 mrg @item @emph{Arguments}:
6817 1.1 mrg @multitable @columnfractions .15 .70
6818 1.1 mrg @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
6819 1.1 mrg of default kind.
6820 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
6821 1.1 mrg default kind.
6822 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
6823 1.1 mrg default kind.
6824 1.1 mrg @end multitable
6825 1.1 mrg
6826 1.1 mrg @item @emph{Return value}:
6827 1.1 mrg If @var{COMMAND} is present, stores the entire command line that was used
6828 1.1 mrg to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
6829 1.1 mrg assigned the length of the command line. If @var{STATUS} is present, it
6830 1.1 mrg is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
6831 1.1 mrg short to store the command line, or a positive value in case of an error.
6832 1.1 mrg
6833 1.1 mrg @item @emph{Example}:
6834 1.1 mrg @smallexample
6835 1.1 mrg PROGRAM test_get_command
6836 1.1 mrg CHARACTER(len=255) :: cmd
6837 1.1 mrg CALL get_command(cmd)
6838 1.1 mrg WRITE (*,*) TRIM(cmd)
6839 1.1 mrg END PROGRAM
6840 1.1 mrg @end smallexample
6841 1.1 mrg
6842 1.1 mrg @item @emph{See also}:
6843 1.1 mrg @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6844 1.1 mrg @end table
6845 1.1 mrg
6846 1.1 mrg
6847 1.1 mrg
6848 1.1 mrg @node GET_COMMAND_ARGUMENT
6849 1.1 mrg @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
6850 1.1 mrg @fnindex GET_COMMAND_ARGUMENT
6851 1.1 mrg @cindex command-line arguments
6852 1.1 mrg @cindex arguments, to program
6853 1.1 mrg
6854 1.1 mrg @table @asis
6855 1.1 mrg @item @emph{Description}:
6856 1.1 mrg Retrieve the @var{NUMBER}-th argument that was passed on the
6857 1.1 mrg command line when the containing program was invoked.
6858 1.1 mrg
6859 1.1 mrg @item @emph{Standard}:
6860 1.1 mrg Fortran 2003 and later
6861 1.1 mrg
6862 1.1 mrg @item @emph{Class}:
6863 1.1 mrg Subroutine
6864 1.1 mrg
6865 1.1 mrg @item @emph{Syntax}:
6866 1.1 mrg @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
6867 1.1 mrg
6868 1.1 mrg @item @emph{Arguments}:
6869 1.1 mrg @multitable @columnfractions .15 .70
6870 1.1 mrg @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
6871 1.1 mrg default kind, @math{@var{NUMBER} \geq 0}
6872 1.1 mrg @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
6873 1.1 mrg and of default kind.
6874 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6875 1.1 mrg and of default kind.
6876 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6877 1.1 mrg and of default kind.
6878 1.1 mrg @end multitable
6879 1.1 mrg
6880 1.1 mrg @item @emph{Return value}:
6881 1.1 mrg After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the
6882 1.1 mrg @var{NUMBER}-th command line argument. If @var{VALUE} cannot hold the argument, it is
6883 1.1 mrg truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
6884 1.1 mrg arguments specified at the command line, @var{VALUE} will be filled with blanks.
6885 1.1 mrg If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
6886 1.1 mrg systems that support this feature). The @var{LENGTH} argument contains the
6887 1.1 mrg length of the @var{NUMBER}-th command line argument. If the argument retrieval
6888 1.1 mrg fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
6889 1.1 mrg command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
6890 1.1 mrg zero.
6891 1.1 mrg
6892 1.1 mrg @item @emph{Example}:
6893 1.1 mrg @smallexample
6894 1.1 mrg PROGRAM test_get_command_argument
6895 1.1 mrg INTEGER :: i
6896 1.1 mrg CHARACTER(len=32) :: arg
6897 1.1 mrg
6898 1.1 mrg i = 0
6899 1.1 mrg DO
6900 1.1 mrg CALL get_command_argument(i, arg)
6901 1.1 mrg IF (LEN_TRIM(arg) == 0) EXIT
6902 1.1 mrg
6903 1.1 mrg WRITE (*,*) TRIM(arg)
6904 1.1 mrg i = i+1
6905 1.1 mrg END DO
6906 1.1 mrg END PROGRAM
6907 1.1 mrg @end smallexample
6908 1.1 mrg
6909 1.1 mrg @item @emph{See also}:
6910 1.1 mrg @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
6911 1.1 mrg @end table
6912 1.1 mrg
6913 1.1 mrg
6914 1.1 mrg
6915 1.1 mrg @node GETCWD
6916 1.1 mrg @section @code{GETCWD} --- Get current working directory
6917 1.1 mrg @fnindex GETCWD
6918 1.1 mrg @cindex system, working directory
6919 1.1 mrg
6920 1.1 mrg @table @asis
6921 1.1 mrg @item @emph{Description}:
6922 1.1 mrg Get current working directory.
6923 1.1 mrg
6924 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
6925 1.1 mrg only one form can be used in any given program unit.
6926 1.1 mrg
6927 1.1 mrg @item @emph{Standard}:
6928 1.1 mrg GNU extension
6929 1.1 mrg
6930 1.1 mrg @item @emph{Class}:
6931 1.1 mrg Subroutine, function
6932 1.1 mrg
6933 1.1 mrg @item @emph{Syntax}:
6934 1.1 mrg @multitable @columnfractions .80
6935 1.1 mrg @item @code{CALL GETCWD(C [, STATUS])}
6936 1.1 mrg @item @code{STATUS = GETCWD(C)}
6937 1.1 mrg @end multitable
6938 1.1 mrg
6939 1.1 mrg @item @emph{Arguments}:
6940 1.1 mrg @multitable @columnfractions .15 .70
6941 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
6942 1.1 mrg @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
6943 1.1 mrg a system specific and nonzero error code otherwise.
6944 1.1 mrg @end multitable
6945 1.1 mrg
6946 1.1 mrg @item @emph{Example}:
6947 1.1 mrg @smallexample
6948 1.1 mrg PROGRAM test_getcwd
6949 1.1 mrg CHARACTER(len=255) :: cwd
6950 1.1 mrg CALL getcwd(cwd)
6951 1.1 mrg WRITE(*,*) TRIM(cwd)
6952 1.1 mrg END PROGRAM
6953 1.1 mrg @end smallexample
6954 1.1 mrg
6955 1.1 mrg @item @emph{See also}:
6956 1.1 mrg @ref{CHDIR}
6957 1.1 mrg @end table
6958 1.1 mrg
6959 1.1 mrg
6960 1.1 mrg
6961 1.1 mrg @node GETENV
6962 1.1 mrg @section @code{GETENV} --- Get an environmental variable
6963 1.1 mrg @fnindex GETENV
6964 1.1 mrg @cindex environment variable
6965 1.1 mrg
6966 1.1 mrg @table @asis
6967 1.1 mrg @item @emph{Description}:
6968 1.1 mrg Get the @var{VALUE} of the environmental variable @var{NAME}.
6969 1.1 mrg
6970 1.1 mrg This intrinsic routine is provided for backwards compatibility with
6971 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
6972 1.1 mrg the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
6973 1.1 mrg 2003 standard.
6974 1.1 mrg
6975 1.1 mrg Note that @code{GETENV} need not be thread-safe. It is the
6976 1.1 mrg responsibility of the user to ensure that the environment is not being
6977 1.1 mrg updated concurrently with a call to the @code{GETENV} intrinsic.
6978 1.1 mrg
6979 1.1 mrg @item @emph{Standard}:
6980 1.1 mrg GNU extension
6981 1.1 mrg
6982 1.1 mrg @item @emph{Class}:
6983 1.1 mrg Subroutine
6984 1.1 mrg
6985 1.1 mrg @item @emph{Syntax}:
6986 1.1 mrg @code{CALL GETENV(NAME, VALUE)}
6987 1.1 mrg
6988 1.1 mrg @item @emph{Arguments}:
6989 1.1 mrg @multitable @columnfractions .15 .70
6990 1.1 mrg @item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind.
6991 1.1 mrg @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
6992 1.1 mrg @end multitable
6993 1.1 mrg
6994 1.1 mrg @item @emph{Return value}:
6995 1.1 mrg Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
6996 1.1 mrg not large enough to hold the data, it is truncated. If @var{NAME}
6997 1.1 mrg is not set, @var{VALUE} will be filled with blanks.
6998 1.1 mrg
6999 1.1 mrg @item @emph{Example}:
7000 1.1 mrg @smallexample
7001 1.1 mrg PROGRAM test_getenv
7002 1.1 mrg CHARACTER(len=255) :: homedir
7003 1.1 mrg CALL getenv("HOME", homedir)
7004 1.1 mrg WRITE (*,*) TRIM(homedir)
7005 1.1 mrg END PROGRAM
7006 1.1 mrg @end smallexample
7007 1.1 mrg
7008 1.1 mrg @item @emph{See also}:
7009 1.1 mrg @ref{GET_ENVIRONMENT_VARIABLE}
7010 1.1 mrg @end table
7011 1.1 mrg
7012 1.1 mrg
7013 1.1 mrg
7014 1.1 mrg @node GET_ENVIRONMENT_VARIABLE
7015 1.1 mrg @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
7016 1.1 mrg @fnindex GET_ENVIRONMENT_VARIABLE
7017 1.1 mrg @cindex environment variable
7018 1.1 mrg
7019 1.1 mrg @table @asis
7020 1.1 mrg @item @emph{Description}:
7021 1.1 mrg Get the @var{VALUE} of the environmental variable @var{NAME}.
7022 1.1 mrg
7023 1.1 mrg Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
7024 1.1 mrg is the responsibility of the user to ensure that the environment is
7025 1.1 mrg not being updated concurrently with a call to the
7026 1.1 mrg @code{GET_ENVIRONMENT_VARIABLE} intrinsic.
7027 1.1 mrg
7028 1.1 mrg @item @emph{Standard}:
7029 1.1 mrg Fortran 2003 and later
7030 1.1 mrg
7031 1.1 mrg @item @emph{Class}:
7032 1.1 mrg Subroutine
7033 1.1 mrg
7034 1.1 mrg @item @emph{Syntax}:
7035 1.1 mrg @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
7036 1.1 mrg
7037 1.1 mrg @item @emph{Arguments}:
7038 1.1 mrg @multitable @columnfractions .15 .70
7039 1.1 mrg @item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER}
7040 1.1 mrg and of default kind.
7041 1.1 mrg @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
7042 1.1 mrg and of default kind.
7043 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7044 1.1 mrg and of default kind.
7045 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7046 1.1 mrg and of default kind.
7047 1.1 mrg @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
7048 1.1 mrg and of default kind.
7049 1.1 mrg @end multitable
7050 1.1 mrg
7051 1.1 mrg @item @emph{Return value}:
7052 1.1 mrg Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
7053 1.1 mrg not large enough to hold the data, it is truncated. If @var{NAME}
7054 1.1 mrg is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
7055 1.1 mrg contains the length needed for storing the environment variable @var{NAME}
7056 1.1 mrg or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
7057 1.1 mrg but too short for the environment variable; it is 1 if the environment
7058 1.1 mrg variable does not exist and 2 if the processor does not support environment
7059 1.1 mrg variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
7060 1.1 mrg present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
7061 1.1 mrg are significant; otherwise they are not part of the environment variable
7062 1.1 mrg name.
7063 1.1 mrg
7064 1.1 mrg @item @emph{Example}:
7065 1.1 mrg @smallexample
7066 1.1 mrg PROGRAM test_getenv
7067 1.1 mrg CHARACTER(len=255) :: homedir
7068 1.1 mrg CALL get_environment_variable("HOME", homedir)
7069 1.1 mrg WRITE (*,*) TRIM(homedir)
7070 1.1 mrg END PROGRAM
7071 1.1 mrg @end smallexample
7072 1.1 mrg @end table
7073 1.1 mrg
7074 1.1 mrg
7075 1.1 mrg
7076 1.1 mrg @node GETGID
7077 1.1 mrg @section @code{GETGID} --- Group ID function
7078 1.1 mrg @fnindex GETGID
7079 1.1 mrg @cindex system, group ID
7080 1.1 mrg
7081 1.1 mrg @table @asis
7082 1.1 mrg @item @emph{Description}:
7083 1.1 mrg Returns the numerical group ID of the current process.
7084 1.1 mrg
7085 1.1 mrg @item @emph{Standard}:
7086 1.1 mrg GNU extension
7087 1.1 mrg
7088 1.1 mrg @item @emph{Class}:
7089 1.1 mrg Function
7090 1.1 mrg
7091 1.1 mrg @item @emph{Syntax}:
7092 1.1 mrg @code{RESULT = GETGID()}
7093 1.1 mrg
7094 1.1 mrg @item @emph{Return value}:
7095 1.1 mrg The return value of @code{GETGID} is an @code{INTEGER} of the default
7096 1.1 mrg kind.
7097 1.1 mrg
7098 1.1 mrg
7099 1.1 mrg @item @emph{Example}:
7100 1.1 mrg See @code{GETPID} for an example.
7101 1.1 mrg
7102 1.1 mrg @item @emph{See also}:
7103 1.1 mrg @ref{GETPID}, @ref{GETUID}
7104 1.1 mrg @end table
7105 1.1 mrg
7106 1.1 mrg
7107 1.1 mrg
7108 1.1 mrg @node GETLOG
7109 1.1 mrg @section @code{GETLOG} --- Get login name
7110 1.1 mrg @fnindex GETLOG
7111 1.1 mrg @cindex system, login name
7112 1.1 mrg @cindex login name
7113 1.1 mrg
7114 1.1 mrg @table @asis
7115 1.1 mrg @item @emph{Description}:
7116 1.1 mrg Gets the username under which the program is running.
7117 1.1 mrg
7118 1.1 mrg @item @emph{Standard}:
7119 1.1 mrg GNU extension
7120 1.1 mrg
7121 1.1 mrg @item @emph{Class}:
7122 1.1 mrg Subroutine
7123 1.1 mrg
7124 1.1 mrg @item @emph{Syntax}:
7125 1.1 mrg @code{CALL GETLOG(C)}
7126 1.1 mrg
7127 1.1 mrg @item @emph{Arguments}:
7128 1.1 mrg @multitable @columnfractions .15 .70
7129 1.1 mrg @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
7130 1.1 mrg @end multitable
7131 1.1 mrg
7132 1.1 mrg @item @emph{Return value}:
7133 1.1 mrg Stores the current user name in @var{LOGIN}. (On systems where POSIX
7134 1.1 mrg functions @code{geteuid} and @code{getpwuid} are not available, and
7135 1.1 mrg the @code{getlogin} function is not implemented either, this will
7136 1.1 mrg return a blank string.)
7137 1.1 mrg
7138 1.1 mrg @item @emph{Example}:
7139 1.1 mrg @smallexample
7140 1.1 mrg PROGRAM TEST_GETLOG
7141 1.1 mrg CHARACTER(32) :: login
7142 1.1 mrg CALL GETLOG(login)
7143 1.1 mrg WRITE(*,*) login
7144 1.1 mrg END PROGRAM
7145 1.1 mrg @end smallexample
7146 1.1 mrg
7147 1.1 mrg @item @emph{See also}:
7148 1.1 mrg @ref{GETUID}
7149 1.1 mrg @end table
7150 1.1 mrg
7151 1.1 mrg
7152 1.1 mrg
7153 1.1 mrg @node GETPID
7154 1.1 mrg @section @code{GETPID} --- Process ID function
7155 1.1 mrg @fnindex GETPID
7156 1.1 mrg @cindex system, process ID
7157 1.1 mrg @cindex process ID
7158 1.1 mrg
7159 1.1 mrg @table @asis
7160 1.1 mrg @item @emph{Description}:
7161 1.1 mrg Returns the numerical process identifier of the current process.
7162 1.1 mrg
7163 1.1 mrg @item @emph{Standard}:
7164 1.1 mrg GNU extension
7165 1.1 mrg
7166 1.1 mrg @item @emph{Class}:
7167 1.1 mrg Function
7168 1.1 mrg
7169 1.1 mrg @item @emph{Syntax}:
7170 1.1 mrg @code{RESULT = GETPID()}
7171 1.1 mrg
7172 1.1 mrg @item @emph{Return value}:
7173 1.1 mrg The return value of @code{GETPID} is an @code{INTEGER} of the default
7174 1.1 mrg kind.
7175 1.1 mrg
7176 1.1 mrg
7177 1.1 mrg @item @emph{Example}:
7178 1.1 mrg @smallexample
7179 1.1 mrg program info
7180 1.1 mrg print *, "The current process ID is ", getpid()
7181 1.1 mrg print *, "Your numerical user ID is ", getuid()
7182 1.1 mrg print *, "Your numerical group ID is ", getgid()
7183 1.1 mrg end program info
7184 1.1 mrg @end smallexample
7185 1.1 mrg
7186 1.1 mrg @item @emph{See also}:
7187 1.1 mrg @ref{GETGID}, @ref{GETUID}
7188 1.1 mrg @end table
7189 1.1 mrg
7190 1.1 mrg
7191 1.1 mrg
7192 1.1 mrg @node GETUID
7193 1.1 mrg @section @code{GETUID} --- User ID function
7194 1.1 mrg @fnindex GETUID
7195 1.1 mrg @cindex system, user ID
7196 1.1 mrg @cindex user id
7197 1.1 mrg
7198 1.1 mrg @table @asis
7199 1.1 mrg @item @emph{Description}:
7200 1.1 mrg Returns the numerical user ID of the current process.
7201 1.1 mrg
7202 1.1 mrg @item @emph{Standard}:
7203 1.1 mrg GNU extension
7204 1.1 mrg
7205 1.1 mrg @item @emph{Class}:
7206 1.1 mrg Function
7207 1.1 mrg
7208 1.1 mrg @item @emph{Syntax}:
7209 1.1 mrg @code{RESULT = GETUID()}
7210 1.1 mrg
7211 1.1 mrg @item @emph{Return value}:
7212 1.1 mrg The return value of @code{GETUID} is an @code{INTEGER} of the default
7213 1.1 mrg kind.
7214 1.1 mrg
7215 1.1 mrg
7216 1.1 mrg @item @emph{Example}:
7217 1.1 mrg See @code{GETPID} for an example.
7218 1.1 mrg
7219 1.1 mrg @item @emph{See also}:
7220 1.1 mrg @ref{GETPID}, @ref{GETLOG}
7221 1.1 mrg @end table
7222 1.1 mrg
7223 1.1 mrg
7224 1.1 mrg
7225 1.1 mrg @node GMTIME
7226 1.1 mrg @section @code{GMTIME} --- Convert time to GMT info
7227 1.1 mrg @fnindex GMTIME
7228 1.1 mrg @cindex time, conversion to GMT info
7229 1.1 mrg
7230 1.1 mrg @table @asis
7231 1.1 mrg @item @emph{Description}:
7232 1.1 mrg Given a system time value @var{TIME} (as provided by the @ref{TIME}
7233 1.1 mrg intrinsic), fills @var{VALUES} with values extracted from it appropriate
7234 1.1 mrg to the UTC time zone (Universal Coordinated Time, also known in some
7235 1.1 mrg countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
7236 1.1 mrg
7237 1.1 mrg This intrinsic routine is provided for backwards compatibility with
7238 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
7239 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
7240 1.1 mrg standard.
7241 1.1 mrg
7242 1.1 mrg @item @emph{Standard}:
7243 1.1 mrg GNU extension
7244 1.1 mrg
7245 1.1 mrg @item @emph{Class}:
7246 1.1 mrg Subroutine
7247 1.1 mrg
7248 1.1 mrg @item @emph{Syntax}:
7249 1.1 mrg @code{CALL GMTIME(TIME, VALUES)}
7250 1.1 mrg
7251 1.1 mrg @item @emph{Arguments}:
7252 1.1 mrg @multitable @columnfractions .15 .70
7253 1.1 mrg @item @var{TIME} @tab An @code{INTEGER} scalar expression
7254 1.1 mrg corresponding to a system time, with @code{INTENT(IN)}.
7255 1.1 mrg @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
7256 1.1 mrg with @code{INTENT(OUT)}.
7257 1.1 mrg @end multitable
7258 1.1 mrg
7259 1.1 mrg @item @emph{Return value}:
7260 1.1 mrg The elements of @var{VALUES} are assigned as follows:
7261 1.1 mrg @enumerate
7262 1.1 mrg @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7263 1.1 mrg seconds
7264 1.1 mrg @item Minutes after the hour, range 0--59
7265 1.1 mrg @item Hours past midnight, range 0--23
7266 1.1 mrg @item Day of month, range 1--31
7267 1.1 mrg @item Number of months since January, range 0--11
7268 1.1 mrg @item Years since 1900
7269 1.1 mrg @item Number of days since Sunday, range 0--6
7270 1.1 mrg @item Days since January 1, range 0--365
7271 1.1 mrg @item Daylight savings indicator: positive if daylight savings is in
7272 1.1 mrg effect, zero if not, and negative if the information is not available.
7273 1.1 mrg @end enumerate
7274 1.1 mrg
7275 1.1 mrg @item @emph{See also}:
7276 1.1 mrg @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
7277 1.1 mrg
7278 1.1 mrg @end table
7279 1.1 mrg
7280 1.1 mrg
7281 1.1 mrg
7282 1.1 mrg @node HOSTNM
7283 1.1 mrg @section @code{HOSTNM} --- Get system host name
7284 1.1 mrg @fnindex HOSTNM
7285 1.1 mrg @cindex system, host name
7286 1.1 mrg
7287 1.1 mrg @table @asis
7288 1.1 mrg @item @emph{Description}:
7289 1.1 mrg Retrieves the host name of the system on which the program is running.
7290 1.1 mrg
7291 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
7292 1.1 mrg only one form can be used in any given program unit.
7293 1.1 mrg
7294 1.1 mrg @item @emph{Standard}:
7295 1.1 mrg GNU extension
7296 1.1 mrg
7297 1.1 mrg @item @emph{Class}:
7298 1.1 mrg Subroutine, function
7299 1.1 mrg
7300 1.1 mrg @item @emph{Syntax}:
7301 1.1 mrg @multitable @columnfractions .80
7302 1.1 mrg @item @code{CALL HOSTNM(C [, STATUS])}
7303 1.1 mrg @item @code{STATUS = HOSTNM(NAME)}
7304 1.1 mrg @end multitable
7305 1.1 mrg
7306 1.1 mrg @item @emph{Arguments}:
7307 1.1 mrg @multitable @columnfractions .15 .70
7308 1.1 mrg @item @var{C} @tab Shall of type @code{CHARACTER} and of default kind.
7309 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
7310 1.1 mrg Returns 0 on success, or a system specific error code otherwise.
7311 1.1 mrg @end multitable
7312 1.1 mrg
7313 1.1 mrg @item @emph{Return value}:
7314 1.1 mrg In either syntax, @var{NAME} is set to the current hostname if it can
7315 1.1 mrg be obtained, or to a blank string otherwise.
7316 1.1 mrg
7317 1.1 mrg @end table
7318 1.1 mrg
7319 1.1 mrg
7320 1.1 mrg
7321 1.1 mrg @node HUGE
7322 1.1 mrg @section @code{HUGE} --- Largest number of a kind
7323 1.1 mrg @fnindex HUGE
7324 1.1 mrg @cindex limits, largest number
7325 1.1 mrg @cindex model representation, largest number
7326 1.1 mrg
7327 1.1 mrg @table @asis
7328 1.1 mrg @item @emph{Description}:
7329 1.1 mrg @code{HUGE(X)} returns the largest number that is not an infinity in
7330 1.1 mrg the model of the type of @code{X}.
7331 1.1 mrg
7332 1.1 mrg @item @emph{Standard}:
7333 1.1 mrg Fortran 95 and later
7334 1.1 mrg
7335 1.1 mrg @item @emph{Class}:
7336 1.1 mrg Inquiry function
7337 1.1 mrg
7338 1.1 mrg @item @emph{Syntax}:
7339 1.1 mrg @code{RESULT = HUGE(X)}
7340 1.1 mrg
7341 1.1 mrg @item @emph{Arguments}:
7342 1.1 mrg @multitable @columnfractions .15 .70
7343 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
7344 1.1 mrg @end multitable
7345 1.1 mrg
7346 1.1 mrg @item @emph{Return value}:
7347 1.1 mrg The return value is of the same type and kind as @var{X}
7348 1.1 mrg
7349 1.1 mrg @item @emph{Example}:
7350 1.1 mrg @smallexample
7351 1.1 mrg program test_huge_tiny
7352 1.1 mrg print *, huge(0), huge(0.0), huge(0.0d0)
7353 1.1 mrg print *, tiny(0.0), tiny(0.0d0)
7354 1.1 mrg end program test_huge_tiny
7355 1.1 mrg @end smallexample
7356 1.1 mrg @end table
7357 1.1 mrg
7358 1.1 mrg
7359 1.1 mrg
7360 1.1 mrg @node HYPOT
7361 1.1 mrg @section @code{HYPOT} --- Euclidean distance function
7362 1.1 mrg @fnindex HYPOT
7363 1.1 mrg @cindex Euclidean distance
7364 1.1 mrg
7365 1.1 mrg @table @asis
7366 1.1 mrg @item @emph{Description}:
7367 1.1 mrg @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
7368 1.1 mrg @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
7369 1.1 mrg
7370 1.1 mrg @item @emph{Standard}:
7371 1.1 mrg Fortran 2008 and later
7372 1.1 mrg
7373 1.1 mrg @item @emph{Class}:
7374 1.1 mrg Elemental function
7375 1.1 mrg
7376 1.1 mrg @item @emph{Syntax}:
7377 1.1 mrg @code{RESULT = HYPOT(X, Y)}
7378 1.1 mrg
7379 1.1 mrg @item @emph{Arguments}:
7380 1.1 mrg @multitable @columnfractions .15 .70
7381 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
7382 1.1 mrg @item @var{Y} @tab The type and kind type parameter shall be the same as
7383 1.1 mrg @var{X}.
7384 1.1 mrg @end multitable
7385 1.1 mrg
7386 1.1 mrg @item @emph{Return value}:
7387 1.1 mrg The return value has the same type and kind type parameter as @var{X}.
7388 1.1 mrg
7389 1.1 mrg @item @emph{Example}:
7390 1.1 mrg @smallexample
7391 1.1 mrg program test_hypot
7392 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4
7393 1.1 mrg x = hypot(x,y)
7394 1.1 mrg end program test_hypot
7395 1.1 mrg @end smallexample
7396 1.1 mrg @end table
7397 1.1 mrg
7398 1.1 mrg
7399 1.1 mrg
7400 1.1 mrg @node IACHAR
7401 1.1 mrg @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
7402 1.1 mrg @fnindex IACHAR
7403 1.1 mrg @cindex @acronym{ASCII} collating sequence
7404 1.1 mrg @cindex collating sequence, @acronym{ASCII}
7405 1.1 mrg @cindex conversion, to integer
7406 1.1 mrg
7407 1.1 mrg @table @asis
7408 1.1 mrg @item @emph{Description}:
7409 1.1 mrg @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
7410 1.1 mrg in the first character position of @code{C}.
7411 1.1 mrg
7412 1.1 mrg @item @emph{Standard}:
7413 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7414 1.1 mrg
7415 1.1 mrg @item @emph{Class}:
7416 1.1 mrg Elemental function
7417 1.1 mrg
7418 1.1 mrg @item @emph{Syntax}:
7419 1.1 mrg @code{RESULT = IACHAR(C [, KIND])}
7420 1.1 mrg
7421 1.1 mrg @item @emph{Arguments}:
7422 1.1 mrg @multitable @columnfractions .15 .70
7423 1.1 mrg @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7424 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7425 1.1 mrg expression indicating the kind parameter of the result.
7426 1.1 mrg @end multitable
7427 1.1 mrg
7428 1.1 mrg @item @emph{Return value}:
7429 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7430 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
7431 1.1 mrg
7432 1.1 mrg @item @emph{Example}:
7433 1.1 mrg @smallexample
7434 1.1 mrg program test_iachar
7435 1.1 mrg integer i
7436 1.1 mrg i = iachar(' ')
7437 1.1 mrg end program test_iachar
7438 1.1 mrg @end smallexample
7439 1.1 mrg
7440 1.1 mrg @item @emph{Note}:
7441 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values
7442 1.1 mrg and formatted string representations.
7443 1.1 mrg
7444 1.1 mrg @item @emph{See also}:
7445 1.1 mrg @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
7446 1.1 mrg
7447 1.1 mrg @end table
7448 1.1 mrg
7449 1.1 mrg
7450 1.1 mrg
7451 1.1 mrg @node IALL
7452 1.1 mrg @section @code{IALL} --- Bitwise AND of array elements
7453 1.1 mrg @fnindex IALL
7454 1.1 mrg @cindex array, AND
7455 1.1 mrg @cindex bits, AND of array elements
7456 1.1 mrg
7457 1.1 mrg @table @asis
7458 1.1 mrg @item @emph{Description}:
7459 1.1 mrg Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
7460 1.1 mrg if the corresponding element in @var{MASK} is @code{TRUE}.
7461 1.1 mrg
7462 1.1 mrg @item @emph{Standard}:
7463 1.1 mrg Fortran 2008 and later
7464 1.1 mrg
7465 1.1 mrg @item @emph{Class}:
7466 1.1 mrg Transformational function
7467 1.1 mrg
7468 1.1 mrg @item @emph{Syntax}:
7469 1.1 mrg @multitable @columnfractions .80
7470 1.1 mrg @item @code{RESULT = IALL(ARRAY[, MASK])}
7471 1.1 mrg @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
7472 1.1 mrg @end multitable
7473 1.1 mrg
7474 1.1 mrg @item @emph{Arguments}:
7475 1.1 mrg @multitable @columnfractions .15 .70
7476 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7477 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
7478 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
7479 1.1 mrg equals the rank of @var{ARRAY}.
7480 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7481 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
7482 1.1 mrg @end multitable
7483 1.1 mrg
7484 1.1 mrg @item @emph{Return value}:
7485 1.1 mrg The result is of the same type as @var{ARRAY}.
7486 1.1 mrg
7487 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
7488 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7489 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7490 1.1 mrg dimension @var{DIM} dropped is returned.
7491 1.1 mrg
7492 1.1 mrg @item @emph{Example}:
7493 1.1 mrg @smallexample
7494 1.1 mrg PROGRAM test_iall
7495 1.1 mrg INTEGER(1) :: a(2)
7496 1.1 mrg
7497 1.1 mrg a(1) = b'00100100'
7498 1.1 mrg a(2) = b'01101010'
7499 1.1 mrg
7500 1.1 mrg ! prints 00100000
7501 1.1 mrg PRINT '(b8.8)', IALL(a)
7502 1.1 mrg END PROGRAM
7503 1.1 mrg @end smallexample
7504 1.1 mrg
7505 1.1 mrg @item @emph{See also}:
7506 1.1 mrg @ref{IANY}, @ref{IPARITY}, @ref{IAND}
7507 1.1 mrg @end table
7508 1.1 mrg
7509 1.1 mrg
7510 1.1 mrg
7511 1.1 mrg @node IAND
7512 1.1 mrg @section @code{IAND} --- Bitwise logical and
7513 1.1 mrg @fnindex IAND
7514 1.1 mrg @fnindex BIAND
7515 1.1 mrg @fnindex IIAND
7516 1.1 mrg @fnindex JIAND
7517 1.1 mrg @fnindex KIAND
7518 1.1 mrg @cindex bitwise logical and
7519 1.1 mrg @cindex logical and, bitwise
7520 1.1 mrg
7521 1.1 mrg @table @asis
7522 1.1 mrg @item @emph{Description}:
7523 1.1 mrg Bitwise logical @code{AND}.
7524 1.1 mrg
7525 1.1 mrg @item @emph{Standard}:
7526 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
7527 1.1 mrg
7528 1.1 mrg @item @emph{Class}:
7529 1.1 mrg Elemental function
7530 1.1 mrg
7531 1.1 mrg @item @emph{Syntax}:
7532 1.1 mrg @code{RESULT = IAND(I, J)}
7533 1.1 mrg
7534 1.1 mrg @item @emph{Arguments}:
7535 1.1 mrg @multitable @columnfractions .15 .70
7536 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
7537 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same
7538 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant.
7539 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants.
7540 1.1 mrg @end multitable
7541 1.1 mrg
7542 1.1 mrg @item @emph{Return value}:
7543 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the
7544 1.1 mrg arguments.
7545 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind
7546 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred.
7547 1.1 mrg
7548 1.1 mrg @item @emph{Example}:
7549 1.1 mrg @smallexample
7550 1.1 mrg PROGRAM test_iand
7551 1.1 mrg INTEGER :: a, b
7552 1.1 mrg DATA a / Z'F' /, b / Z'3' /
7553 1.1 mrg WRITE (*,*) IAND(a, b)
7554 1.1 mrg END PROGRAM
7555 1.1 mrg @end smallexample
7556 1.1 mrg
7557 1.1 mrg @item @emph{Specific names}:
7558 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7559 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7560 1.1 mrg @item @code{IAND(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7561 1.1 mrg @item @code{BIAND(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7562 1.1 mrg @item @code{IIAND(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7563 1.1 mrg @item @code{JIAND(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7564 1.1 mrg @item @code{KIAND(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7565 1.1 mrg @end multitable
7566 1.1 mrg
7567 1.1 mrg @item @emph{See also}:
7568 1.1 mrg @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
7569 1.1 mrg
7570 1.1 mrg @end table
7571 1.1 mrg
7572 1.1 mrg
7573 1.1 mrg
7574 1.1 mrg @node IANY
7575 1.1 mrg @section @code{IANY} --- Bitwise OR of array elements
7576 1.1 mrg @fnindex IANY
7577 1.1 mrg @cindex array, OR
7578 1.1 mrg @cindex bits, OR of array elements
7579 1.1 mrg
7580 1.1 mrg @table @asis
7581 1.1 mrg @item @emph{Description}:
7582 1.1 mrg Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
7583 1.1 mrg dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
7584 1.1 mrg
7585 1.1 mrg @item @emph{Standard}:
7586 1.1 mrg Fortran 2008 and later
7587 1.1 mrg
7588 1.1 mrg @item @emph{Class}:
7589 1.1 mrg Transformational function
7590 1.1 mrg
7591 1.1 mrg @item @emph{Syntax}:
7592 1.1 mrg @multitable @columnfractions .80
7593 1.1 mrg @item @code{RESULT = IANY(ARRAY[, MASK])}
7594 1.1 mrg @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
7595 1.1 mrg @end multitable
7596 1.1 mrg
7597 1.1 mrg @item @emph{Arguments}:
7598 1.1 mrg @multitable @columnfractions .15 .70
7599 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7600 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
7601 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
7602 1.1 mrg equals the rank of @var{ARRAY}.
7603 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7604 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
7605 1.1 mrg @end multitable
7606 1.1 mrg
7607 1.1 mrg @item @emph{Return value}:
7608 1.1 mrg The result is of the same type as @var{ARRAY}.
7609 1.1 mrg
7610 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
7611 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7612 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7613 1.1 mrg dimension @var{DIM} dropped is returned.
7614 1.1 mrg
7615 1.1 mrg @item @emph{Example}:
7616 1.1 mrg @smallexample
7617 1.1 mrg PROGRAM test_iany
7618 1.1 mrg INTEGER(1) :: a(2)
7619 1.1 mrg
7620 1.1 mrg a(1) = b'00100100'
7621 1.1 mrg a(2) = b'01101010'
7622 1.1 mrg
7623 1.1 mrg ! prints 01101110
7624 1.1 mrg PRINT '(b8.8)', IANY(a)
7625 1.1 mrg END PROGRAM
7626 1.1 mrg @end smallexample
7627 1.1 mrg
7628 1.1 mrg @item @emph{See also}:
7629 1.1 mrg @ref{IPARITY}, @ref{IALL}, @ref{IOR}
7630 1.1 mrg @end table
7631 1.1 mrg
7632 1.1 mrg
7633 1.1 mrg
7634 1.1 mrg @node IARGC
7635 1.1 mrg @section @code{IARGC} --- Get the number of command line arguments
7636 1.1 mrg @fnindex IARGC
7637 1.1 mrg @cindex command-line arguments
7638 1.1 mrg @cindex command-line arguments, number of
7639 1.1 mrg @cindex arguments, to program
7640 1.1 mrg
7641 1.1 mrg @table @asis
7642 1.1 mrg @item @emph{Description}:
7643 1.1 mrg @code{IARGC} returns the number of arguments passed on the
7644 1.1 mrg command line when the containing program was invoked.
7645 1.1 mrg
7646 1.1 mrg This intrinsic routine is provided for backwards compatibility with
7647 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
7648 1.1 mrg the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
7649 1.1 mrg standard.
7650 1.1 mrg
7651 1.1 mrg @item @emph{Standard}:
7652 1.1 mrg GNU extension
7653 1.1 mrg
7654 1.1 mrg @item @emph{Class}:
7655 1.1 mrg Function
7656 1.1 mrg
7657 1.1 mrg @item @emph{Syntax}:
7658 1.1 mrg @code{RESULT = IARGC()}
7659 1.1 mrg
7660 1.1 mrg @item @emph{Arguments}:
7661 1.1 mrg None.
7662 1.1 mrg
7663 1.1 mrg @item @emph{Return value}:
7664 1.1 mrg The number of command line arguments, type @code{INTEGER(4)}.
7665 1.1 mrg
7666 1.1 mrg @item @emph{Example}:
7667 1.1 mrg See @ref{GETARG}
7668 1.1 mrg
7669 1.1 mrg @item @emph{See also}:
7670 1.1 mrg GNU Fortran 77 compatibility subroutine: @ref{GETARG}
7671 1.1 mrg
7672 1.1 mrg Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
7673 1.1 mrg @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
7674 1.1 mrg @end table
7675 1.1 mrg
7676 1.1 mrg
7677 1.1 mrg
7678 1.1 mrg @node IBCLR
7679 1.1 mrg @section @code{IBCLR} --- Clear bit
7680 1.1 mrg @fnindex IBCLR
7681 1.1 mrg @fnindex BBCLR
7682 1.1 mrg @fnindex IIBCLR
7683 1.1 mrg @fnindex JIBCLR
7684 1.1 mrg @fnindex KIBCLR
7685 1.1 mrg @cindex bits, unset
7686 1.1 mrg @cindex bits, clear
7687 1.1 mrg
7688 1.1 mrg @table @asis
7689 1.1 mrg @item @emph{Description}:
7690 1.1 mrg @code{IBCLR} returns the value of @var{I} with the bit at position
7691 1.1 mrg @var{POS} set to zero.
7692 1.1 mrg
7693 1.1 mrg @item @emph{Standard}:
7694 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
7695 1.1 mrg
7696 1.1 mrg @item @emph{Class}:
7697 1.1 mrg Elemental function
7698 1.1 mrg
7699 1.1 mrg @item @emph{Syntax}:
7700 1.1 mrg @code{RESULT = IBCLR(I, POS)}
7701 1.1 mrg
7702 1.1 mrg @item @emph{Arguments}:
7703 1.1 mrg @multitable @columnfractions .15 .70
7704 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
7705 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}.
7706 1.1 mrg @end multitable
7707 1.1 mrg
7708 1.1 mrg @item @emph{Return value}:
7709 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
7710 1.1 mrg @var{I}.
7711 1.1 mrg
7712 1.1 mrg @item @emph{Specific names}:
7713 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7714 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7715 1.1 mrg @item @code{IBCLR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7716 1.1 mrg @item @code{BBCLR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7717 1.1 mrg @item @code{IIBCLR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7718 1.1 mrg @item @code{JIBCLR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7719 1.1 mrg @item @code{KIBCLR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7720 1.1 mrg @end multitable
7721 1.1 mrg
7722 1.1 mrg @item @emph{See also}:
7723 1.1 mrg @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
7724 1.1 mrg
7725 1.1 mrg @end table
7726 1.1 mrg
7727 1.1 mrg
7728 1.1 mrg
7729 1.1 mrg @node IBITS
7730 1.1 mrg @section @code{IBITS} --- Bit extraction
7731 1.1 mrg @fnindex IBITS
7732 1.1 mrg @fnindex BBITS
7733 1.1 mrg @fnindex IIBITS
7734 1.1 mrg @fnindex JIBITS
7735 1.1 mrg @fnindex KIBITS
7736 1.1 mrg @cindex bits, get
7737 1.1 mrg @cindex bits, extract
7738 1.1 mrg
7739 1.1 mrg @table @asis
7740 1.1 mrg @item @emph{Description}:
7741 1.1 mrg @code{IBITS} extracts a field of length @var{LEN} from @var{I},
7742 1.1 mrg starting from bit position @var{POS} and extending left for @var{LEN}
7743 1.1 mrg bits. The result is right-justified and the remaining bits are
7744 1.1 mrg zeroed. The value of @code{POS+LEN} must be less than or equal to the
7745 1.1 mrg value @code{BIT_SIZE(I)}.
7746 1.1 mrg
7747 1.1 mrg @item @emph{Standard}:
7748 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
7749 1.1 mrg
7750 1.1 mrg @item @emph{Class}:
7751 1.1 mrg Elemental function
7752 1.1 mrg
7753 1.1 mrg @item @emph{Syntax}:
7754 1.1 mrg @code{RESULT = IBITS(I, POS, LEN)}
7755 1.1 mrg
7756 1.1 mrg @item @emph{Arguments}:
7757 1.1 mrg @multitable @columnfractions .15 .70
7758 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
7759 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}.
7760 1.1 mrg @item @var{LEN} @tab The type shall be @code{INTEGER}.
7761 1.1 mrg @end multitable
7762 1.1 mrg
7763 1.1 mrg @item @emph{Return value}:
7764 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
7765 1.1 mrg @var{I}.
7766 1.1 mrg
7767 1.1 mrg @item @emph{Specific names}:
7768 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7769 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7770 1.1 mrg @item @code{IBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7771 1.1 mrg @item @code{BBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7772 1.1 mrg @item @code{IIBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7773 1.1 mrg @item @code{JIBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7774 1.1 mrg @item @code{KIBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7775 1.1 mrg @end multitable
7776 1.1 mrg
7777 1.1 mrg @item @emph{See also}:
7778 1.1 mrg @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
7779 1.1 mrg @end table
7780 1.1 mrg
7781 1.1 mrg
7782 1.1 mrg
7783 1.1 mrg @node IBSET
7784 1.1 mrg @section @code{IBSET} --- Set bit
7785 1.1 mrg @fnindex IBSET
7786 1.1 mrg @fnindex BBSET
7787 1.1 mrg @fnindex IIBSET
7788 1.1 mrg @fnindex JIBSET
7789 1.1 mrg @fnindex KIBSET
7790 1.1 mrg @cindex bits, set
7791 1.1 mrg
7792 1.1 mrg @table @asis
7793 1.1 mrg @item @emph{Description}:
7794 1.1 mrg @code{IBSET} returns the value of @var{I} with the bit at position
7795 1.1 mrg @var{POS} set to one.
7796 1.1 mrg
7797 1.1 mrg @item @emph{Standard}:
7798 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
7799 1.1 mrg
7800 1.1 mrg @item @emph{Class}:
7801 1.1 mrg Elemental function
7802 1.1 mrg
7803 1.1 mrg @item @emph{Syntax}:
7804 1.1 mrg @code{RESULT = IBSET(I, POS)}
7805 1.1 mrg
7806 1.1 mrg @item @emph{Arguments}:
7807 1.1 mrg @multitable @columnfractions .15 .70
7808 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
7809 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}.
7810 1.1 mrg @end multitable
7811 1.1 mrg
7812 1.1 mrg @item @emph{Return value}:
7813 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
7814 1.1 mrg @var{I}.
7815 1.1 mrg
7816 1.1 mrg @item @emph{Specific names}:
7817 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7818 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7819 1.1 mrg @item @code{IBSET(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7820 1.1 mrg @item @code{BBSET(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7821 1.1 mrg @item @code{IIBSET(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7822 1.1 mrg @item @code{JIBSET(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7823 1.1 mrg @item @code{KIBSET(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7824 1.1 mrg @end multitable
7825 1.1 mrg
7826 1.1 mrg @item @emph{See also}:
7827 1.1 mrg @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
7828 1.1 mrg
7829 1.1 mrg @end table
7830 1.1 mrg
7831 1.1 mrg
7832 1.1 mrg
7833 1.1 mrg @node ICHAR
7834 1.1 mrg @section @code{ICHAR} --- Character-to-integer conversion function
7835 1.1 mrg @fnindex ICHAR
7836 1.1 mrg @cindex conversion, to integer
7837 1.1 mrg
7838 1.1 mrg @table @asis
7839 1.1 mrg @item @emph{Description}:
7840 1.1 mrg @code{ICHAR(C)} returns the code for the character in the first character
7841 1.1 mrg position of @code{C} in the system's native character set.
7842 1.1 mrg The correspondence between characters and their codes is not necessarily
7843 1.1 mrg the same across different GNU Fortran implementations.
7844 1.1 mrg
7845 1.1 mrg @item @emph{Standard}:
7846 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7847 1.1 mrg
7848 1.1 mrg @item @emph{Class}:
7849 1.1 mrg Elemental function
7850 1.1 mrg
7851 1.1 mrg @item @emph{Syntax}:
7852 1.1 mrg @code{RESULT = ICHAR(C [, KIND])}
7853 1.1 mrg
7854 1.1 mrg @item @emph{Arguments}:
7855 1.1 mrg @multitable @columnfractions .15 .70
7856 1.1 mrg @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7857 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7858 1.1 mrg expression indicating the kind parameter of the result.
7859 1.1 mrg @end multitable
7860 1.1 mrg
7861 1.1 mrg @item @emph{Return value}:
7862 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7863 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
7864 1.1 mrg
7865 1.1 mrg @item @emph{Example}:
7866 1.1 mrg @smallexample
7867 1.1 mrg program test_ichar
7868 1.1 mrg integer i
7869 1.1 mrg i = ichar(' ')
7870 1.1 mrg end program test_ichar
7871 1.1 mrg @end smallexample
7872 1.1 mrg
7873 1.1 mrg @item @emph{Specific names}:
7874 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
7875 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
7876 1.1 mrg @item @code{ICHAR(C)} @tab @code{CHARACTER C} @tab @code{INTEGER(4)} @tab Fortran 77 and later
7877 1.1 mrg @end multitable
7878 1.1 mrg
7879 1.1 mrg @item @emph{Note}:
7880 1.1 mrg No intrinsic exists to convert between a numeric value and a formatted
7881 1.1 mrg character string representation -- for instance, given the
7882 1.1 mrg @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
7883 1.1 mrg @code{REAL} value with the value 154, or vice versa. Instead, this
7884 1.1 mrg functionality is provided by internal-file I/O, as in the following
7885 1.1 mrg example:
7886 1.1 mrg @smallexample
7887 1.1 mrg program read_val
7888 1.1 mrg integer value
7889 1.1 mrg character(len=10) string, string2
7890 1.1 mrg string = '154'
7891 1.1 mrg
7892 1.1 mrg ! Convert a string to a numeric value
7893 1.1 mrg read (string,'(I10)') value
7894 1.1 mrg print *, value
7895 1.1 mrg
7896 1.1 mrg ! Convert a value to a formatted string
7897 1.1 mrg write (string2,'(I10)') value
7898 1.1 mrg print *, string2
7899 1.1 mrg end program read_val
7900 1.1 mrg @end smallexample
7901 1.1 mrg
7902 1.1 mrg @item @emph{See also}:
7903 1.1 mrg @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
7904 1.1 mrg
7905 1.1 mrg @end table
7906 1.1 mrg
7907 1.1 mrg
7908 1.1 mrg
7909 1.1 mrg @node IDATE
7910 1.1 mrg @section @code{IDATE} --- Get current local time subroutine (day/month/year)
7911 1.1 mrg @fnindex IDATE
7912 1.1 mrg @cindex date, current
7913 1.1 mrg @cindex current date
7914 1.1 mrg
7915 1.1 mrg @table @asis
7916 1.1 mrg @item @emph{Description}:
7917 1.1 mrg @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
7918 1.1 mrg current local time. The day (in the range 1-31), month (in the range 1-12),
7919 1.1 mrg and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively.
7920 1.1 mrg The year has four significant digits.
7921 1.1 mrg
7922 1.1 mrg This intrinsic routine is provided for backwards compatibility with
7923 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
7924 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
7925 1.1 mrg standard.
7926 1.1 mrg
7927 1.1 mrg @item @emph{Standard}:
7928 1.1 mrg GNU extension
7929 1.1 mrg
7930 1.1 mrg @item @emph{Class}:
7931 1.1 mrg Subroutine
7932 1.1 mrg
7933 1.1 mrg @item @emph{Syntax}:
7934 1.1 mrg @code{CALL IDATE(VALUES)}
7935 1.1 mrg
7936 1.1 mrg @item @emph{Arguments}:
7937 1.1 mrg @multitable @columnfractions .15 .70
7938 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
7939 1.1 mrg the kind shall be the default integer kind.
7940 1.1 mrg @end multitable
7941 1.1 mrg
7942 1.1 mrg @item @emph{Return value}:
7943 1.1 mrg Does not return anything.
7944 1.1 mrg
7945 1.1 mrg @item @emph{Example}:
7946 1.1 mrg @smallexample
7947 1.1 mrg program test_idate
7948 1.1 mrg integer, dimension(3) :: tarray
7949 1.1 mrg call idate(tarray)
7950 1.1 mrg print *, tarray(1)
7951 1.1 mrg print *, tarray(2)
7952 1.1 mrg print *, tarray(3)
7953 1.1 mrg end program test_idate
7954 1.1 mrg @end smallexample
7955 1.1 mrg
7956 1.1 mrg @item @emph{See also}:
7957 1.1 mrg @ref{DATE_AND_TIME}
7958 1.1 mrg @end table
7959 1.1 mrg
7960 1.1 mrg
7961 1.1 mrg @node IEOR
7962 1.1 mrg @section @code{IEOR} --- Bitwise logical exclusive or
7963 1.1 mrg @fnindex IEOR
7964 1.1 mrg @fnindex BIEOR
7965 1.1 mrg @fnindex IIEOR
7966 1.1 mrg @fnindex JIEOR
7967 1.1 mrg @fnindex KIEOR
7968 1.1 mrg @cindex bitwise logical exclusive or
7969 1.1 mrg @cindex logical exclusive or, bitwise
7970 1.1 mrg
7971 1.1 mrg @table @asis
7972 1.1 mrg @item @emph{Description}:
7973 1.1 mrg @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
7974 1.1 mrg @var{J}.
7975 1.1 mrg
7976 1.1 mrg @item @emph{Standard}:
7977 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
7978 1.1 mrg
7979 1.1 mrg @item @emph{Class}:
7980 1.1 mrg Elemental function
7981 1.1 mrg
7982 1.1 mrg @item @emph{Syntax}:
7983 1.1 mrg @code{RESULT = IEOR(I, J)}
7984 1.1 mrg
7985 1.1 mrg @item @emph{Arguments}:
7986 1.1 mrg @multitable @columnfractions .15 .70
7987 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
7988 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same
7989 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant.
7990 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants.
7991 1.1 mrg @end multitable
7992 1.1 mrg
7993 1.1 mrg @item @emph{Return value}:
7994 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the
7995 1.1 mrg arguments.
7996 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind
7997 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred.
7998 1.1 mrg
7999 1.1 mrg @item @emph{Specific names}:
8000 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8001 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8002 1.1 mrg @item @code{IEOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8003 1.1 mrg @item @code{BIEOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8004 1.1 mrg @item @code{IIEOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8005 1.1 mrg @item @code{JIEOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8006 1.1 mrg @item @code{KIEOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8007 1.1 mrg @end multitable
8008 1.1 mrg
8009 1.1 mrg @item @emph{See also}:
8010 1.1 mrg @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
8011 1.1 mrg @end table
8012 1.1 mrg
8013 1.1 mrg
8014 1.1 mrg
8015 1.1 mrg @node IERRNO
8016 1.1 mrg @section @code{IERRNO} --- Get the last system error number
8017 1.1 mrg @fnindex IERRNO
8018 1.1 mrg @cindex system, error handling
8019 1.1 mrg
8020 1.1 mrg @table @asis
8021 1.1 mrg @item @emph{Description}:
8022 1.1 mrg Returns the last system error number, as given by the C @code{errno}
8023 1.1 mrg variable.
8024 1.1 mrg
8025 1.1 mrg @item @emph{Standard}:
8026 1.1 mrg GNU extension
8027 1.1 mrg
8028 1.1 mrg @item @emph{Class}:
8029 1.1 mrg Function
8030 1.1 mrg
8031 1.1 mrg @item @emph{Syntax}:
8032 1.1 mrg @code{RESULT = IERRNO()}
8033 1.1 mrg
8034 1.1 mrg @item @emph{Arguments}:
8035 1.1 mrg None.
8036 1.1 mrg
8037 1.1 mrg @item @emph{Return value}:
8038 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
8039 1.1 mrg kind.
8040 1.1 mrg
8041 1.1 mrg @item @emph{See also}:
8042 1.1 mrg @ref{PERROR}
8043 1.1 mrg @end table
8044 1.1 mrg
8045 1.1 mrg
8046 1.1 mrg
8047 1.1 mrg @node IMAGE_INDEX
8048 1.1 mrg @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
8049 1.1 mrg @fnindex IMAGE_INDEX
8050 1.1 mrg @cindex coarray, @code{IMAGE_INDEX}
8051 1.1 mrg @cindex images, cosubscript to image index conversion
8052 1.1 mrg
8053 1.1 mrg @table @asis
8054 1.1 mrg @item @emph{Description}:
8055 1.1 mrg Returns the image index belonging to a cosubscript.
8056 1.1 mrg
8057 1.1 mrg @item @emph{Standard}:
8058 1.1 mrg Fortran 2008 and later
8059 1.1 mrg
8060 1.1 mrg @item @emph{Class}:
8061 1.1 mrg Inquiry function.
8062 1.1 mrg
8063 1.1 mrg @item @emph{Syntax}:
8064 1.1 mrg @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
8065 1.1 mrg
8066 1.1 mrg @item @emph{Arguments}: None.
8067 1.1 mrg @multitable @columnfractions .15 .70
8068 1.1 mrg @item @var{COARRAY} @tab Coarray of any type.
8069 1.1 mrg @item @var{SUB} @tab default integer rank-1 array of a size equal to
8070 1.1 mrg the corank of @var{COARRAY}.
8071 1.1 mrg @end multitable
8072 1.1 mrg
8073 1.1 mrg
8074 1.1 mrg @item @emph{Return value}:
8075 1.1 mrg Scalar default integer with the value of the image index which corresponds
8076 1.1 mrg to the cosubscripts. For invalid cosubscripts the result is zero.
8077 1.1 mrg
8078 1.1 mrg @item @emph{Example}:
8079 1.1 mrg @smallexample
8080 1.1 mrg INTEGER :: array[2,-1:4,8,*]
8081 1.1 mrg ! Writes 28 (or 0 if there are fewer than 28 images)
8082 1.1 mrg WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
8083 1.1 mrg @end smallexample
8084 1.1 mrg
8085 1.1 mrg @item @emph{See also}:
8086 1.1 mrg @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
8087 1.1 mrg @end table
8088 1.1 mrg
8089 1.1 mrg
8090 1.1 mrg
8091 1.1 mrg @node INDEX intrinsic
8092 1.1 mrg @section @code{INDEX} --- Position of a substring within a string
8093 1.1 mrg @fnindex INDEX
8094 1.1 mrg @cindex substring position
8095 1.1 mrg @cindex string, find substring
8096 1.1 mrg
8097 1.1 mrg @table @asis
8098 1.1 mrg @item @emph{Description}:
8099 1.1 mrg Returns the position of the start of the first occurrence of string
8100 1.1 mrg @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
8101 1.1 mrg @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
8102 1.1 mrg the @var{BACK} argument is present and true, the return value is the
8103 1.1 mrg start of the last occurrence rather than the first.
8104 1.1 mrg
8105 1.1 mrg @item @emph{Standard}:
8106 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8107 1.1 mrg
8108 1.1 mrg @item @emph{Class}:
8109 1.1 mrg Elemental function
8110 1.1 mrg
8111 1.1 mrg @item @emph{Syntax}:
8112 1.1 mrg @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
8113 1.1 mrg
8114 1.1 mrg @item @emph{Arguments}:
8115 1.1 mrg @multitable @columnfractions .15 .70
8116 1.1 mrg @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
8117 1.1 mrg @code{INTENT(IN)}
8118 1.1 mrg @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
8119 1.1 mrg @code{INTENT(IN)}
8120 1.1 mrg @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
8121 1.1 mrg @code{INTENT(IN)}
8122 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8123 1.1 mrg expression indicating the kind parameter of the result.
8124 1.1 mrg @end multitable
8125 1.1 mrg
8126 1.1 mrg @item @emph{Return value}:
8127 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8128 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
8129 1.1 mrg
8130 1.1 mrg @item @emph{Specific names}:
8131 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8132 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8133 1.1 mrg @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8134 1.1 mrg @end multitable
8135 1.1 mrg
8136 1.1 mrg @item @emph{See also}:
8137 1.1 mrg @ref{SCAN}, @ref{VERIFY}
8138 1.1 mrg @end table
8139 1.1 mrg
8140 1.1 mrg
8141 1.1 mrg
8142 1.1 mrg @node INT
8143 1.1 mrg @section @code{INT} --- Convert to integer type
8144 1.1 mrg @fnindex INT
8145 1.1 mrg @fnindex IFIX
8146 1.1 mrg @fnindex IDINT
8147 1.1 mrg @cindex conversion, to integer
8148 1.1 mrg
8149 1.1 mrg @table @asis
8150 1.1 mrg @item @emph{Description}:
8151 1.1 mrg Convert to integer type
8152 1.1 mrg
8153 1.1 mrg @item @emph{Standard}:
8154 1.1 mrg Fortran 77 and later
8155 1.1 mrg
8156 1.1 mrg @item @emph{Class}:
8157 1.1 mrg Elemental function
8158 1.1 mrg
8159 1.1 mrg @item @emph{Syntax}:
8160 1.1 mrg @code{RESULT = INT(A [, KIND))}
8161 1.1 mrg
8162 1.1 mrg @item @emph{Arguments}:
8163 1.1 mrg @multitable @columnfractions .15 .70
8164 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER},
8165 1.1 mrg @code{REAL}, or @code{COMPLEX}.
8166 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8167 1.1 mrg expression indicating the kind parameter of the result.
8168 1.1 mrg @end multitable
8169 1.1 mrg
8170 1.1 mrg @item @emph{Return value}:
8171 1.1 mrg These functions return a @code{INTEGER} variable or array under
8172 1.1 mrg the following rules:
8173 1.1 mrg
8174 1.1 mrg @table @asis
8175 1.1 mrg @item (A)
8176 1.1 mrg If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
8177 1.1 mrg @item (B)
8178 1.1 mrg If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)}
8179 1.1 mrg equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer
8180 1.1 mrg whose magnitude is the largest integer that does not exceed the magnitude
8181 1.1 mrg of @var{A} and whose sign is the same as the sign of @var{A}.
8182 1.1 mrg @item (C)
8183 1.1 mrg If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
8184 1.1 mrg @end table
8185 1.1 mrg
8186 1.1 mrg @item @emph{Example}:
8187 1.1 mrg @smallexample
8188 1.1 mrg program test_int
8189 1.1 mrg integer :: i = 42
8190 1.1 mrg complex :: z = (-3.7, 1.0)
8191 1.1 mrg print *, int(i)
8192 1.1 mrg print *, int(z), int(z,8)
8193 1.1 mrg end program
8194 1.1 mrg @end smallexample
8195 1.1 mrg
8196 1.1 mrg @item @emph{Specific names}:
8197 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8198 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8199 1.1 mrg @item @code{INT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8200 1.1 mrg @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8201 1.1 mrg @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
8202 1.1 mrg @end multitable
8203 1.1 mrg
8204 1.1 mrg @end table
8205 1.1 mrg
8206 1.1 mrg
8207 1.1 mrg @node INT2
8208 1.1 mrg @section @code{INT2} --- Convert to 16-bit integer type
8209 1.1 mrg @fnindex INT2
8210 1.1 mrg @fnindex SHORT
8211 1.1 mrg @cindex conversion, to integer
8212 1.1 mrg
8213 1.1 mrg @table @asis
8214 1.1 mrg @item @emph{Description}:
8215 1.1 mrg Convert to a @code{KIND=2} integer type. This is equivalent to the
8216 1.1 mrg standard @code{INT} intrinsic with an optional argument of
8217 1.1 mrg @code{KIND=2}, and is only included for backwards compatibility.
8218 1.1 mrg
8219 1.1 mrg The @code{SHORT} intrinsic is equivalent to @code{INT2}.
8220 1.1 mrg
8221 1.1 mrg @item @emph{Standard}:
8222 1.1 mrg GNU extension
8223 1.1 mrg
8224 1.1 mrg @item @emph{Class}:
8225 1.1 mrg Elemental function
8226 1.1 mrg
8227 1.1 mrg @item @emph{Syntax}:
8228 1.1 mrg @code{RESULT = INT2(A)}
8229 1.1 mrg
8230 1.1 mrg @item @emph{Arguments}:
8231 1.1 mrg @multitable @columnfractions .15 .70
8232 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER},
8233 1.1 mrg @code{REAL}, or @code{COMPLEX}.
8234 1.1 mrg @end multitable
8235 1.1 mrg
8236 1.1 mrg @item @emph{Return value}:
8237 1.1 mrg The return value is a @code{INTEGER(2)} variable.
8238 1.1 mrg
8239 1.1 mrg @item @emph{See also}:
8240 1.1 mrg @ref{INT}, @ref{INT8}, @ref{LONG}
8241 1.1 mrg @end table
8242 1.1 mrg
8243 1.1 mrg
8244 1.1 mrg
8245 1.1 mrg @node INT8
8246 1.1 mrg @section @code{INT8} --- Convert to 64-bit integer type
8247 1.1 mrg @fnindex INT8
8248 1.1 mrg @cindex conversion, to integer
8249 1.1 mrg
8250 1.1 mrg @table @asis
8251 1.1 mrg @item @emph{Description}:
8252 1.1 mrg Convert to a @code{KIND=8} integer type. This is equivalent to the
8253 1.1 mrg standard @code{INT} intrinsic with an optional argument of
8254 1.1 mrg @code{KIND=8}, and is only included for backwards compatibility.
8255 1.1 mrg
8256 1.1 mrg @item @emph{Standard}:
8257 1.1 mrg GNU extension
8258 1.1 mrg
8259 1.1 mrg @item @emph{Class}:
8260 1.1 mrg Elemental function
8261 1.1 mrg
8262 1.1 mrg @item @emph{Syntax}:
8263 1.1 mrg @code{RESULT = INT8(A)}
8264 1.1 mrg
8265 1.1 mrg @item @emph{Arguments}:
8266 1.1 mrg @multitable @columnfractions .15 .70
8267 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER},
8268 1.1 mrg @code{REAL}, or @code{COMPLEX}.
8269 1.1 mrg @end multitable
8270 1.1 mrg
8271 1.1 mrg @item @emph{Return value}:
8272 1.1 mrg The return value is a @code{INTEGER(8)} variable.
8273 1.1 mrg
8274 1.1 mrg @item @emph{See also}:
8275 1.1 mrg @ref{INT}, @ref{INT2}, @ref{LONG}
8276 1.1 mrg @end table
8277 1.1 mrg
8278 1.1 mrg
8279 1.1 mrg
8280 1.1 mrg @node IOR
8281 1.1 mrg @section @code{IOR} --- Bitwise logical or
8282 1.1 mrg @fnindex IOR
8283 1.1 mrg @fnindex BIOR
8284 1.1 mrg @fnindex IIOR
8285 1.1 mrg @fnindex JIOR
8286 1.1 mrg @fnindex KIOR
8287 1.1 mrg @cindex bitwise logical or
8288 1.1 mrg @cindex logical or, bitwise
8289 1.1 mrg
8290 1.1 mrg @table @asis
8291 1.1 mrg @item @emph{Description}:
8292 1.1 mrg @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
8293 1.1 mrg @var{J}.
8294 1.1 mrg
8295 1.1 mrg @item @emph{Standard}:
8296 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
8297 1.1 mrg
8298 1.1 mrg @item @emph{Class}:
8299 1.1 mrg Elemental function
8300 1.1 mrg
8301 1.1 mrg @item @emph{Syntax}:
8302 1.1 mrg @code{RESULT = IOR(I, J)}
8303 1.1 mrg
8304 1.1 mrg @item @emph{Arguments}:
8305 1.1 mrg @multitable @columnfractions .15 .70
8306 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
8307 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same
8308 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant.
8309 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants.
8310 1.1 mrg @end multitable
8311 1.1 mrg
8312 1.1 mrg @item @emph{Return value}:
8313 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the
8314 1.1 mrg arguments.
8315 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind
8316 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred.
8317 1.1 mrg
8318 1.1 mrg @item @emph{Specific names}:
8319 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8320 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8321 1.1 mrg @item @code{IOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8322 1.1 mrg @item @code{BIOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8323 1.1 mrg @item @code{IIOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8324 1.1 mrg @item @code{JIOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8325 1.1 mrg @item @code{KIOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8326 1.1 mrg @end multitable
8327 1.1 mrg
8328 1.1 mrg @item @emph{See also}:
8329 1.1 mrg @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
8330 1.1 mrg @end table
8331 1.1 mrg
8332 1.1 mrg
8333 1.1 mrg
8334 1.1 mrg @node IPARITY
8335 1.1 mrg @section @code{IPARITY} --- Bitwise XOR of array elements
8336 1.1 mrg @fnindex IPARITY
8337 1.1 mrg @cindex array, parity
8338 1.1 mrg @cindex array, XOR
8339 1.1 mrg @cindex bits, XOR of array elements
8340 1.1 mrg
8341 1.1 mrg @table @asis
8342 1.1 mrg @item @emph{Description}:
8343 1.1 mrg Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
8344 1.1 mrg dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
8345 1.1 mrg
8346 1.1 mrg @item @emph{Standard}:
8347 1.1 mrg Fortran 2008 and later
8348 1.1 mrg
8349 1.1 mrg @item @emph{Class}:
8350 1.1 mrg Transformational function
8351 1.1 mrg
8352 1.1 mrg @item @emph{Syntax}:
8353 1.1 mrg @multitable @columnfractions .80
8354 1.1 mrg @item @code{RESULT = IPARITY(ARRAY[, MASK])}
8355 1.1 mrg @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
8356 1.1 mrg @end multitable
8357 1.1 mrg
8358 1.1 mrg @item @emph{Arguments}:
8359 1.1 mrg @multitable @columnfractions .15 .70
8360 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
8361 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
8362 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
8363 1.1 mrg equals the rank of @var{ARRAY}.
8364 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
8365 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
8366 1.1 mrg @end multitable
8367 1.1 mrg
8368 1.1 mrg @item @emph{Return value}:
8369 1.1 mrg The result is of the same type as @var{ARRAY}.
8370 1.1 mrg
8371 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
8372 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
8373 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
8374 1.1 mrg dimension @var{DIM} dropped is returned.
8375 1.1 mrg
8376 1.1 mrg @item @emph{Example}:
8377 1.1 mrg @smallexample
8378 1.1 mrg PROGRAM test_iparity
8379 1.1 mrg INTEGER(1) :: a(2)
8380 1.1 mrg
8381 1.1 mrg a(1) = b'00100100'
8382 1.1 mrg a(2) = b'01101010'
8383 1.1 mrg
8384 1.1 mrg ! prints 01001110
8385 1.1 mrg PRINT '(b8.8)', IPARITY(a)
8386 1.1 mrg END PROGRAM
8387 1.1 mrg @end smallexample
8388 1.1 mrg
8389 1.1 mrg @item @emph{See also}:
8390 1.1 mrg @ref{IANY}, @ref{IALL}, @ref{IEOR}, @ref{PARITY}
8391 1.1 mrg @end table
8392 1.1 mrg
8393 1.1 mrg
8394 1.1 mrg
8395 1.1 mrg @node IRAND
8396 1.1 mrg @section @code{IRAND} --- Integer pseudo-random number
8397 1.1 mrg @fnindex IRAND
8398 1.1 mrg @cindex random number generation
8399 1.1 mrg
8400 1.1 mrg @table @asis
8401 1.1 mrg @item @emph{Description}:
8402 1.1 mrg @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
8403 1.1 mrg distribution between 0 and a system-dependent limit (which is in most
8404 1.1 mrg cases 2147483647). If @var{FLAG} is 0, the next number
8405 1.1 mrg in the current sequence is returned; if @var{FLAG} is 1, the generator
8406 1.1 mrg is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8407 1.1 mrg it is used as a new seed with @code{SRAND}.
8408 1.1 mrg
8409 1.1 mrg This intrinsic routine is provided for backwards compatibility with
8410 1.1 mrg GNU Fortran 77. It implements a simple modulo generator as provided
8411 1.1 mrg by @command{g77}. For new code, one should consider the use of
8412 1.1 mrg @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8413 1.1 mrg
8414 1.1 mrg @item @emph{Standard}:
8415 1.1 mrg GNU extension
8416 1.1 mrg
8417 1.1 mrg @item @emph{Class}:
8418 1.1 mrg Function
8419 1.1 mrg
8420 1.1 mrg @item @emph{Syntax}:
8421 1.1 mrg @code{RESULT = IRAND(I)}
8422 1.1 mrg
8423 1.1 mrg @item @emph{Arguments}:
8424 1.1 mrg @multitable @columnfractions .15 .70
8425 1.1 mrg @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
8426 1.1 mrg @end multitable
8427 1.1 mrg
8428 1.1 mrg @item @emph{Return value}:
8429 1.1 mrg The return value is of @code{INTEGER(kind=4)} type.
8430 1.1 mrg
8431 1.1 mrg @item @emph{Example}:
8432 1.1 mrg @smallexample
8433 1.1 mrg program test_irand
8434 1.1 mrg integer,parameter :: seed = 86456
8435 1.1 mrg
8436 1.1 mrg call srand(seed)
8437 1.1 mrg print *, irand(), irand(), irand(), irand()
8438 1.1 mrg print *, irand(seed), irand(), irand(), irand()
8439 1.1 mrg end program test_irand
8440 1.1 mrg @end smallexample
8441 1.1 mrg
8442 1.1 mrg @end table
8443 1.1 mrg
8444 1.1 mrg
8445 1.1 mrg
8446 1.1 mrg @node IS_CONTIGUOUS
8447 1.1 mrg @section @code{IS_CONTIGUOUS} --- Test whether an array is contiguous
8448 1.1 mrg @fnindex IS_IOSTAT_EOR
8449 1.1 mrg @cindex array, contiguity
8450 1.1 mrg
8451 1.1 mrg @table @asis
8452 1.1 mrg @item @emph{Description}:
8453 1.1 mrg @code{IS_CONTIGUOUS} tests whether an array is contiguous.
8454 1.1 mrg
8455 1.1 mrg @item @emph{Standard}:
8456 1.1 mrg Fortran 2008 and later
8457 1.1 mrg
8458 1.1 mrg @item @emph{Class}:
8459 1.1 mrg Inquiry function
8460 1.1 mrg
8461 1.1 mrg @item @emph{Syntax}:
8462 1.1 mrg @code{RESULT = IS_CONTIGUOUS(ARRAY)}
8463 1.1 mrg
8464 1.1 mrg @item @emph{Arguments}:
8465 1.1 mrg @multitable @columnfractions .15 .70
8466 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type.
8467 1.1 mrg @end multitable
8468 1.1 mrg
8469 1.1 mrg @item @emph{Return value}:
8470 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8471 1.1 mrg @var{ARRAY} is contiguous and false otherwise.
8472 1.1 mrg
8473 1.1 mrg @item @emph{Example}:
8474 1.1 mrg @smallexample
8475 1.1 mrg program test
8476 1.1 mrg integer :: a(10)
8477 1.1 mrg a = [1,2,3,4,5,6,7,8,9,10]
8478 1.1 mrg call sub (a) ! every element, is contiguous
8479 1.1 mrg call sub (a(::2)) ! every other element, is noncontiguous
8480 1.1 mrg contains
8481 1.1 mrg subroutine sub (x)
8482 1.1 mrg integer :: x(:)
8483 1.1 mrg if (is_contiguous (x)) then
8484 1.1 mrg write (*,*) 'X is contiguous'
8485 1.1 mrg else
8486 1.1 mrg write (*,*) 'X is not contiguous'
8487 1.1 mrg end if
8488 1.1 mrg end subroutine sub
8489 1.1 mrg end program test
8490 1.1 mrg @end smallexample
8491 1.1 mrg @end table
8492 1.1 mrg
8493 1.1 mrg
8494 1.1 mrg
8495 1.1 mrg @node IS_IOSTAT_END
8496 1.1 mrg @section @code{IS_IOSTAT_END} --- Test for end-of-file value
8497 1.1 mrg @fnindex IS_IOSTAT_END
8498 1.1 mrg @cindex @code{IOSTAT}, end of file
8499 1.1 mrg
8500 1.1 mrg @table @asis
8501 1.1 mrg @item @emph{Description}:
8502 1.1 mrg @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
8503 1.1 mrg status ``end of file''. The function is equivalent to comparing the variable
8504 1.1 mrg with the @code{IOSTAT_END} parameter of the intrinsic module
8505 1.1 mrg @code{ISO_FORTRAN_ENV}.
8506 1.1 mrg
8507 1.1 mrg @item @emph{Standard}:
8508 1.1 mrg Fortran 2003 and later
8509 1.1 mrg
8510 1.1 mrg @item @emph{Class}:
8511 1.1 mrg Elemental function
8512 1.1 mrg
8513 1.1 mrg @item @emph{Syntax}:
8514 1.1 mrg @code{RESULT = IS_IOSTAT_END(I)}
8515 1.1 mrg
8516 1.1 mrg @item @emph{Arguments}:
8517 1.1 mrg @multitable @columnfractions .15 .70
8518 1.1 mrg @item @var{I} @tab Shall be of the type @code{INTEGER}.
8519 1.1 mrg @end multitable
8520 1.1 mrg
8521 1.1 mrg @item @emph{Return value}:
8522 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8523 1.1 mrg @var{I} has the value which indicates an end of file condition for
8524 1.1 mrg @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8525 1.1 mrg
8526 1.1 mrg @item @emph{Example}:
8527 1.1 mrg @smallexample
8528 1.1 mrg PROGRAM iostat
8529 1.1 mrg IMPLICIT NONE
8530 1.1 mrg INTEGER :: stat, i
8531 1.1 mrg OPEN(88, FILE='test.dat')
8532 1.1 mrg READ(88, *, IOSTAT=stat) i
8533 1.1 mrg IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
8534 1.1 mrg END PROGRAM
8535 1.1 mrg @end smallexample
8536 1.1 mrg @end table
8537 1.1 mrg
8538 1.1 mrg
8539 1.1 mrg
8540 1.1 mrg @node IS_IOSTAT_EOR
8541 1.1 mrg @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
8542 1.1 mrg @fnindex IS_IOSTAT_EOR
8543 1.1 mrg @cindex @code{IOSTAT}, end of record
8544 1.1 mrg
8545 1.1 mrg @table @asis
8546 1.1 mrg @item @emph{Description}:
8547 1.1 mrg @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
8548 1.1 mrg status ``end of record''. The function is equivalent to comparing the
8549 1.1 mrg variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
8550 1.1 mrg @code{ISO_FORTRAN_ENV}.
8551 1.1 mrg
8552 1.1 mrg @item @emph{Standard}:
8553 1.1 mrg Fortran 2003 and later
8554 1.1 mrg
8555 1.1 mrg @item @emph{Class}:
8556 1.1 mrg Elemental function
8557 1.1 mrg
8558 1.1 mrg @item @emph{Syntax}:
8559 1.1 mrg @code{RESULT = IS_IOSTAT_EOR(I)}
8560 1.1 mrg
8561 1.1 mrg @item @emph{Arguments}:
8562 1.1 mrg @multitable @columnfractions .15 .70
8563 1.1 mrg @item @var{I} @tab Shall be of the type @code{INTEGER}.
8564 1.1 mrg @end multitable
8565 1.1 mrg
8566 1.1 mrg @item @emph{Return value}:
8567 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8568 1.1 mrg @var{I} has the value which indicates an end of file condition for
8569 1.1 mrg @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8570 1.1 mrg
8571 1.1 mrg @item @emph{Example}:
8572 1.1 mrg @smallexample
8573 1.1 mrg PROGRAM iostat
8574 1.1 mrg IMPLICIT NONE
8575 1.1 mrg INTEGER :: stat, i(50)
8576 1.1 mrg OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
8577 1.1 mrg READ(88, IOSTAT=stat) i
8578 1.1 mrg IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
8579 1.1 mrg END PROGRAM
8580 1.1 mrg @end smallexample
8581 1.1 mrg @end table
8582 1.1 mrg
8583 1.1 mrg
8584 1.1 mrg @node ISATTY
8585 1.1 mrg @section @code{ISATTY} --- Whether a unit is a terminal device.
8586 1.1 mrg @fnindex ISATTY
8587 1.1 mrg @cindex system, terminal
8588 1.1 mrg
8589 1.1 mrg @table @asis
8590 1.1 mrg @item @emph{Description}:
8591 1.1 mrg Determine whether a unit is connected to a terminal device.
8592 1.1 mrg
8593 1.1 mrg @item @emph{Standard}:
8594 1.1 mrg GNU extension
8595 1.1 mrg
8596 1.1 mrg @item @emph{Class}:
8597 1.1 mrg Function
8598 1.1 mrg
8599 1.1 mrg @item @emph{Syntax}:
8600 1.1 mrg @code{RESULT = ISATTY(UNIT)}
8601 1.1 mrg
8602 1.1 mrg @item @emph{Arguments}:
8603 1.1 mrg @multitable @columnfractions .15 .70
8604 1.1 mrg @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
8605 1.1 mrg @end multitable
8606 1.1 mrg
8607 1.1 mrg @item @emph{Return value}:
8608 1.1 mrg Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
8609 1.1 mrg device, @code{.FALSE.} otherwise.
8610 1.1 mrg
8611 1.1 mrg @item @emph{Example}:
8612 1.1 mrg @smallexample
8613 1.1 mrg PROGRAM test_isatty
8614 1.1 mrg INTEGER(kind=1) :: unit
8615 1.1 mrg DO unit = 1, 10
8616 1.1 mrg write(*,*) isatty(unit=unit)
8617 1.1 mrg END DO
8618 1.1 mrg END PROGRAM
8619 1.1 mrg @end smallexample
8620 1.1 mrg @item @emph{See also}:
8621 1.1 mrg @ref{TTYNAM}
8622 1.1 mrg @end table
8623 1.1 mrg
8624 1.1 mrg
8625 1.1 mrg
8626 1.1 mrg @node ISHFT
8627 1.1 mrg @section @code{ISHFT} --- Shift bits
8628 1.1 mrg @fnindex ISHFT
8629 1.1 mrg @fnindex BSHFT
8630 1.1 mrg @fnindex IISHFT
8631 1.1 mrg @fnindex JISHFT
8632 1.1 mrg @fnindex KISHFT
8633 1.1 mrg @cindex bits, shift
8634 1.1 mrg
8635 1.1 mrg @table @asis
8636 1.1 mrg @item @emph{Description}:
8637 1.1 mrg @code{ISHFT} returns a value corresponding to @var{I} with all of the
8638 1.1 mrg bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
8639 1.1 mrg zero corresponds to a left shift, a value of zero corresponds to no
8640 1.1 mrg shift, and a value less than zero corresponds to a right shift. If the
8641 1.1 mrg absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
8642 1.1 mrg value is undefined. Bits shifted out from the left end or right end are
8643 1.1 mrg lost; zeros are shifted in from the opposite end.
8644 1.1 mrg
8645 1.1 mrg @item @emph{Standard}:
8646 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
8647 1.1 mrg
8648 1.1 mrg @item @emph{Class}:
8649 1.1 mrg Elemental function
8650 1.1 mrg
8651 1.1 mrg @item @emph{Syntax}:
8652 1.1 mrg @code{RESULT = ISHFT(I, SHIFT)}
8653 1.1 mrg
8654 1.1 mrg @item @emph{Arguments}:
8655 1.1 mrg @multitable @columnfractions .15 .70
8656 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
8657 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8658 1.1 mrg @end multitable
8659 1.1 mrg
8660 1.1 mrg @item @emph{Return value}:
8661 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
8662 1.1 mrg @var{I}.
8663 1.1 mrg
8664 1.1 mrg @item @emph{Specific names}:
8665 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8666 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8667 1.1 mrg @item @code{ISHFT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8668 1.1 mrg @item @code{BSHFT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8669 1.1 mrg @item @code{IISHFT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8670 1.1 mrg @item @code{JISHFT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8671 1.1 mrg @item @code{KISHFT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8672 1.1 mrg @end multitable
8673 1.1 mrg
8674 1.1 mrg @item @emph{See also}:
8675 1.1 mrg @ref{ISHFTC}
8676 1.1 mrg @end table
8677 1.1 mrg
8678 1.1 mrg
8679 1.1 mrg
8680 1.1 mrg @node ISHFTC
8681 1.1 mrg @section @code{ISHFTC} --- Shift bits circularly
8682 1.1 mrg @fnindex ISHFTC
8683 1.1 mrg @fnindex BSHFTC
8684 1.1 mrg @fnindex IISHFTC
8685 1.1 mrg @fnindex JISHFTC
8686 1.1 mrg @fnindex KISHFTC
8687 1.1 mrg @cindex bits, shift circular
8688 1.1 mrg
8689 1.1 mrg @table @asis
8690 1.1 mrg @item @emph{Description}:
8691 1.1 mrg @code{ISHFTC} returns a value corresponding to @var{I} with the
8692 1.1 mrg rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
8693 1.1 mrg is, bits shifted out one end are shifted into the opposite end. A value
8694 1.1 mrg of @var{SHIFT} greater than zero corresponds to a left shift, a value of
8695 1.1 mrg zero corresponds to no shift, and a value less than zero corresponds to
8696 1.1 mrg a right shift. The absolute value of @var{SHIFT} must be less than
8697 1.1 mrg @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
8698 1.1 mrg equivalent to @code{BIT_SIZE(I)}.
8699 1.1 mrg
8700 1.1 mrg @item @emph{Standard}:
8701 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
8702 1.1 mrg
8703 1.1 mrg @item @emph{Class}:
8704 1.1 mrg Elemental function
8705 1.1 mrg
8706 1.1 mrg @item @emph{Syntax}:
8707 1.1 mrg @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
8708 1.1 mrg
8709 1.1 mrg @item @emph{Arguments}:
8710 1.1 mrg @multitable @columnfractions .15 .70
8711 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
8712 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8713 1.1 mrg @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
8714 1.1 mrg the value must be greater than zero and less than or equal to
8715 1.1 mrg @code{BIT_SIZE(I)}.
8716 1.1 mrg @end multitable
8717 1.1 mrg
8718 1.1 mrg @item @emph{Return value}:
8719 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
8720 1.1 mrg @var{I}.
8721 1.1 mrg
8722 1.1 mrg @item @emph{Specific names}:
8723 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
8724 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
8725 1.1 mrg @item @code{ISHFTC(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8726 1.1 mrg @item @code{BSHFTC(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8727 1.1 mrg @item @code{IISHFTC(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8728 1.1 mrg @item @code{JISHFTC(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8729 1.1 mrg @item @code{KISHFTC(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8730 1.1 mrg @end multitable
8731 1.1 mrg
8732 1.1 mrg @item @emph{See also}:
8733 1.1 mrg @ref{ISHFT}
8734 1.1 mrg @end table
8735 1.1 mrg
8736 1.1 mrg
8737 1.1 mrg
8738 1.1 mrg @node ISNAN
8739 1.1 mrg @section @code{ISNAN} --- Test for a NaN
8740 1.1 mrg @fnindex ISNAN
8741 1.1 mrg @cindex IEEE, ISNAN
8742 1.1 mrg
8743 1.1 mrg @table @asis
8744 1.1 mrg @item @emph{Description}:
8745 1.1 mrg @code{ISNAN} tests whether a floating-point value is an IEEE
8746 1.1 mrg Not-a-Number (NaN).
8747 1.1 mrg @item @emph{Standard}:
8748 1.1 mrg GNU extension
8749 1.1 mrg
8750 1.1 mrg @item @emph{Class}:
8751 1.1 mrg Elemental function
8752 1.1 mrg
8753 1.1 mrg @item @emph{Syntax}:
8754 1.1 mrg @code{ISNAN(X)}
8755 1.1 mrg
8756 1.1 mrg @item @emph{Arguments}:
8757 1.1 mrg @multitable @columnfractions .15 .70
8758 1.1 mrg @item @var{X} @tab Variable of the type @code{REAL}.
8759 1.1 mrg
8760 1.1 mrg @end multitable
8761 1.1 mrg
8762 1.1 mrg @item @emph{Return value}:
8763 1.1 mrg Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
8764 1.1 mrg if @var{X} is a NaN and @code{FALSE} otherwise.
8765 1.1 mrg
8766 1.1 mrg @item @emph{Example}:
8767 1.1 mrg @smallexample
8768 1.1 mrg program test_nan
8769 1.1 mrg implicit none
8770 1.1 mrg real :: x
8771 1.1 mrg x = -1.0
8772 1.1 mrg x = sqrt(x)
8773 1.1 mrg if (isnan(x)) stop '"x" is a NaN'
8774 1.1 mrg end program test_nan
8775 1.1 mrg @end smallexample
8776 1.1 mrg @end table
8777 1.1 mrg
8778 1.1 mrg
8779 1.1 mrg
8780 1.1 mrg @node ITIME
8781 1.1 mrg @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
8782 1.1 mrg @fnindex ITIME
8783 1.1 mrg @cindex time, current
8784 1.1 mrg @cindex current time
8785 1.1 mrg
8786 1.1 mrg @table @asis
8787 1.1 mrg @item @emph{Description}:
8788 1.1 mrg @code{ITIME(VALUES)} Fills @var{VALUES} with the numerical values at the
8789 1.1 mrg current local time. The hour (in the range 1-24), minute (in the range 1-60),
8790 1.1 mrg and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES},
8791 1.1 mrg respectively.
8792 1.1 mrg
8793 1.1 mrg This intrinsic routine is provided for backwards compatibility with
8794 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
8795 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
8796 1.1 mrg standard.
8797 1.1 mrg
8798 1.1 mrg @item @emph{Standard}:
8799 1.1 mrg GNU extension
8800 1.1 mrg
8801 1.1 mrg @item @emph{Class}:
8802 1.1 mrg Subroutine
8803 1.1 mrg
8804 1.1 mrg @item @emph{Syntax}:
8805 1.1 mrg @code{CALL ITIME(VALUES)}
8806 1.1 mrg
8807 1.1 mrg @item @emph{Arguments}:
8808 1.1 mrg @multitable @columnfractions .15 .70
8809 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
8810 1.1 mrg and the kind shall be the default integer kind.
8811 1.1 mrg @end multitable
8812 1.1 mrg
8813 1.1 mrg @item @emph{Return value}:
8814 1.1 mrg Does not return anything.
8815 1.1 mrg
8816 1.1 mrg
8817 1.1 mrg @item @emph{Example}:
8818 1.1 mrg @smallexample
8819 1.1 mrg program test_itime
8820 1.1 mrg integer, dimension(3) :: tarray
8821 1.1 mrg call itime(tarray)
8822 1.1 mrg print *, tarray(1)
8823 1.1 mrg print *, tarray(2)
8824 1.1 mrg print *, tarray(3)
8825 1.1 mrg end program test_itime
8826 1.1 mrg @end smallexample
8827 1.1 mrg
8828 1.1 mrg @item @emph{See also}:
8829 1.1 mrg @ref{DATE_AND_TIME}
8830 1.1 mrg @end table
8831 1.1 mrg
8832 1.1 mrg
8833 1.1 mrg
8834 1.1 mrg @node KILL
8835 1.1 mrg @section @code{KILL} --- Send a signal to a process
8836 1.1 mrg @fnindex KILL
8837 1.1 mrg
8838 1.1 mrg @table @asis
8839 1.1 mrg @item @emph{Description}:
8840 1.1 mrg @item @emph{Standard}:
8841 1.1 mrg Sends the signal specified by @var{SIG} to the process @var{PID}.
8842 1.1 mrg See @code{kill(2)}.
8843 1.1 mrg
8844 1.1 mrg This intrinsic is provided in both subroutine and function forms;
8845 1.1 mrg however, only one form can be used in any given program unit.
8846 1.1 mrg
8847 1.1 mrg @item @emph{Class}:
8848 1.1 mrg Subroutine, function
8849 1.1 mrg
8850 1.1 mrg @item @emph{Syntax}:
8851 1.1 mrg @multitable @columnfractions .80
8852 1.1 mrg @item @code{CALL KILL(PID, SIG [, STATUS])}
8853 1.1 mrg @item @code{STATUS = KILL(PID, SIG)}
8854 1.1 mrg @end multitable
8855 1.1 mrg
8856 1.1 mrg @item @emph{Arguments}:
8857 1.1 mrg @multitable @columnfractions .15 .70
8858 1.1 mrg @item @var{PID} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
8859 1.1 mrg @item @var{SIG} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
8860 1.1 mrg @item @var{STATUS} @tab [Subroutine](Optional)
8861 1.1 mrg Shall be a scalar @code{INTEGER}.
8862 1.1 mrg Returns 0 on success; otherwise a system-specific error code is returned.
8863 1.1 mrg @item @var{STATUS} @tab [Function] The kind type parameter is that of
8864 1.1 mrg @code{pid}.
8865 1.1 mrg Returns 0 on success; otherwise a system-specific error code is returned.
8866 1.1 mrg @end multitable
8867 1.1 mrg
8868 1.1 mrg @item @emph{See also}:
8869 1.1 mrg @ref{ABORT}, @ref{EXIT}
8870 1.1 mrg @end table
8871 1.1 mrg
8872 1.1 mrg
8873 1.1 mrg @node KIND
8874 1.1 mrg @section @code{KIND} --- Kind of an entity
8875 1.1 mrg @fnindex KIND
8876 1.1 mrg @cindex kind
8877 1.1 mrg
8878 1.1 mrg @table @asis
8879 1.1 mrg @item @emph{Description}:
8880 1.1 mrg @code{KIND(X)} returns the kind value of the entity @var{X}.
8881 1.1 mrg
8882 1.1 mrg @item @emph{Standard}:
8883 1.1 mrg Fortran 95 and later
8884 1.1 mrg
8885 1.1 mrg @item @emph{Class}:
8886 1.1 mrg Inquiry function
8887 1.1 mrg
8888 1.1 mrg @item @emph{Syntax}:
8889 1.1 mrg @code{K = KIND(X)}
8890 1.1 mrg
8891 1.1 mrg @item @emph{Arguments}:
8892 1.1 mrg @multitable @columnfractions .15 .70
8893 1.1 mrg @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
8894 1.1 mrg @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
8895 1.1 mrg @end multitable
8896 1.1 mrg
8897 1.1 mrg @item @emph{Return value}:
8898 1.1 mrg The return value is a scalar of type @code{INTEGER} and of the default
8899 1.1 mrg integer kind.
8900 1.1 mrg
8901 1.1 mrg @item @emph{Example}:
8902 1.1 mrg @smallexample
8903 1.1 mrg program test_kind
8904 1.1 mrg integer,parameter :: kc = kind(' ')
8905 1.1 mrg integer,parameter :: kl = kind(.true.)
8906 1.1 mrg
8907 1.1 mrg print *, "The default character kind is ", kc
8908 1.1 mrg print *, "The default logical kind is ", kl
8909 1.1 mrg end program test_kind
8910 1.1 mrg @end smallexample
8911 1.1 mrg
8912 1.1 mrg @end table
8913 1.1 mrg
8914 1.1 mrg
8915 1.1 mrg
8916 1.1 mrg @node LBOUND
8917 1.1 mrg @section @code{LBOUND} --- Lower dimension bounds of an array
8918 1.1 mrg @fnindex LBOUND
8919 1.1 mrg @cindex array, lower bound
8920 1.1 mrg
8921 1.1 mrg @table @asis
8922 1.1 mrg @item @emph{Description}:
8923 1.1 mrg Returns the lower bounds of an array, or a single lower bound
8924 1.1 mrg along the @var{DIM} dimension.
8925 1.1 mrg @item @emph{Standard}:
8926 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
8927 1.1 mrg
8928 1.1 mrg @item @emph{Class}:
8929 1.1 mrg Inquiry function
8930 1.1 mrg
8931 1.1 mrg @item @emph{Syntax}:
8932 1.1 mrg @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
8933 1.1 mrg
8934 1.1 mrg @item @emph{Arguments}:
8935 1.1 mrg @multitable @columnfractions .15 .70
8936 1.1 mrg @item @var{ARRAY} @tab Shall be an array, of any type.
8937 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
8938 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8939 1.1 mrg expression indicating the kind parameter of the result.
8940 1.1 mrg @end multitable
8941 1.1 mrg
8942 1.1 mrg @item @emph{Return value}:
8943 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8944 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
8945 1.1 mrg If @var{DIM} is absent, the result is an array of the lower bounds of
8946 1.1 mrg @var{ARRAY}. If @var{DIM} is present, the result is a scalar
8947 1.1 mrg corresponding to the lower bound of the array along that dimension. If
8948 1.1 mrg @var{ARRAY} is an expression rather than a whole array or array
8949 1.1 mrg structure component, or if it has a zero extent along the relevant
8950 1.1 mrg dimension, the lower bound is taken to be 1.
8951 1.1 mrg
8952 1.1 mrg @item @emph{See also}:
8953 1.1 mrg @ref{UBOUND}, @ref{LCOBOUND}
8954 1.1 mrg @end table
8955 1.1 mrg
8956 1.1 mrg
8957 1.1 mrg
8958 1.1 mrg @node LCOBOUND
8959 1.1 mrg @section @code{LCOBOUND} --- Lower codimension bounds of an array
8960 1.1 mrg @fnindex LCOBOUND
8961 1.1 mrg @cindex coarray, lower bound
8962 1.1 mrg
8963 1.1 mrg @table @asis
8964 1.1 mrg @item @emph{Description}:
8965 1.1 mrg Returns the lower bounds of a coarray, or a single lower cobound
8966 1.1 mrg along the @var{DIM} codimension.
8967 1.1 mrg @item @emph{Standard}:
8968 1.1 mrg Fortran 2008 and later
8969 1.1 mrg
8970 1.1 mrg @item @emph{Class}:
8971 1.1 mrg Inquiry function
8972 1.1 mrg
8973 1.1 mrg @item @emph{Syntax}:
8974 1.1 mrg @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
8975 1.1 mrg
8976 1.1 mrg @item @emph{Arguments}:
8977 1.1 mrg @multitable @columnfractions .15 .70
8978 1.1 mrg @item @var{ARRAY} @tab Shall be an coarray, of any type.
8979 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
8980 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8981 1.1 mrg expression indicating the kind parameter of the result.
8982 1.1 mrg @end multitable
8983 1.1 mrg
8984 1.1 mrg @item @emph{Return value}:
8985 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8986 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
8987 1.1 mrg If @var{DIM} is absent, the result is an array of the lower cobounds of
8988 1.1 mrg @var{COARRAY}. If @var{DIM} is present, the result is a scalar
8989 1.1 mrg corresponding to the lower cobound of the array along that codimension.
8990 1.1 mrg
8991 1.1 mrg @item @emph{See also}:
8992 1.1 mrg @ref{UCOBOUND}, @ref{LBOUND}
8993 1.1 mrg @end table
8994 1.1 mrg
8995 1.1 mrg
8996 1.1 mrg
8997 1.1 mrg @node LEADZ
8998 1.1 mrg @section @code{LEADZ} --- Number of leading zero bits of an integer
8999 1.1 mrg @fnindex LEADZ
9000 1.1 mrg @cindex zero bits
9001 1.1 mrg
9002 1.1 mrg @table @asis
9003 1.1 mrg @item @emph{Description}:
9004 1.1 mrg @code{LEADZ} returns the number of leading zero bits of an integer.
9005 1.1 mrg
9006 1.1 mrg @item @emph{Standard}:
9007 1.1 mrg Fortran 2008 and later
9008 1.1 mrg
9009 1.1 mrg @item @emph{Class}:
9010 1.1 mrg Elemental function
9011 1.1 mrg
9012 1.1 mrg @item @emph{Syntax}:
9013 1.1 mrg @code{RESULT = LEADZ(I)}
9014 1.1 mrg
9015 1.1 mrg @item @emph{Arguments}:
9016 1.1 mrg @multitable @columnfractions .15 .70
9017 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
9018 1.1 mrg @end multitable
9019 1.1 mrg
9020 1.1 mrg @item @emph{Return value}:
9021 1.1 mrg The type of the return value is the default @code{INTEGER}.
9022 1.1 mrg If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
9023 1.1 mrg
9024 1.1 mrg @item @emph{Example}:
9025 1.1 mrg @smallexample
9026 1.1 mrg PROGRAM test_leadz
9027 1.1 mrg WRITE (*,*) BIT_SIZE(1) ! prints 32
9028 1.1 mrg WRITE (*,*) LEADZ(1) ! prints 31
9029 1.1 mrg END PROGRAM
9030 1.1 mrg @end smallexample
9031 1.1 mrg
9032 1.1 mrg @item @emph{See also}:
9033 1.1 mrg @ref{BIT_SIZE}, @ref{TRAILZ}, @ref{POPCNT}, @ref{POPPAR}
9034 1.1 mrg @end table
9035 1.1 mrg
9036 1.1 mrg
9037 1.1 mrg
9038 1.1 mrg @node LEN
9039 1.1 mrg @section @code{LEN} --- Length of a character entity
9040 1.1 mrg @fnindex LEN
9041 1.1 mrg @cindex string, length
9042 1.1 mrg
9043 1.1 mrg @table @asis
9044 1.1 mrg @item @emph{Description}:
9045 1.1 mrg Returns the length of a character string. If @var{STRING} is an array,
9046 1.1 mrg the length of an element of @var{STRING} is returned. Note that
9047 1.1 mrg @var{STRING} need not be defined when this intrinsic is invoked, since
9048 1.1 mrg only the length, not the content, of @var{STRING} is needed.
9049 1.1 mrg
9050 1.1 mrg @item @emph{Standard}:
9051 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
9052 1.1 mrg
9053 1.1 mrg @item @emph{Class}:
9054 1.1 mrg Inquiry function
9055 1.1 mrg
9056 1.1 mrg @item @emph{Syntax}:
9057 1.1 mrg @code{L = LEN(STRING [, KIND])}
9058 1.1 mrg
9059 1.1 mrg @item @emph{Arguments}:
9060 1.1 mrg @multitable @columnfractions .15 .70
9061 1.1 mrg @item @var{STRING} @tab Shall be a scalar or array of type
9062 1.1 mrg @code{CHARACTER}, with @code{INTENT(IN)}
9063 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9064 1.1 mrg expression indicating the kind parameter of the result.
9065 1.1 mrg @end multitable
9066 1.1 mrg
9067 1.1 mrg @item @emph{Return value}:
9068 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9069 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
9070 1.1 mrg
9071 1.1 mrg
9072 1.1 mrg @item @emph{Specific names}:
9073 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9074 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9075 1.1 mrg @item @code{LEN(STRING)} @tab @code{CHARACTER} @tab @code{INTEGER} @tab Fortran 77 and later
9076 1.1 mrg @end multitable
9077 1.1 mrg
9078 1.1 mrg
9079 1.1 mrg @item @emph{See also}:
9080 1.1 mrg @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
9081 1.1 mrg @end table
9082 1.1 mrg
9083 1.1 mrg
9084 1.1 mrg
9085 1.1 mrg @node LEN_TRIM
9086 1.1 mrg @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
9087 1.1 mrg @fnindex LEN_TRIM
9088 1.1 mrg @cindex string, length, without trailing whitespace
9089 1.1 mrg
9090 1.1 mrg @table @asis
9091 1.1 mrg @item @emph{Description}:
9092 1.1 mrg Returns the length of a character string, ignoring any trailing blanks.
9093 1.1 mrg
9094 1.1 mrg @item @emph{Standard}:
9095 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9096 1.1 mrg
9097 1.1 mrg @item @emph{Class}:
9098 1.1 mrg Elemental function
9099 1.1 mrg
9100 1.1 mrg @item @emph{Syntax}:
9101 1.1 mrg @code{RESULT = LEN_TRIM(STRING [, KIND])}
9102 1.1 mrg
9103 1.1 mrg @item @emph{Arguments}:
9104 1.1 mrg @multitable @columnfractions .15 .70
9105 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9106 1.1 mrg with @code{INTENT(IN)}
9107 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9108 1.1 mrg expression indicating the kind parameter of the result.
9109 1.1 mrg @end multitable
9110 1.1 mrg
9111 1.1 mrg @item @emph{Return value}:
9112 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9113 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
9114 1.1 mrg
9115 1.1 mrg @item @emph{See also}:
9116 1.1 mrg @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
9117 1.1 mrg @end table
9118 1.1 mrg
9119 1.1 mrg
9120 1.1 mrg
9121 1.1 mrg @node LGE
9122 1.1 mrg @section @code{LGE} --- Lexical greater than or equal
9123 1.1 mrg @fnindex LGE
9124 1.1 mrg @cindex lexical comparison of strings
9125 1.1 mrg @cindex string, comparison
9126 1.1 mrg
9127 1.1 mrg @table @asis
9128 1.1 mrg @item @emph{Description}:
9129 1.1 mrg Determines whether one string is lexically greater than or equal to
9130 1.1 mrg another string, where the two strings are interpreted as containing
9131 1.1 mrg ASCII character codes. If the String A and String B are not the same
9132 1.1 mrg length, the shorter is compared as if spaces were appended to it to form
9133 1.1 mrg a value that has the same length as the longer.
9134 1.1 mrg
9135 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9136 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9137 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9138 1.1 mrg that the latter use the processor's character ordering (which is not
9139 1.1 mrg ASCII on some targets), whereas the former always use the ASCII
9140 1.1 mrg ordering.
9141 1.1 mrg
9142 1.1 mrg @item @emph{Standard}:
9143 1.1 mrg Fortran 77 and later
9144 1.1 mrg
9145 1.1 mrg @item @emph{Class}:
9146 1.1 mrg Elemental function
9147 1.1 mrg
9148 1.1 mrg @item @emph{Syntax}:
9149 1.1 mrg @code{RESULT = LGE(STRING_A, STRING_B)}
9150 1.1 mrg
9151 1.1 mrg @item @emph{Arguments}:
9152 1.1 mrg @multitable @columnfractions .15 .70
9153 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9154 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9155 1.1 mrg @end multitable
9156 1.1 mrg
9157 1.1 mrg @item @emph{Return value}:
9158 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
9159 1.1 mrg otherwise, based on the ASCII ordering.
9160 1.1 mrg
9161 1.1 mrg @item @emph{Specific names}:
9162 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9163 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9164 1.1 mrg @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9165 1.1 mrg @end multitable
9166 1.1 mrg
9167 1.1 mrg @item @emph{See also}:
9168 1.1 mrg @ref{LGT}, @ref{LLE}, @ref{LLT}
9169 1.1 mrg @end table
9170 1.1 mrg
9171 1.1 mrg
9172 1.1 mrg
9173 1.1 mrg @node LGT
9174 1.1 mrg @section @code{LGT} --- Lexical greater than
9175 1.1 mrg @fnindex LGT
9176 1.1 mrg @cindex lexical comparison of strings
9177 1.1 mrg @cindex string, comparison
9178 1.1 mrg
9179 1.1 mrg @table @asis
9180 1.1 mrg @item @emph{Description}:
9181 1.1 mrg Determines whether one string is lexically greater than another string,
9182 1.1 mrg where the two strings are interpreted as containing ASCII character
9183 1.1 mrg codes. If the String A and String B are not the same length, the
9184 1.1 mrg shorter is compared as if spaces were appended to it to form a value
9185 1.1 mrg that has the same length as the longer.
9186 1.1 mrg
9187 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9188 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9189 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9190 1.1 mrg that the latter use the processor's character ordering (which is not
9191 1.1 mrg ASCII on some targets), whereas the former always use the ASCII
9192 1.1 mrg ordering.
9193 1.1 mrg
9194 1.1 mrg @item @emph{Standard}:
9195 1.1 mrg Fortran 77 and later
9196 1.1 mrg
9197 1.1 mrg @item @emph{Class}:
9198 1.1 mrg Elemental function
9199 1.1 mrg
9200 1.1 mrg @item @emph{Syntax}:
9201 1.1 mrg @code{RESULT = LGT(STRING_A, STRING_B)}
9202 1.1 mrg
9203 1.1 mrg @item @emph{Arguments}:
9204 1.1 mrg @multitable @columnfractions .15 .70
9205 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9206 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9207 1.1 mrg @end multitable
9208 1.1 mrg
9209 1.1 mrg @item @emph{Return value}:
9210 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
9211 1.1 mrg otherwise, based on the ASCII ordering.
9212 1.1 mrg
9213 1.1 mrg @item @emph{Specific names}:
9214 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9215 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9216 1.1 mrg @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9217 1.1 mrg @end multitable
9218 1.1 mrg
9219 1.1 mrg @item @emph{See also}:
9220 1.1 mrg @ref{LGE}, @ref{LLE}, @ref{LLT}
9221 1.1 mrg @end table
9222 1.1 mrg
9223 1.1 mrg
9224 1.1 mrg
9225 1.1 mrg @node LINK
9226 1.1 mrg @section @code{LINK} --- Create a hard link
9227 1.1 mrg @fnindex LINK
9228 1.1 mrg @cindex file system, create link
9229 1.1 mrg @cindex file system, hard link
9230 1.1 mrg
9231 1.1 mrg @table @asis
9232 1.1 mrg @item @emph{Description}:
9233 1.1 mrg Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
9234 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in
9235 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9236 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it
9237 1.1 mrg contains 0 on success or a nonzero error code upon return; see
9238 1.1 mrg @code{link(2)}.
9239 1.1 mrg
9240 1.1 mrg This intrinsic is provided in both subroutine and function forms;
9241 1.1 mrg however, only one form can be used in any given program unit.
9242 1.1 mrg
9243 1.1 mrg @item @emph{Standard}:
9244 1.1 mrg GNU extension
9245 1.1 mrg
9246 1.1 mrg @item @emph{Class}:
9247 1.1 mrg Subroutine, function
9248 1.1 mrg
9249 1.1 mrg @item @emph{Syntax}:
9250 1.1 mrg @multitable @columnfractions .80
9251 1.1 mrg @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
9252 1.1 mrg @item @code{STATUS = LINK(PATH1, PATH2)}
9253 1.1 mrg @end multitable
9254 1.1 mrg
9255 1.1 mrg @item @emph{Arguments}:
9256 1.1 mrg @multitable @columnfractions .15 .70
9257 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9258 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9259 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9260 1.1 mrg @end multitable
9261 1.1 mrg
9262 1.1 mrg @item @emph{See also}:
9263 1.1 mrg @ref{SYMLNK}, @ref{UNLINK}
9264 1.1 mrg @end table
9265 1.1 mrg
9266 1.1 mrg
9267 1.1 mrg
9268 1.1 mrg @node LLE
9269 1.1 mrg @section @code{LLE} --- Lexical less than or equal
9270 1.1 mrg @fnindex LLE
9271 1.1 mrg @cindex lexical comparison of strings
9272 1.1 mrg @cindex string, comparison
9273 1.1 mrg
9274 1.1 mrg @table @asis
9275 1.1 mrg @item @emph{Description}:
9276 1.1 mrg Determines whether one string is lexically less than or equal to another
9277 1.1 mrg string, where the two strings are interpreted as containing ASCII
9278 1.1 mrg character codes. If the String A and String B are not the same length,
9279 1.1 mrg the shorter is compared as if spaces were appended to it to form a value
9280 1.1 mrg that has the same length as the longer.
9281 1.1 mrg
9282 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9283 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9284 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9285 1.1 mrg that the latter use the processor's character ordering (which is not
9286 1.1 mrg ASCII on some targets), whereas the former always use the ASCII
9287 1.1 mrg ordering.
9288 1.1 mrg
9289 1.1 mrg @item @emph{Standard}:
9290 1.1 mrg Fortran 77 and later
9291 1.1 mrg
9292 1.1 mrg @item @emph{Class}:
9293 1.1 mrg Elemental function
9294 1.1 mrg
9295 1.1 mrg @item @emph{Syntax}:
9296 1.1 mrg @code{RESULT = LLE(STRING_A, STRING_B)}
9297 1.1 mrg
9298 1.1 mrg @item @emph{Arguments}:
9299 1.1 mrg @multitable @columnfractions .15 .70
9300 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9301 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9302 1.1 mrg @end multitable
9303 1.1 mrg
9304 1.1 mrg @item @emph{Return value}:
9305 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
9306 1.1 mrg otherwise, based on the ASCII ordering.
9307 1.1 mrg
9308 1.1 mrg @item @emph{Specific names}:
9309 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9310 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9311 1.1 mrg @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9312 1.1 mrg @end multitable
9313 1.1 mrg
9314 1.1 mrg @item @emph{See also}:
9315 1.1 mrg @ref{LGE}, @ref{LGT}, @ref{LLT}
9316 1.1 mrg @end table
9317 1.1 mrg
9318 1.1 mrg
9319 1.1 mrg
9320 1.1 mrg @node LLT
9321 1.1 mrg @section @code{LLT} --- Lexical less than
9322 1.1 mrg @fnindex LLT
9323 1.1 mrg @cindex lexical comparison of strings
9324 1.1 mrg @cindex string, comparison
9325 1.1 mrg
9326 1.1 mrg @table @asis
9327 1.1 mrg @item @emph{Description}:
9328 1.1 mrg Determines whether one string is lexically less than another string,
9329 1.1 mrg where the two strings are interpreted as containing ASCII character
9330 1.1 mrg codes. If the String A and String B are not the same length, the
9331 1.1 mrg shorter is compared as if spaces were appended to it to form a value
9332 1.1 mrg that has the same length as the longer.
9333 1.1 mrg
9334 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9335 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9336 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9337 1.1 mrg that the latter use the processor's character ordering (which is not
9338 1.1 mrg ASCII on some targets), whereas the former always use the ASCII
9339 1.1 mrg ordering.
9340 1.1 mrg
9341 1.1 mrg @item @emph{Standard}:
9342 1.1 mrg Fortran 77 and later
9343 1.1 mrg
9344 1.1 mrg @item @emph{Class}:
9345 1.1 mrg Elemental function
9346 1.1 mrg
9347 1.1 mrg @item @emph{Syntax}:
9348 1.1 mrg @code{RESULT = LLT(STRING_A, STRING_B)}
9349 1.1 mrg
9350 1.1 mrg @item @emph{Arguments}:
9351 1.1 mrg @multitable @columnfractions .15 .70
9352 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9353 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9354 1.1 mrg @end multitable
9355 1.1 mrg
9356 1.1 mrg @item @emph{Return value}:
9357 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
9358 1.1 mrg otherwise, based on the ASCII ordering.
9359 1.1 mrg
9360 1.1 mrg @item @emph{Specific names}:
9361 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9362 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9363 1.1 mrg @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9364 1.1 mrg @end multitable
9365 1.1 mrg
9366 1.1 mrg @item @emph{See also}:
9367 1.1 mrg @ref{LGE}, @ref{LGT}, @ref{LLE}
9368 1.1 mrg @end table
9369 1.1 mrg
9370 1.1 mrg
9371 1.1 mrg
9372 1.1 mrg @node LNBLNK
9373 1.1 mrg @section @code{LNBLNK} --- Index of the last non-blank character in a string
9374 1.1 mrg @fnindex LNBLNK
9375 1.1 mrg @cindex string, find non-blank character
9376 1.1 mrg
9377 1.1 mrg @table @asis
9378 1.1 mrg @item @emph{Description}:
9379 1.1 mrg Returns the length of a character string, ignoring any trailing blanks.
9380 1.1 mrg This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
9381 1.1 mrg included for backwards compatibility.
9382 1.1 mrg
9383 1.1 mrg @item @emph{Standard}:
9384 1.1 mrg GNU extension
9385 1.1 mrg
9386 1.1 mrg @item @emph{Class}:
9387 1.1 mrg Elemental function
9388 1.1 mrg
9389 1.1 mrg @item @emph{Syntax}:
9390 1.1 mrg @code{RESULT = LNBLNK(STRING)}
9391 1.1 mrg
9392 1.1 mrg @item @emph{Arguments}:
9393 1.1 mrg @multitable @columnfractions .15 .70
9394 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9395 1.1 mrg with @code{INTENT(IN)}
9396 1.1 mrg @end multitable
9397 1.1 mrg
9398 1.1 mrg @item @emph{Return value}:
9399 1.1 mrg The return value is of @code{INTEGER(kind=4)} type.
9400 1.1 mrg
9401 1.1 mrg @item @emph{See also}:
9402 1.1 mrg @ref{INDEX intrinsic}, @ref{LEN_TRIM}
9403 1.1 mrg @end table
9404 1.1 mrg
9405 1.1 mrg
9406 1.1 mrg
9407 1.1 mrg @node LOC
9408 1.1 mrg @section @code{LOC} --- Returns the address of a variable
9409 1.1 mrg @fnindex LOC
9410 1.1 mrg @cindex location of a variable in memory
9411 1.1 mrg
9412 1.1 mrg @table @asis
9413 1.1 mrg @item @emph{Description}:
9414 1.1 mrg @code{LOC(X)} returns the address of @var{X} as an integer.
9415 1.1 mrg
9416 1.1 mrg @item @emph{Standard}:
9417 1.1 mrg GNU extension
9418 1.1 mrg
9419 1.1 mrg @item @emph{Class}:
9420 1.1 mrg Inquiry function
9421 1.1 mrg
9422 1.1 mrg @item @emph{Syntax}:
9423 1.1 mrg @code{RESULT = LOC(X)}
9424 1.1 mrg
9425 1.1 mrg @item @emph{Arguments}:
9426 1.1 mrg @multitable @columnfractions .15 .70
9427 1.1 mrg @item @var{X} @tab Variable of any type.
9428 1.1 mrg @end multitable
9429 1.1 mrg
9430 1.1 mrg @item @emph{Return value}:
9431 1.1 mrg The return value is of type @code{INTEGER}, with a @code{KIND}
9432 1.1 mrg corresponding to the size (in bytes) of a memory address on the target
9433 1.1 mrg machine.
9434 1.1 mrg
9435 1.1 mrg @item @emph{Example}:
9436 1.1 mrg @smallexample
9437 1.1 mrg program test_loc
9438 1.1 mrg integer :: i
9439 1.1 mrg real :: r
9440 1.1 mrg i = loc(r)
9441 1.1 mrg print *, i
9442 1.1 mrg end program test_loc
9443 1.1 mrg @end smallexample
9444 1.1 mrg @end table
9445 1.1 mrg
9446 1.1 mrg
9447 1.1 mrg
9448 1.1 mrg @node LOG
9449 1.1 mrg @section @code{LOG} --- Natural logarithm function
9450 1.1 mrg @fnindex LOG
9451 1.1 mrg @fnindex ALOG
9452 1.1 mrg @fnindex DLOG
9453 1.1 mrg @fnindex CLOG
9454 1.1 mrg @fnindex ZLOG
9455 1.1 mrg @fnindex CDLOG
9456 1.1 mrg @cindex exponential function, inverse
9457 1.1 mrg @cindex logarithm function
9458 1.1 mrg @cindex natural logarithm function
9459 1.1 mrg
9460 1.1 mrg @table @asis
9461 1.1 mrg @item @emph{Description}:
9462 1.1 mrg @code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the
9463 1.1 mrg logarithm to the base @math{e}.
9464 1.1 mrg
9465 1.1 mrg @item @emph{Standard}:
9466 1.1 mrg Fortran 77 and later
9467 1.1 mrg
9468 1.1 mrg @item @emph{Class}:
9469 1.1 mrg Elemental function
9470 1.1 mrg
9471 1.1 mrg @item @emph{Syntax}:
9472 1.1 mrg @code{RESULT = LOG(X)}
9473 1.1 mrg
9474 1.1 mrg @item @emph{Arguments}:
9475 1.1 mrg @multitable @columnfractions .15 .70
9476 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
9477 1.1 mrg @code{COMPLEX}.
9478 1.1 mrg @end multitable
9479 1.1 mrg
9480 1.1 mrg @item @emph{Return value}:
9481 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}.
9482 1.1 mrg The kind type parameter is the same as @var{X}.
9483 1.1 mrg If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
9484 1.1 mrg @math{-\pi < \omega \leq \pi}.
9485 1.1 mrg
9486 1.1 mrg @item @emph{Example}:
9487 1.1 mrg @smallexample
9488 1.1 mrg program test_log
9489 1.1 mrg real(8) :: x = 2.7182818284590451_8
9490 1.1 mrg complex :: z = (1.0, 2.0)
9491 1.1 mrg x = log(x) ! will yield (approximately) 1
9492 1.1 mrg z = log(z)
9493 1.1 mrg end program test_log
9494 1.1 mrg @end smallexample
9495 1.1 mrg
9496 1.1 mrg @item @emph{Specific names}:
9497 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9498 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9499 1.1 mrg @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
9500 1.1 mrg @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
9501 1.1 mrg @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
9502 1.1 mrg @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9503 1.1 mrg @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9504 1.1 mrg @end multitable
9505 1.1 mrg @end table
9506 1.1 mrg
9507 1.1 mrg
9508 1.1 mrg
9509 1.1 mrg @node LOG10
9510 1.1 mrg @section @code{LOG10} --- Base 10 logarithm function
9511 1.1 mrg @fnindex LOG10
9512 1.1 mrg @fnindex ALOG10
9513 1.1 mrg @fnindex DLOG10
9514 1.1 mrg @cindex exponential function, inverse
9515 1.1 mrg @cindex logarithm function with base 10
9516 1.1 mrg @cindex base 10 logarithm function
9517 1.1 mrg
9518 1.1 mrg @table @asis
9519 1.1 mrg @item @emph{Description}:
9520 1.1 mrg @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
9521 1.1 mrg
9522 1.1 mrg @item @emph{Standard}:
9523 1.1 mrg Fortran 77 and later
9524 1.1 mrg
9525 1.1 mrg @item @emph{Class}:
9526 1.1 mrg Elemental function
9527 1.1 mrg
9528 1.1 mrg @item @emph{Syntax}:
9529 1.1 mrg @code{RESULT = LOG10(X)}
9530 1.1 mrg
9531 1.1 mrg @item @emph{Arguments}:
9532 1.1 mrg @multitable @columnfractions .15 .70
9533 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}.
9534 1.1 mrg @end multitable
9535 1.1 mrg
9536 1.1 mrg @item @emph{Return value}:
9537 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}.
9538 1.1 mrg The kind type parameter is the same as @var{X}.
9539 1.1 mrg
9540 1.1 mrg @item @emph{Example}:
9541 1.1 mrg @smallexample
9542 1.1 mrg program test_log10
9543 1.1 mrg real(8) :: x = 10.0_8
9544 1.1 mrg x = log10(x)
9545 1.1 mrg end program test_log10
9546 1.1 mrg @end smallexample
9547 1.1 mrg
9548 1.1 mrg @item @emph{Specific names}:
9549 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9550 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9551 1.1 mrg @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
9552 1.1 mrg @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
9553 1.1 mrg @end multitable
9554 1.1 mrg @end table
9555 1.1 mrg
9556 1.1 mrg
9557 1.1 mrg
9558 1.1 mrg @node LOG_GAMMA
9559 1.1 mrg @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
9560 1.1 mrg @fnindex LOG_GAMMA
9561 1.1 mrg @fnindex LGAMMA
9562 1.1 mrg @fnindex ALGAMA
9563 1.1 mrg @fnindex DLGAMA
9564 1.1 mrg @cindex Gamma function, logarithm of
9565 1.1 mrg
9566 1.1 mrg @table @asis
9567 1.1 mrg @item @emph{Description}:
9568 1.1 mrg @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
9569 1.1 mrg of the Gamma (@math{\Gamma}) function.
9570 1.1 mrg
9571 1.1 mrg @item @emph{Standard}:
9572 1.1 mrg Fortran 2008 and later
9573 1.1 mrg
9574 1.1 mrg @item @emph{Class}:
9575 1.1 mrg Elemental function
9576 1.1 mrg
9577 1.1 mrg @item @emph{Syntax}:
9578 1.1 mrg @code{X = LOG_GAMMA(X)}
9579 1.1 mrg
9580 1.1 mrg @item @emph{Arguments}:
9581 1.1 mrg @multitable @columnfractions .15 .70
9582 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} and neither zero
9583 1.1 mrg nor a negative integer.
9584 1.1 mrg @end multitable
9585 1.1 mrg
9586 1.1 mrg @item @emph{Return value}:
9587 1.1 mrg The return value is of type @code{REAL} of the same kind as @var{X}.
9588 1.1 mrg
9589 1.1 mrg @item @emph{Example}:
9590 1.1 mrg @smallexample
9591 1.1 mrg program test_log_gamma
9592 1.1 mrg real :: x = 1.0
9593 1.1 mrg x = lgamma(x) ! returns 0.0
9594 1.1 mrg end program test_log_gamma
9595 1.1 mrg @end smallexample
9596 1.1 mrg
9597 1.1 mrg @item @emph{Specific names}:
9598 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
9599 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
9600 1.1 mrg @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
9601 1.1 mrg @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
9602 1.1 mrg @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
9603 1.1 mrg @end multitable
9604 1.1 mrg
9605 1.1 mrg @item @emph{See also}:
9606 1.1 mrg Gamma function: @ref{GAMMA}
9607 1.1 mrg
9608 1.1 mrg @end table
9609 1.1 mrg
9610 1.1 mrg
9611 1.1 mrg
9612 1.1 mrg @node LOGICAL
9613 1.1 mrg @section @code{LOGICAL} --- Convert to logical type
9614 1.1 mrg @fnindex LOGICAL
9615 1.1 mrg @cindex conversion, to logical
9616 1.1 mrg
9617 1.1 mrg @table @asis
9618 1.1 mrg @item @emph{Description}:
9619 1.1 mrg Converts one kind of @code{LOGICAL} variable to another.
9620 1.1 mrg
9621 1.1 mrg @item @emph{Standard}:
9622 1.1 mrg Fortran 95 and later
9623 1.1 mrg
9624 1.1 mrg @item @emph{Class}:
9625 1.1 mrg Elemental function
9626 1.1 mrg
9627 1.1 mrg @item @emph{Syntax}:
9628 1.1 mrg @code{RESULT = LOGICAL(L [, KIND])}
9629 1.1 mrg
9630 1.1 mrg @item @emph{Arguments}:
9631 1.1 mrg @multitable @columnfractions .15 .70
9632 1.1 mrg @item @var{L} @tab The type shall be @code{LOGICAL}.
9633 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9634 1.1 mrg expression indicating the kind parameter of the result.
9635 1.1 mrg @end multitable
9636 1.1 mrg
9637 1.1 mrg @item @emph{Return value}:
9638 1.1 mrg The return value is a @code{LOGICAL} value equal to @var{L}, with a
9639 1.1 mrg kind corresponding to @var{KIND}, or of the default logical kind if
9640 1.1 mrg @var{KIND} is not given.
9641 1.1 mrg
9642 1.1 mrg @item @emph{See also}:
9643 1.1 mrg @ref{INT}, @ref{REAL}, @ref{CMPLX}
9644 1.1 mrg @end table
9645 1.1 mrg
9646 1.1 mrg
9647 1.1 mrg
9648 1.1 mrg @node LONG
9649 1.1 mrg @section @code{LONG} --- Convert to integer type
9650 1.1 mrg @fnindex LONG
9651 1.1 mrg @cindex conversion, to integer
9652 1.1 mrg
9653 1.1 mrg @table @asis
9654 1.1 mrg @item @emph{Description}:
9655 1.1 mrg Convert to a @code{KIND=4} integer type, which is the same size as a C
9656 1.1 mrg @code{long} integer. This is equivalent to the standard @code{INT}
9657 1.1 mrg intrinsic with an optional argument of @code{KIND=4}, and is only
9658 1.1 mrg included for backwards compatibility.
9659 1.1 mrg
9660 1.1 mrg @item @emph{Standard}:
9661 1.1 mrg GNU extension
9662 1.1 mrg
9663 1.1 mrg @item @emph{Class}:
9664 1.1 mrg Elemental function
9665 1.1 mrg
9666 1.1 mrg @item @emph{Syntax}:
9667 1.1 mrg @code{RESULT = LONG(A)}
9668 1.1 mrg
9669 1.1 mrg @item @emph{Arguments}:
9670 1.1 mrg @multitable @columnfractions .15 .70
9671 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER},
9672 1.1 mrg @code{REAL}, or @code{COMPLEX}.
9673 1.1 mrg @end multitable
9674 1.1 mrg
9675 1.1 mrg @item @emph{Return value}:
9676 1.1 mrg The return value is a @code{INTEGER(4)} variable.
9677 1.1 mrg
9678 1.1 mrg @item @emph{See also}:
9679 1.1 mrg @ref{INT}, @ref{INT2}, @ref{INT8}
9680 1.1 mrg @end table
9681 1.1 mrg
9682 1.1 mrg
9683 1.1 mrg
9684 1.1 mrg @node LSHIFT
9685 1.1 mrg @section @code{LSHIFT} --- Left shift bits
9686 1.1 mrg @fnindex LSHIFT
9687 1.1 mrg @cindex bits, shift left
9688 1.1 mrg
9689 1.1 mrg @table @asis
9690 1.1 mrg @item @emph{Description}:
9691 1.1 mrg @code{LSHIFT} returns a value corresponding to @var{I} with all of the
9692 1.1 mrg bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be
9693 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
9694 1.1 mrg the result value is undefined. Bits shifted out from the left end are
9695 1.1 mrg lost; zeros are shifted in from the opposite end.
9696 1.1 mrg
9697 1.1 mrg This function has been superseded by the @code{ISHFT} intrinsic, which
9698 1.1 mrg is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
9699 1.1 mrg which is standard in Fortran 2008 and later.
9700 1.1 mrg
9701 1.1 mrg @item @emph{Standard}:
9702 1.1 mrg GNU extension
9703 1.1 mrg
9704 1.1 mrg @item @emph{Class}:
9705 1.1 mrg Elemental function
9706 1.1 mrg
9707 1.1 mrg @item @emph{Syntax}:
9708 1.1 mrg @code{RESULT = LSHIFT(I, SHIFT)}
9709 1.1 mrg
9710 1.1 mrg @item @emph{Arguments}:
9711 1.1 mrg @multitable @columnfractions .15 .70
9712 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
9713 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9714 1.1 mrg @end multitable
9715 1.1 mrg
9716 1.1 mrg @item @emph{Return value}:
9717 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
9718 1.1 mrg @var{I}.
9719 1.1 mrg
9720 1.1 mrg @item @emph{See also}:
9721 1.1 mrg @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}, @ref{SHIFTA}, @ref{SHIFTL},
9722 1.1 mrg @ref{SHIFTR}
9723 1.1 mrg
9724 1.1 mrg @end table
9725 1.1 mrg
9726 1.1 mrg
9727 1.1 mrg
9728 1.1 mrg @node LSTAT
9729 1.1 mrg @section @code{LSTAT} --- Get file status
9730 1.1 mrg @fnindex LSTAT
9731 1.1 mrg @cindex file system, file status
9732 1.1 mrg
9733 1.1 mrg @table @asis
9734 1.1 mrg @item @emph{Description}:
9735 1.1 mrg @code{LSTAT} is identical to @ref{STAT}, except that if path is a
9736 1.1 mrg symbolic link, then the link itself is statted, not the file that it
9737 1.1 mrg refers to.
9738 1.1 mrg
9739 1.1 mrg The elements in @code{VALUES} are the same as described by @ref{STAT}.
9740 1.1 mrg
9741 1.1 mrg This intrinsic is provided in both subroutine and function forms;
9742 1.1 mrg however, only one form can be used in any given program unit.
9743 1.1 mrg
9744 1.1 mrg @item @emph{Standard}:
9745 1.1 mrg GNU extension
9746 1.1 mrg
9747 1.1 mrg @item @emph{Class}:
9748 1.1 mrg Subroutine, function
9749 1.1 mrg
9750 1.1 mrg @item @emph{Syntax}:
9751 1.1 mrg @multitable @columnfractions .80
9752 1.1 mrg @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
9753 1.1 mrg @item @code{STATUS = LSTAT(NAME, VALUES)}
9754 1.1 mrg @end multitable
9755 1.1 mrg
9756 1.1 mrg @item @emph{Arguments}:
9757 1.1 mrg @multitable @columnfractions .15 .70
9758 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER} of the default
9759 1.1 mrg kind, a valid path within the file system.
9760 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9761 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
9762 1.1 mrg Returns 0 on success and a system specific error code otherwise.
9763 1.1 mrg @end multitable
9764 1.1 mrg
9765 1.1 mrg @item @emph{Example}:
9766 1.1 mrg See @ref{STAT} for an example.
9767 1.1 mrg
9768 1.1 mrg @item @emph{See also}:
9769 1.1 mrg To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
9770 1.1 mrg @end table
9771 1.1 mrg
9772 1.1 mrg
9773 1.1 mrg
9774 1.1 mrg @node LTIME
9775 1.1 mrg @section @code{LTIME} --- Convert time to local time info
9776 1.1 mrg @fnindex LTIME
9777 1.1 mrg @cindex time, conversion to local time info
9778 1.1 mrg
9779 1.1 mrg @table @asis
9780 1.1 mrg @item @emph{Description}:
9781 1.1 mrg Given a system time value @var{TIME} (as provided by the @ref{TIME}
9782 1.1 mrg intrinsic), fills @var{VALUES} with values extracted from it appropriate
9783 1.1 mrg to the local time zone using @code{localtime(3)}.
9784 1.1 mrg
9785 1.1 mrg This intrinsic routine is provided for backwards compatibility with
9786 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of
9787 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
9788 1.1 mrg standard.
9789 1.1 mrg
9790 1.1 mrg @item @emph{Standard}:
9791 1.1 mrg GNU extension
9792 1.1 mrg
9793 1.1 mrg @item @emph{Class}:
9794 1.1 mrg Subroutine
9795 1.1 mrg
9796 1.1 mrg @item @emph{Syntax}:
9797 1.1 mrg @code{CALL LTIME(TIME, VALUES)}
9798 1.1 mrg
9799 1.1 mrg @item @emph{Arguments}:
9800 1.1 mrg @multitable @columnfractions .15 .70
9801 1.1 mrg @item @var{TIME} @tab An @code{INTEGER} scalar expression
9802 1.1 mrg corresponding to a system time, with @code{INTENT(IN)}.
9803 1.1 mrg @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
9804 1.1 mrg with @code{INTENT(OUT)}.
9805 1.1 mrg @end multitable
9806 1.1 mrg
9807 1.1 mrg @item @emph{Return value}:
9808 1.1 mrg The elements of @var{VALUES} are assigned as follows:
9809 1.1 mrg @enumerate
9810 1.1 mrg @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
9811 1.1 mrg seconds
9812 1.1 mrg @item Minutes after the hour, range 0--59
9813 1.1 mrg @item Hours past midnight, range 0--23
9814 1.1 mrg @item Day of month, range 1--31
9815 1.1 mrg @item Number of months since January, range 0--11
9816 1.1 mrg @item Years since 1900
9817 1.1 mrg @item Number of days since Sunday, range 0--6
9818 1.1 mrg @item Days since January 1, range 0--365
9819 1.1 mrg @item Daylight savings indicator: positive if daylight savings is in
9820 1.1 mrg effect, zero if not, and negative if the information is not available.
9821 1.1 mrg @end enumerate
9822 1.1 mrg
9823 1.1 mrg @item @emph{See also}:
9824 1.1 mrg @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
9825 1.1 mrg
9826 1.1 mrg @end table
9827 1.1 mrg
9828 1.1 mrg
9829 1.1 mrg
9830 1.1 mrg @node MALLOC
9831 1.1 mrg @section @code{MALLOC} --- Allocate dynamic memory
9832 1.1 mrg @fnindex MALLOC
9833 1.1 mrg @cindex pointer, cray
9834 1.1 mrg
9835 1.1 mrg @table @asis
9836 1.1 mrg @item @emph{Description}:
9837 1.1 mrg @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
9838 1.1 mrg returns the address of the allocated memory. The @code{MALLOC} intrinsic
9839 1.1 mrg is an extension intended to be used with Cray pointers, and is provided
9840 1.1 mrg in GNU Fortran to allow the user to compile legacy code. For new code
9841 1.1 mrg using Fortran 95 pointers, the memory allocation intrinsic is
9842 1.1 mrg @code{ALLOCATE}.
9843 1.1 mrg
9844 1.1 mrg @item @emph{Standard}:
9845 1.1 mrg GNU extension
9846 1.1 mrg
9847 1.1 mrg @item @emph{Class}:
9848 1.1 mrg Function
9849 1.1 mrg
9850 1.1 mrg @item @emph{Syntax}:
9851 1.1 mrg @code{PTR = MALLOC(SIZE)}
9852 1.1 mrg
9853 1.1 mrg @item @emph{Arguments}:
9854 1.1 mrg @multitable @columnfractions .15 .70
9855 1.1 mrg @item @var{SIZE} @tab The type shall be @code{INTEGER}.
9856 1.1 mrg @end multitable
9857 1.1 mrg
9858 1.1 mrg @item @emph{Return value}:
9859 1.1 mrg The return value is of type @code{INTEGER(K)}, with @var{K} such that
9860 1.1 mrg variables of type @code{INTEGER(K)} have the same size as
9861 1.1 mrg C pointers (@code{sizeof(void *)}).
9862 1.1 mrg
9863 1.1 mrg @item @emph{Example}:
9864 1.1 mrg The following example demonstrates the use of @code{MALLOC} and
9865 1.1 mrg @code{FREE} with Cray pointers.
9866 1.1 mrg
9867 1.1 mrg @smallexample
9868 1.1 mrg program test_malloc
9869 1.1 mrg implicit none
9870 1.1 mrg integer i
9871 1.1 mrg real*8 x(*), z
9872 1.1 mrg pointer(ptr_x,x)
9873 1.1 mrg
9874 1.1 mrg ptr_x = malloc(20*8)
9875 1.1 mrg do i = 1, 20
9876 1.1 mrg x(i) = sqrt(1.0d0 / i)
9877 1.1 mrg end do
9878 1.1 mrg z = 0
9879 1.1 mrg do i = 1, 20
9880 1.1 mrg z = z + x(i)
9881 1.1 mrg print *, z
9882 1.1 mrg end do
9883 1.1 mrg call free(ptr_x)
9884 1.1 mrg end program test_malloc
9885 1.1 mrg @end smallexample
9886 1.1 mrg
9887 1.1 mrg @item @emph{See also}:
9888 1.1 mrg @ref{FREE}
9889 1.1 mrg @end table
9890 1.1 mrg
9891 1.1 mrg
9892 1.1 mrg
9893 1.1 mrg @node MASKL
9894 1.1 mrg @section @code{MASKL} --- Left justified mask
9895 1.1 mrg @fnindex MASKL
9896 1.1 mrg @cindex mask, left justified
9897 1.1 mrg
9898 1.1 mrg @table @asis
9899 1.1 mrg @item @emph{Description}:
9900 1.1 mrg @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
9901 1.1 mrg remaining bits set to 0.
9902 1.1 mrg
9903 1.1 mrg @item @emph{Standard}:
9904 1.1 mrg Fortran 2008 and later
9905 1.1 mrg
9906 1.1 mrg @item @emph{Class}:
9907 1.1 mrg Elemental function
9908 1.1 mrg
9909 1.1 mrg @item @emph{Syntax}:
9910 1.1 mrg @code{RESULT = MASKL(I[, KIND])}
9911 1.1 mrg
9912 1.1 mrg @item @emph{Arguments}:
9913 1.1 mrg @multitable @columnfractions .15 .70
9914 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
9915 1.1 mrg @item @var{KIND} @tab Shall be a scalar constant expression of type
9916 1.1 mrg @code{INTEGER}.
9917 1.1 mrg @end multitable
9918 1.1 mrg
9919 1.1 mrg @item @emph{Return value}:
9920 1.1 mrg The return value is of type @code{INTEGER}. If @var{KIND} is present, it
9921 1.1 mrg specifies the kind value of the return type; otherwise, it is of the
9922 1.1 mrg default integer kind.
9923 1.1 mrg
9924 1.1 mrg @item @emph{See also}:
9925 1.1 mrg @ref{MASKR}
9926 1.1 mrg @end table
9927 1.1 mrg
9928 1.1 mrg
9929 1.1 mrg
9930 1.1 mrg @node MASKR
9931 1.1 mrg @section @code{MASKR} --- Right justified mask
9932 1.1 mrg @fnindex MASKR
9933 1.1 mrg @cindex mask, right justified
9934 1.1 mrg
9935 1.1 mrg @table @asis
9936 1.1 mrg @item @emph{Description}:
9937 1.1 mrg @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
9938 1.1 mrg remaining bits set to 0.
9939 1.1 mrg
9940 1.1 mrg @item @emph{Standard}:
9941 1.1 mrg Fortran 2008 and later
9942 1.1 mrg
9943 1.1 mrg @item @emph{Class}:
9944 1.1 mrg Elemental function
9945 1.1 mrg
9946 1.1 mrg @item @emph{Syntax}:
9947 1.1 mrg @code{RESULT = MASKR(I[, KIND])}
9948 1.1 mrg
9949 1.1 mrg @item @emph{Arguments}:
9950 1.1 mrg @multitable @columnfractions .15 .70
9951 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
9952 1.1 mrg @item @var{KIND} @tab Shall be a scalar constant expression of type
9953 1.1 mrg @code{INTEGER}.
9954 1.1 mrg @end multitable
9955 1.1 mrg
9956 1.1 mrg @item @emph{Return value}:
9957 1.1 mrg The return value is of type @code{INTEGER}. If @var{KIND} is present, it
9958 1.1 mrg specifies the kind value of the return type; otherwise, it is of the
9959 1.1 mrg default integer kind.
9960 1.1 mrg
9961 1.1 mrg @item @emph{See also}:
9962 1.1 mrg @ref{MASKL}
9963 1.1 mrg @end table
9964 1.1 mrg
9965 1.1 mrg
9966 1.1 mrg
9967 1.1 mrg @node MATMUL
9968 1.1 mrg @section @code{MATMUL} --- matrix multiplication
9969 1.1 mrg @fnindex MATMUL
9970 1.1 mrg @cindex matrix multiplication
9971 1.1 mrg @cindex product, matrix
9972 1.1 mrg
9973 1.1 mrg @table @asis
9974 1.1 mrg @item @emph{Description}:
9975 1.1 mrg Performs a matrix multiplication on numeric or logical arguments.
9976 1.1 mrg
9977 1.1 mrg @item @emph{Standard}:
9978 1.1 mrg Fortran 95 and later
9979 1.1 mrg
9980 1.1 mrg @item @emph{Class}:
9981 1.1 mrg Transformational function
9982 1.1 mrg
9983 1.1 mrg @item @emph{Syntax}:
9984 1.1 mrg @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
9985 1.1 mrg
9986 1.1 mrg @item @emph{Arguments}:
9987 1.1 mrg @multitable @columnfractions .15 .70
9988 1.1 mrg @item @var{MATRIX_A} @tab An array of @code{INTEGER},
9989 1.1 mrg @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
9990 1.1 mrg one or two.
9991 1.1 mrg @item @var{MATRIX_B} @tab An array of @code{INTEGER},
9992 1.1 mrg @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
9993 1.1 mrg type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
9994 1.1 mrg or two, and the first (or only) dimension of @var{MATRIX_B} shall be
9995 1.1 mrg equal to the last (or only) dimension of @var{MATRIX_A}.
9996 1.1 mrg @var{MATRIX_A} and @var{MATRIX_B} shall not both be rank one arrays.
9997 1.1 mrg @end multitable
9998 1.1 mrg
9999 1.1 mrg @item @emph{Return value}:
10000 1.1 mrg The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
10001 1.1 mrg kind of the result follow the usual type and kind promotion rules, as
10002 1.1 mrg for the @code{*} or @code{.AND.} operators.
10003 1.1 mrg
10004 1.1 mrg @item @emph{See also}:
10005 1.1 mrg @end table
10006 1.1 mrg
10007 1.1 mrg
10008 1.1 mrg
10009 1.1 mrg @node MAX
10010 1.1 mrg @section @code{MAX} --- Maximum value of an argument list
10011 1.1 mrg @fnindex MAX
10012 1.1 mrg @fnindex MAX0
10013 1.1 mrg @fnindex AMAX0
10014 1.1 mrg @fnindex MAX1
10015 1.1 mrg @fnindex AMAX1
10016 1.1 mrg @fnindex DMAX1
10017 1.1 mrg @cindex maximum value
10018 1.1 mrg
10019 1.1 mrg @table @asis
10020 1.1 mrg @item @emph{Description}:
10021 1.1 mrg Returns the argument with the largest (most positive) value.
10022 1.1 mrg
10023 1.1 mrg @item @emph{Standard}:
10024 1.1 mrg Fortran 77 and later
10025 1.1 mrg
10026 1.1 mrg @item @emph{Class}:
10027 1.1 mrg Elemental function
10028 1.1 mrg
10029 1.1 mrg @item @emph{Syntax}:
10030 1.1 mrg @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
10031 1.1 mrg
10032 1.1 mrg @item @emph{Arguments}:
10033 1.1 mrg @multitable @columnfractions .15 .70
10034 1.1 mrg @item @var{A1} @tab The type shall be @code{INTEGER} or
10035 1.1 mrg @code{REAL}.
10036 1.1 mrg @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10037 1.1 mrg as @var{A1}. (As a GNU extension, arguments of different kinds are
10038 1.1 mrg permitted.)
10039 1.1 mrg @end multitable
10040 1.1 mrg
10041 1.1 mrg @item @emph{Return value}:
10042 1.1 mrg The return value corresponds to the maximum value among the arguments,
10043 1.1 mrg and has the same type and kind as the first argument.
10044 1.1 mrg
10045 1.1 mrg @item @emph{Specific names}:
10046 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
10047 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
10048 1.1 mrg @item @code{MAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10049 1.1 mrg @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
10050 1.1 mrg @item @code{MAX1(A1)} @tab @code{REAL A1} @tab @code{INT(MAX(X))} @tab Fortran 77 and later
10051 1.1 mrg @item @code{AMAX1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10052 1.1 mrg @item @code{DMAX1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10053 1.1 mrg @end multitable
10054 1.1 mrg
10055 1.1 mrg @item @emph{See also}:
10056 1.1 mrg @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
10057 1.1 mrg
10058 1.1 mrg @end table
10059 1.1 mrg
10060 1.1 mrg
10061 1.1 mrg
10062 1.1 mrg @node MAXEXPONENT
10063 1.1 mrg @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
10064 1.1 mrg @fnindex MAXEXPONENT
10065 1.1 mrg @cindex model representation, maximum exponent
10066 1.1 mrg
10067 1.1 mrg @table @asis
10068 1.1 mrg @item @emph{Description}:
10069 1.1 mrg @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
10070 1.1 mrg type of @code{X}.
10071 1.1 mrg
10072 1.1 mrg @item @emph{Standard}:
10073 1.1 mrg Fortran 95 and later
10074 1.1 mrg
10075 1.1 mrg @item @emph{Class}:
10076 1.1 mrg Inquiry function
10077 1.1 mrg
10078 1.1 mrg @item @emph{Syntax}:
10079 1.1 mrg @code{RESULT = MAXEXPONENT(X)}
10080 1.1 mrg
10081 1.1 mrg @item @emph{Arguments}:
10082 1.1 mrg @multitable @columnfractions .15 .70
10083 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
10084 1.1 mrg @end multitable
10085 1.1 mrg
10086 1.1 mrg @item @emph{Return value}:
10087 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
10088 1.1 mrg kind.
10089 1.1 mrg
10090 1.1 mrg @item @emph{Example}:
10091 1.1 mrg @smallexample
10092 1.1 mrg program exponents
10093 1.1 mrg real(kind=4) :: x
10094 1.1 mrg real(kind=8) :: y
10095 1.1 mrg
10096 1.1 mrg print *, minexponent(x), maxexponent(x)
10097 1.1 mrg print *, minexponent(y), maxexponent(y)
10098 1.1 mrg end program exponents
10099 1.1 mrg @end smallexample
10100 1.1 mrg @end table
10101 1.1 mrg
10102 1.1 mrg
10103 1.1 mrg
10104 1.1 mrg @node MAXLOC
10105 1.1 mrg @section @code{MAXLOC} --- Location of the maximum value within an array
10106 1.1 mrg @fnindex MAXLOC
10107 1.1 mrg @cindex array, location of maximum element
10108 1.1 mrg
10109 1.1 mrg @table @asis
10110 1.1 mrg @item @emph{Description}:
10111 1.1 mrg Determines the location of the element in the array with the maximum
10112 1.1 mrg value, or, if the @var{DIM} argument is supplied, determines the
10113 1.1 mrg locations of the maximum element along each row of the array in the
10114 1.1 mrg @var{DIM} direction. If @var{MASK} is present, only the elements for
10115 1.1 mrg which @var{MASK} is @code{.TRUE.} are considered. If more than one
10116 1.1 mrg element in the array has the maximum value, the location returned is
10117 1.1 mrg that of the first such element in array element order if the
10118 1.1 mrg @var{BACK} is not present, or is false; if @var{BACK} is true, the location
10119 1.1 mrg returned is that of the last such element. If the array has zero
10120 1.1 mrg size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10121 1.1 mrg the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10122 1.1 mrg and all of the elements of @var{MASK} along a given row are zero, the
10123 1.1 mrg result value for that row is zero.
10124 1.1 mrg
10125 1.1 mrg @item @emph{Standard}:
10126 1.1 mrg Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the
10127 1.1 mrg @var{KIND} argument are available in Fortran 2003 and later.
10128 1.1 mrg The @var{BACK} argument is available in Fortran 2008 and later.
10129 1.1 mrg
10130 1.1 mrg @item @emph{Class}:
10131 1.1 mrg Transformational function
10132 1.1 mrg
10133 1.1 mrg @item @emph{Syntax}:
10134 1.1 mrg @multitable @columnfractions .80
10135 1.1 mrg @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10136 1.1 mrg @item @code{RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])}
10137 1.1 mrg @end multitable
10138 1.1 mrg
10139 1.1 mrg @item @emph{Arguments}:
10140 1.1 mrg @multitable @columnfractions .15 .70
10141 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10142 1.1 mrg @code{REAL}.
10143 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
10144 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10145 1.1 mrg inclusive. It may not be an optional dummy argument.
10146 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10147 1.1 mrg and conformable with @var{ARRAY}.
10148 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10149 1.1 mrg expression indicating the kind parameter of the result.
10150 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10151 1.1 mrg @end multitable
10152 1.1 mrg
10153 1.1 mrg @item @emph{Return value}:
10154 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length
10155 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10156 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a
10157 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM}
10158 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10159 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND}
10160 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it
10161 1.1 mrg is of default kind.
10162 1.1 mrg
10163 1.1 mrg @item @emph{See also}:
10164 1.1 mrg @ref{FINDLOC}, @ref{MAX}, @ref{MAXVAL}
10165 1.1 mrg
10166 1.1 mrg @end table
10167 1.1 mrg
10168 1.1 mrg
10169 1.1 mrg
10170 1.1 mrg @node MAXVAL
10171 1.1 mrg @section @code{MAXVAL} --- Maximum value of an array
10172 1.1 mrg @fnindex MAXVAL
10173 1.1 mrg @cindex array, maximum value
10174 1.1 mrg @cindex maximum value
10175 1.1 mrg
10176 1.1 mrg @table @asis
10177 1.1 mrg @item @emph{Description}:
10178 1.1 mrg Determines the maximum value of the elements in an array value, or, if
10179 1.1 mrg the @var{DIM} argument is supplied, determines the maximum value along
10180 1.1 mrg each row of the array in the @var{DIM} direction. If @var{MASK} is
10181 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are
10182 1.1 mrg considered. If the array has zero size, or all of the elements of
10183 1.1 mrg @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
10184 1.1 mrg if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
10185 1.1 mrg type.
10186 1.1 mrg
10187 1.1 mrg @item @emph{Standard}:
10188 1.1 mrg Fortran 95 and later
10189 1.1 mrg
10190 1.1 mrg @item @emph{Class}:
10191 1.1 mrg Transformational function
10192 1.1 mrg
10193 1.1 mrg @item @emph{Syntax}:
10194 1.1 mrg @multitable @columnfractions .80
10195 1.1 mrg @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
10196 1.1 mrg @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
10197 1.1 mrg @end multitable
10198 1.1 mrg
10199 1.1 mrg @item @emph{Arguments}:
10200 1.1 mrg @multitable @columnfractions .15 .70
10201 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10202 1.1 mrg @code{REAL}.
10203 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
10204 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10205 1.1 mrg inclusive. It may not be an optional dummy argument.
10206 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10207 1.1 mrg and conformable with @var{ARRAY}.
10208 1.1 mrg @end multitable
10209 1.1 mrg
10210 1.1 mrg @item @emph{Return value}:
10211 1.1 mrg If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10212 1.1 mrg is a scalar. If @var{DIM} is present, the result is an array with a
10213 1.1 mrg rank one less than the rank of @var{ARRAY}, and a size corresponding to
10214 1.1 mrg the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10215 1.1 mrg cases, the result is of the same type and kind as @var{ARRAY}.
10216 1.1 mrg
10217 1.1 mrg @item @emph{See also}:
10218 1.1 mrg @ref{MAX}, @ref{MAXLOC}
10219 1.1 mrg @end table
10220 1.1 mrg
10221 1.1 mrg
10222 1.1 mrg
10223 1.1 mrg @node MCLOCK
10224 1.1 mrg @section @code{MCLOCK} --- Time function
10225 1.1 mrg @fnindex MCLOCK
10226 1.1 mrg @cindex time, clock ticks
10227 1.1 mrg @cindex clock ticks
10228 1.1 mrg
10229 1.1 mrg @table @asis
10230 1.1 mrg @item @emph{Description}:
10231 1.1 mrg Returns the number of clock ticks since the start of the process, based
10232 1.1 mrg on the function @code{clock(3)} in the C standard library.
10233 1.1 mrg
10234 1.1 mrg This intrinsic is not fully portable, such as to systems with 32-bit
10235 1.1 mrg @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10236 1.1 mrg the values returned by this intrinsic might be, or become, negative, or
10237 1.1 mrg numerically less than previous values, during a single run of the
10238 1.1 mrg compiled program.
10239 1.1 mrg
10240 1.1 mrg @item @emph{Standard}:
10241 1.1 mrg GNU extension
10242 1.1 mrg
10243 1.1 mrg @item @emph{Class}:
10244 1.1 mrg Function
10245 1.1 mrg
10246 1.1 mrg @item @emph{Syntax}:
10247 1.1 mrg @code{RESULT = MCLOCK()}
10248 1.1 mrg
10249 1.1 mrg @item @emph{Return value}:
10250 1.1 mrg The return value is a scalar of type @code{INTEGER(4)}, equal to the
10251 1.1 mrg number of clock ticks since the start of the process, or @code{-1} if
10252 1.1 mrg the system does not support @code{clock(3)}.
10253 1.1 mrg
10254 1.1 mrg @item @emph{See also}:
10255 1.1 mrg @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
10256 1.1 mrg
10257 1.1 mrg @end table
10258 1.1 mrg
10259 1.1 mrg
10260 1.1 mrg
10261 1.1 mrg @node MCLOCK8
10262 1.1 mrg @section @code{MCLOCK8} --- Time function (64-bit)
10263 1.1 mrg @fnindex MCLOCK8
10264 1.1 mrg @cindex time, clock ticks
10265 1.1 mrg @cindex clock ticks
10266 1.1 mrg
10267 1.1 mrg @table @asis
10268 1.1 mrg @item @emph{Description}:
10269 1.1 mrg Returns the number of clock ticks since the start of the process, based
10270 1.1 mrg on the function @code{clock(3)} in the C standard library.
10271 1.1 mrg
10272 1.1 mrg @emph{Warning:} this intrinsic does not increase the range of the timing
10273 1.1 mrg values over that returned by @code{clock(3)}. On a system with a 32-bit
10274 1.1 mrg @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
10275 1.1 mrg it is converted to a 64-bit @code{INTEGER(8)} value. That means
10276 1.1 mrg overflows of the 32-bit value can still occur. Therefore, the values
10277 1.1 mrg returned by this intrinsic might be or become negative or numerically
10278 1.1 mrg less than previous values during a single run of the compiled program.
10279 1.1 mrg
10280 1.1 mrg @item @emph{Standard}:
10281 1.1 mrg GNU extension
10282 1.1 mrg
10283 1.1 mrg @item @emph{Class}:
10284 1.1 mrg Function
10285 1.1 mrg
10286 1.1 mrg @item @emph{Syntax}:
10287 1.1 mrg @code{RESULT = MCLOCK8()}
10288 1.1 mrg
10289 1.1 mrg @item @emph{Return value}:
10290 1.1 mrg The return value is a scalar of type @code{INTEGER(8)}, equal to the
10291 1.1 mrg number of clock ticks since the start of the process, or @code{-1} if
10292 1.1 mrg the system does not support @code{clock(3)}.
10293 1.1 mrg
10294 1.1 mrg @item @emph{See also}:
10295 1.1 mrg @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
10296 1.1 mrg
10297 1.1 mrg @end table
10298 1.1 mrg
10299 1.1 mrg
10300 1.1 mrg
10301 1.1 mrg @node MERGE
10302 1.1 mrg @section @code{MERGE} --- Merge variables
10303 1.1 mrg @fnindex MERGE
10304 1.1 mrg @cindex array, merge arrays
10305 1.1 mrg @cindex array, combine arrays
10306 1.1 mrg
10307 1.1 mrg @table @asis
10308 1.1 mrg @item @emph{Description}:
10309 1.1 mrg Select values from two arrays according to a logical mask. The result
10310 1.1 mrg is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
10311 1.1 mrg @var{FSOURCE} if it is @code{.FALSE.}.
10312 1.1 mrg
10313 1.1 mrg @item @emph{Standard}:
10314 1.1 mrg Fortran 95 and later
10315 1.1 mrg
10316 1.1 mrg @item @emph{Class}:
10317 1.1 mrg Elemental function
10318 1.1 mrg
10319 1.1 mrg @item @emph{Syntax}:
10320 1.1 mrg @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
10321 1.1 mrg
10322 1.1 mrg @item @emph{Arguments}:
10323 1.1 mrg @multitable @columnfractions .15 .70
10324 1.1 mrg @item @var{TSOURCE} @tab May be of any type.
10325 1.1 mrg @item @var{FSOURCE} @tab Shall be of the same type and type parameters
10326 1.1 mrg as @var{TSOURCE}.
10327 1.1 mrg @item @var{MASK} @tab Shall be of type @code{LOGICAL}.
10328 1.1 mrg @end multitable
10329 1.1 mrg
10330 1.1 mrg @item @emph{Return value}:
10331 1.1 mrg The result is of the same type and type parameters as @var{TSOURCE}.
10332 1.1 mrg
10333 1.1 mrg @end table
10334 1.1 mrg
10335 1.1 mrg
10336 1.1 mrg
10337 1.1 mrg @node MERGE_BITS
10338 1.1 mrg @section @code{MERGE_BITS} --- Merge of bits under mask
10339 1.1 mrg @fnindex MERGE_BITS
10340 1.1 mrg @cindex bits, merge
10341 1.1 mrg
10342 1.1 mrg @table @asis
10343 1.1 mrg @item @emph{Description}:
10344 1.1 mrg @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
10345 1.1 mrg as determined by the mask. The i-th bit of the result is equal to the
10346 1.1 mrg i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
10347 1.1 mrg the i-th bit of @var{J} otherwise.
10348 1.1 mrg
10349 1.1 mrg @item @emph{Standard}:
10350 1.1 mrg Fortran 2008 and later
10351 1.1 mrg
10352 1.1 mrg @item @emph{Class}:
10353 1.1 mrg Elemental function
10354 1.1 mrg
10355 1.1 mrg @item @emph{Syntax}:
10356 1.1 mrg @code{RESULT = MERGE_BITS(I, J, MASK)}
10357 1.1 mrg
10358 1.1 mrg @item @emph{Arguments}:
10359 1.1 mrg @multitable @columnfractions .15 .70
10360 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a boz-literal-constant.
10361 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} with the same
10362 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant.
10363 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants.
10364 1.1 mrg @item @var{MASK} @tab Shall be of type @code{INTEGER} or a boz-literal-constant
10365 1.1 mrg and of the same kind as @var{I}.
10366 1.1 mrg @end multitable
10367 1.1 mrg
10368 1.1 mrg @item @emph{Return value}:
10369 1.1 mrg The result is of the same type and kind as @var{I}.
10370 1.1 mrg
10371 1.1 mrg @end table
10372 1.1 mrg
10373 1.1 mrg
10374 1.1 mrg
10375 1.1 mrg @node MIN
10376 1.1 mrg @section @code{MIN} --- Minimum value of an argument list
10377 1.1 mrg @fnindex MIN
10378 1.1 mrg @fnindex MIN0
10379 1.1 mrg @fnindex AMIN0
10380 1.1 mrg @fnindex MIN1
10381 1.1 mrg @fnindex AMIN1
10382 1.1 mrg @fnindex DMIN1
10383 1.1 mrg @cindex minimum value
10384 1.1 mrg
10385 1.1 mrg @table @asis
10386 1.1 mrg @item @emph{Description}:
10387 1.1 mrg Returns the argument with the smallest (most negative) value.
10388 1.1 mrg
10389 1.1 mrg @item @emph{Standard}:
10390 1.1 mrg Fortran 77 and later
10391 1.1 mrg
10392 1.1 mrg @item @emph{Class}:
10393 1.1 mrg Elemental function
10394 1.1 mrg
10395 1.1 mrg @item @emph{Syntax}:
10396 1.1 mrg @code{RESULT = MIN(A1, A2 [, A3, ...])}
10397 1.1 mrg
10398 1.1 mrg @item @emph{Arguments}:
10399 1.1 mrg @multitable @columnfractions .15 .70
10400 1.1 mrg @item @var{A1} @tab The type shall be @code{INTEGER} or
10401 1.1 mrg @code{REAL}.
10402 1.1 mrg @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10403 1.1 mrg as @var{A1}. (As a GNU extension, arguments of different kinds are
10404 1.1 mrg permitted.)
10405 1.1 mrg @end multitable
10406 1.1 mrg
10407 1.1 mrg @item @emph{Return value}:
10408 1.1 mrg The return value corresponds to the maximum value among the arguments,
10409 1.1 mrg and has the same type and kind as the first argument.
10410 1.1 mrg
10411 1.1 mrg @item @emph{Specific names}:
10412 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
10413 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
10414 1.1 mrg @item @code{MIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10415 1.1 mrg @item @code{AMIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10416 1.1 mrg @item @code{MIN1(A1)} @tab @code{REAL A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10417 1.1 mrg @item @code{AMIN1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10418 1.1 mrg @item @code{DMIN1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10419 1.1 mrg @end multitable
10420 1.1 mrg
10421 1.1 mrg @item @emph{See also}:
10422 1.1 mrg @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
10423 1.1 mrg @end table
10424 1.1 mrg
10425 1.1 mrg
10426 1.1 mrg
10427 1.1 mrg @node MINEXPONENT
10428 1.1 mrg @section @code{MINEXPONENT} --- Minimum exponent of a real kind
10429 1.1 mrg @fnindex MINEXPONENT
10430 1.1 mrg @cindex model representation, minimum exponent
10431 1.1 mrg
10432 1.1 mrg @table @asis
10433 1.1 mrg @item @emph{Description}:
10434 1.1 mrg @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
10435 1.1 mrg type of @code{X}.
10436 1.1 mrg
10437 1.1 mrg @item @emph{Standard}:
10438 1.1 mrg Fortran 95 and later
10439 1.1 mrg
10440 1.1 mrg @item @emph{Class}:
10441 1.1 mrg Inquiry function
10442 1.1 mrg
10443 1.1 mrg @item @emph{Syntax}:
10444 1.1 mrg @code{RESULT = MINEXPONENT(X)}
10445 1.1 mrg
10446 1.1 mrg @item @emph{Arguments}:
10447 1.1 mrg @multitable @columnfractions .15 .70
10448 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
10449 1.1 mrg @end multitable
10450 1.1 mrg
10451 1.1 mrg @item @emph{Return value}:
10452 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
10453 1.1 mrg kind.
10454 1.1 mrg
10455 1.1 mrg @item @emph{Example}:
10456 1.1 mrg See @code{MAXEXPONENT} for an example.
10457 1.1 mrg @end table
10458 1.1 mrg
10459 1.1 mrg
10460 1.1 mrg
10461 1.1 mrg @node MINLOC
10462 1.1 mrg @section @code{MINLOC} --- Location of the minimum value within an array
10463 1.1 mrg @fnindex MINLOC
10464 1.1 mrg @cindex array, location of minimum element
10465 1.1 mrg
10466 1.1 mrg @table @asis
10467 1.1 mrg @item @emph{Description}:
10468 1.1 mrg Determines the location of the element in the array with the minimum
10469 1.1 mrg value, or, if the @var{DIM} argument is supplied, determines the
10470 1.1 mrg locations of the minimum element along each row of the array in the
10471 1.1 mrg @var{DIM} direction. If @var{MASK} is present, only the elements for
10472 1.1 mrg which @var{MASK} is @code{.TRUE.} are considered. If more than one
10473 1.1 mrg element in the array has the minimum value, the location returned is
10474 1.1 mrg that of the first such element in array element order if the
10475 1.1 mrg @var{BACK} is not present, or is false; if @var{BACK} is true, the location
10476 1.1 mrg returned is that of the last such element. If the array has
10477 1.1 mrg zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10478 1.1 mrg the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10479 1.1 mrg and all of the elements of @var{MASK} along a given row are zero, the
10480 1.1 mrg result value for that row is zero.
10481 1.1 mrg
10482 1.1 mrg @item @emph{Standard}:
10483 1.1 mrg Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the
10484 1.1 mrg @var{KIND} argument are available in Fortran 2003 and later.
10485 1.1 mrg The @var{BACK} argument is available in Fortran 2008 and later.
10486 1.1 mrg
10487 1.1 mrg @item @emph{Class}:
10488 1.1 mrg Transformational function
10489 1.1 mrg
10490 1.1 mrg @item @emph{Syntax}:
10491 1.1 mrg @multitable @columnfractions .80
10492 1.1 mrg @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10493 1.1 mrg @item @code{RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK])}
10494 1.1 mrg @end multitable
10495 1.1 mrg
10496 1.1 mrg @item @emph{Arguments}:
10497 1.1 mrg @multitable @columnfractions .15 .70
10498 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
10499 1.1 mrg @code{REAL} or @code{CHARACTER}.
10500 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
10501 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10502 1.1 mrg inclusive. It may not be an optional dummy argument.
10503 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10504 1.1 mrg and conformable with @var{ARRAY}.
10505 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10506 1.1 mrg expression indicating the kind parameter of the result.
10507 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10508 1.1 mrg @end multitable
10509 1.1 mrg
10510 1.1 mrg @item @emph{Return value}:
10511 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length
10512 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10513 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a
10514 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM}
10515 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10516 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND}
10517 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it
10518 1.1 mrg is of default kind.
10519 1.1 mrg
10520 1.1 mrg @item @emph{See also}:
10521 1.1 mrg @ref{FINDLOC}, @ref{MIN}, @ref{MINVAL}
10522 1.1 mrg
10523 1.1 mrg @end table
10524 1.1 mrg
10525 1.1 mrg
10526 1.1 mrg
10527 1.1 mrg @node MINVAL
10528 1.1 mrg @section @code{MINVAL} --- Minimum value of an array
10529 1.1 mrg @fnindex MINVAL
10530 1.1 mrg @cindex array, minimum value
10531 1.1 mrg @cindex minimum value
10532 1.1 mrg
10533 1.1 mrg @table @asis
10534 1.1 mrg @item @emph{Description}:
10535 1.1 mrg Determines the minimum value of the elements in an array value, or, if
10536 1.1 mrg the @var{DIM} argument is supplied, determines the minimum value along
10537 1.1 mrg each row of the array in the @var{DIM} direction. If @var{MASK} is
10538 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are
10539 1.1 mrg considered. If the array has zero size, or all of the elements of
10540 1.1 mrg @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
10541 1.1 mrg @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
10542 1.1 mrg @var{ARRAY} is of character type.
10543 1.1 mrg
10544 1.1 mrg @item @emph{Standard}:
10545 1.1 mrg Fortran 95 and later
10546 1.1 mrg
10547 1.1 mrg @item @emph{Class}:
10548 1.1 mrg Transformational function
10549 1.1 mrg
10550 1.1 mrg @item @emph{Syntax}:
10551 1.1 mrg @multitable @columnfractions .80
10552 1.1 mrg @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
10553 1.1 mrg @item @code{RESULT = MINVAL(ARRAY [, MASK])}
10554 1.1 mrg @end multitable
10555 1.1 mrg
10556 1.1 mrg @item @emph{Arguments}:
10557 1.1 mrg @multitable @columnfractions .15 .70
10558 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10559 1.1 mrg @code{REAL}.
10560 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type
10561 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10562 1.1 mrg inclusive. It may not be an optional dummy argument.
10563 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10564 1.1 mrg and conformable with @var{ARRAY}.
10565 1.1 mrg @end multitable
10566 1.1 mrg
10567 1.1 mrg @item @emph{Return value}:
10568 1.1 mrg If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10569 1.1 mrg is a scalar. If @var{DIM} is present, the result is an array with a
10570 1.1 mrg rank one less than the rank of @var{ARRAY}, and a size corresponding to
10571 1.1 mrg the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10572 1.1 mrg cases, the result is of the same type and kind as @var{ARRAY}.
10573 1.1 mrg
10574 1.1 mrg @item @emph{See also}:
10575 1.1 mrg @ref{MIN}, @ref{MINLOC}
10576 1.1 mrg
10577 1.1 mrg @end table
10578 1.1 mrg
10579 1.1 mrg
10580 1.1 mrg
10581 1.1 mrg @node MOD
10582 1.1 mrg @section @code{MOD} --- Remainder function
10583 1.1 mrg @fnindex MOD
10584 1.1 mrg @fnindex AMOD
10585 1.1 mrg @fnindex DMOD
10586 1.1 mrg @fnindex BMOD
10587 1.1 mrg @fnindex IMOD
10588 1.1 mrg @fnindex JMOD
10589 1.1 mrg @fnindex KMOD
10590 1.1 mrg @cindex remainder
10591 1.1 mrg @cindex division, remainder
10592 1.1 mrg
10593 1.1 mrg @table @asis
10594 1.1 mrg @item @emph{Description}:
10595 1.1 mrg @code{MOD(A,P)} computes the remainder of the division of A by P@.
10596 1.1 mrg
10597 1.1 mrg @item @emph{Standard}:
10598 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions
10599 1.1 mrg
10600 1.1 mrg @item @emph{Class}:
10601 1.1 mrg Elemental function
10602 1.1 mrg
10603 1.1 mrg @item @emph{Syntax}:
10604 1.1 mrg @code{RESULT = MOD(A, P)}
10605 1.1 mrg
10606 1.1 mrg @item @emph{Arguments}:
10607 1.1 mrg @multitable @columnfractions .15 .70
10608 1.1 mrg @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10609 1.1 mrg @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
10610 1.1 mrg and not equal to zero.
10611 1.1 mrg @end multitable
10612 1.1 mrg
10613 1.1 mrg @item @emph{Return value}:
10614 1.1 mrg The return value is the result of @code{A - (INT(A/P) * P)}. The type
10615 1.1 mrg and kind of the return value is the same as that of the arguments. The
10616 1.1 mrg returned value has the same sign as A and a magnitude less than the
10617 1.1 mrg magnitude of P.
10618 1.1 mrg
10619 1.1 mrg @item @emph{Example}:
10620 1.1 mrg @smallexample
10621 1.1 mrg program test_mod
10622 1.1 mrg print *, mod(17,3)
10623 1.1 mrg print *, mod(17.5,5.5)
10624 1.1 mrg print *, mod(17.5d0,5.5)
10625 1.1 mrg print *, mod(17.5,5.5d0)
10626 1.1 mrg
10627 1.1 mrg print *, mod(-17,3)
10628 1.1 mrg print *, mod(-17.5,5.5)
10629 1.1 mrg print *, mod(-17.5d0,5.5)
10630 1.1 mrg print *, mod(-17.5,5.5d0)
10631 1.1 mrg
10632 1.1 mrg print *, mod(17,-3)
10633 1.1 mrg print *, mod(17.5,-5.5)
10634 1.1 mrg print *, mod(17.5d0,-5.5)
10635 1.1 mrg print *, mod(17.5,-5.5d0)
10636 1.1 mrg end program test_mod
10637 1.1 mrg @end smallexample
10638 1.1 mrg
10639 1.1 mrg @item @emph{Specific names}:
10640 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
10641 1.1 mrg @item Name @tab Arguments @tab Return type @tab Standard
10642 1.1 mrg @item @code{MOD(A,P)} @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
10643 1.1 mrg @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
10644 1.1 mrg @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
10645 1.1 mrg @item @code{BMOD(A,P)} @tab @code{INTEGER(1) A,P} @tab @code{INTEGER(1)} @tab GNU extension
10646 1.1 mrg @item @code{IMOD(A,P)} @tab @code{INTEGER(2) A,P} @tab @code{INTEGER(2)} @tab GNU extension
10647 1.1 mrg @item @code{JMOD(A,P)} @tab @code{INTEGER(4) A,P} @tab @code{INTEGER(4)} @tab GNU extension
10648 1.1 mrg @item @code{KMOD(A,P)} @tab @code{INTEGER(8) A,P} @tab @code{INTEGER(8)} @tab GNU extension
10649 1.1 mrg @end multitable
10650 1.1 mrg
10651 1.1 mrg @item @emph{See also}:
10652 1.1 mrg @ref{MODULO}
10653 1.1 mrg
10654 1.1 mrg @end table
10655 1.1 mrg
10656 1.1 mrg
10657 1.1 mrg
10658 1.1 mrg @node MODULO
10659 1.1 mrg @section @code{MODULO} --- Modulo function
10660 1.1 mrg @fnindex MODULO
10661 1.1 mrg @cindex modulo
10662 1.1 mrg @cindex division, modulo
10663 1.1 mrg
10664 1.1 mrg @table @asis
10665 1.1 mrg @item @emph{Description}:
10666 1.1 mrg @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
10667 1.1 mrg
10668 1.1 mrg @item @emph{Standard}:
10669 1.1 mrg Fortran 95 and later
10670 1.1 mrg
10671 1.1 mrg @item @emph{Class}:
10672 1.1 mrg Elemental function
10673 1.1 mrg
10674 1.1 mrg @item @emph{Syntax}:
10675 1.1 mrg @code{RESULT = MODULO(A, P)}
10676 1.1 mrg
10677 1.1 mrg @item @emph{Arguments}:
10678 1.1 mrg @multitable @columnfractions .15 .70
10679 1.1 mrg @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10680 1.1 mrg @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}.
10681 1.1 mrg It shall not be zero.
10682 1.1 mrg @end multitable
10683 1.1 mrg
10684 1.1 mrg @item @emph{Return value}:
10685 1.1 mrg The type and kind of the result are those of the arguments.
10686 1.1 mrg @table @asis
10687 1.1 mrg @item If @var{A} and @var{P} are of type @code{INTEGER}:
10688 1.1 mrg @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
10689 1.1 mrg @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
10690 1.1 mrg (exclusive).
10691 1.1 mrg @item If @var{A} and @var{P} are of type @code{REAL}:
10692 1.1 mrg @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
10693 1.1 mrg @end table
10694 1.1 mrg The returned value has the same sign as P and a magnitude less than
10695 1.1 mrg the magnitude of P.
10696 1.1 mrg
10697 1.1 mrg @item @emph{Example}:
10698 1.1 mrg @smallexample
10699 1.1 mrg program test_modulo
10700 1.1 mrg print *, modulo(17,3)
10701 1.1 mrg print *, modulo(17.5,5.5)
10702 1.1 mrg
10703 1.1 mrg print *, modulo(-17,3)
10704 1.1 mrg print *, modulo(-17.5,5.5)
10705 1.1 mrg
10706 1.1 mrg print *, modulo(17,-3)
10707 1.1 mrg print *, modulo(17.5,-5.5)
10708 1.1 mrg end program
10709 1.1 mrg @end smallexample
10710 1.1 mrg
10711 1.1 mrg @item @emph{See also}:
10712 1.1 mrg @ref{MOD}
10713 1.1 mrg
10714 1.1 mrg @end table
10715 1.1 mrg
10716 1.1 mrg
10717 1.1 mrg
10718 1.1 mrg @node MOVE_ALLOC
10719 1.1 mrg @section @code{MOVE_ALLOC} --- Move allocation from one object to another
10720 1.1 mrg @fnindex MOVE_ALLOC
10721 1.1 mrg @cindex moving allocation
10722 1.1 mrg @cindex allocation, moving
10723 1.1 mrg
10724 1.1 mrg @table @asis
10725 1.1 mrg @item @emph{Description}:
10726 1.1 mrg @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
10727 1.1 mrg @var{TO}. @var{FROM} will become deallocated in the process.
10728 1.1 mrg
10729 1.1 mrg @item @emph{Standard}:
10730 1.1 mrg Fortran 2003 and later
10731 1.1 mrg
10732 1.1 mrg @item @emph{Class}:
10733 1.1 mrg Pure subroutine
10734 1.1 mrg
10735 1.1 mrg @item @emph{Syntax}:
10736 1.1 mrg @code{CALL MOVE_ALLOC(FROM, TO)}
10737 1.1 mrg
10738 1.1 mrg @item @emph{Arguments}:
10739 1.1 mrg @multitable @columnfractions .15 .70
10740 1.1 mrg @item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
10741 1.1 mrg of any type and kind.
10742 1.1 mrg @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
10743 1.1 mrg of the same type, kind and rank as @var{FROM}.
10744 1.1 mrg @end multitable
10745 1.1 mrg
10746 1.1 mrg @item @emph{Return value}:
10747 1.1 mrg None
10748 1.1 mrg
10749 1.1 mrg @item @emph{Example}:
10750 1.1 mrg @smallexample
10751 1.1 mrg program test_move_alloc
10752 1.1 mrg integer, allocatable :: a(:), b(:)
10753 1.1 mrg
10754 1.1 mrg allocate(a(3))
10755 1.1 mrg a = [ 1, 2, 3 ]
10756 1.1 mrg call move_alloc(a, b)
10757 1.1 mrg print *, allocated(a), allocated(b)
10758 1.1 mrg print *, b
10759 1.1 mrg end program test_move_alloc
10760 1.1 mrg @end smallexample
10761 1.1 mrg @end table
10762 1.1 mrg
10763 1.1 mrg
10764 1.1 mrg
10765 1.1 mrg @node MVBITS
10766 1.1 mrg @section @code{MVBITS} --- Move bits from one integer to another
10767 1.1 mrg @fnindex MVBITS
10768 1.1 mrg @fnindex BMVBITS
10769 1.1 mrg @fnindex IMVBITS
10770 1.1 mrg @fnindex JMVBITS
10771 1.1 mrg @fnindex KMVBITS
10772 1.1 mrg @cindex bits, move
10773 1.1 mrg
10774 1.1 mrg @table @asis
10775 1.1 mrg @item @emph{Description}:
10776 1.1 mrg Moves @var{LEN} bits from positions @var{FROMPOS} through
10777 1.1 mrg @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
10778 1.1 mrg @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
10779 1.1 mrg affected by the movement of bits is unchanged. The values of
10780 1.1 mrg @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
10781 1.1 mrg @code{BIT_SIZE(FROM)}.
10782 1.1 mrg
10783 1.1 mrg @item @emph{Standard}:
10784 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
10785 1.1 mrg
10786 1.1 mrg @item @emph{Class}:
10787 1.1 mrg Elemental subroutine
10788 1.1 mrg
10789 1.1 mrg @item @emph{Syntax}:
10790 1.1 mrg @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
10791 1.1 mrg
10792 1.1 mrg @item @emph{Arguments}:
10793 1.1 mrg @multitable @columnfractions .15 .70
10794 1.1 mrg @item @var{FROM} @tab The type shall be @code{INTEGER}.
10795 1.1 mrg @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
10796 1.1 mrg @item @var{LEN} @tab The type shall be @code{INTEGER}.
10797 1.1 mrg @item @var{TO} @tab The type shall be @code{INTEGER}, of the
10798 1.1 mrg same kind as @var{FROM}.
10799 1.1 mrg @item @var{TOPOS} @tab The type shall be @code{INTEGER}.
10800 1.1 mrg @end multitable
10801 1.1 mrg
10802 1.1 mrg @item @emph{Specific names}:
10803 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
10804 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
10805 1.1 mrg @item @code{MVBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
10806 1.1 mrg @item @code{BMVBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
10807 1.1 mrg @item @code{IMVBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
10808 1.1 mrg @item @code{JMVBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
10809 1.1 mrg @item @code{KMVBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
10810 1.1 mrg @end multitable
10811 1.1 mrg
10812 1.1 mrg @item @emph{See also}:
10813 1.1 mrg @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
10814 1.1 mrg @end table
10815 1.1 mrg
10816 1.1 mrg
10817 1.1 mrg
10818 1.1 mrg @node NEAREST
10819 1.1 mrg @section @code{NEAREST} --- Nearest representable number
10820 1.1 mrg @fnindex NEAREST
10821 1.1 mrg @cindex real number, nearest different
10822 1.1 mrg @cindex floating point, nearest different
10823 1.1 mrg
10824 1.1 mrg @table @asis
10825 1.1 mrg @item @emph{Description}:
10826 1.1 mrg @code{NEAREST(X, S)} returns the processor-representable number nearest
10827 1.1 mrg to @code{X} in the direction indicated by the sign of @code{S}.
10828 1.1 mrg
10829 1.1 mrg @item @emph{Standard}:
10830 1.1 mrg Fortran 95 and later
10831 1.1 mrg
10832 1.1 mrg @item @emph{Class}:
10833 1.1 mrg Elemental function
10834 1.1 mrg
10835 1.1 mrg @item @emph{Syntax}:
10836 1.1 mrg @code{RESULT = NEAREST(X, S)}
10837 1.1 mrg
10838 1.1 mrg @item @emph{Arguments}:
10839 1.1 mrg @multitable @columnfractions .15 .70
10840 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
10841 1.1 mrg @item @var{S} @tab Shall be of type @code{REAL} and
10842 1.1 mrg not equal to zero.
10843 1.1 mrg @end multitable
10844 1.1 mrg
10845 1.1 mrg @item @emph{Return value}:
10846 1.1 mrg The return value is of the same type as @code{X}. If @code{S} is
10847 1.1 mrg positive, @code{NEAREST} returns the processor-representable number
10848 1.1 mrg greater than @code{X} and nearest to it. If @code{S} is negative,
10849 1.1 mrg @code{NEAREST} returns the processor-representable number smaller than
10850 1.1 mrg @code{X} and nearest to it.
10851 1.1 mrg
10852 1.1 mrg @item @emph{Example}:
10853 1.1 mrg @smallexample
10854 1.1 mrg program test_nearest
10855 1.1 mrg real :: x, y
10856 1.1 mrg x = nearest(42.0, 1.0)
10857 1.1 mrg y = nearest(42.0, -1.0)
10858 1.1 mrg write (*,"(3(G20.15))") x, y, x - y
10859 1.1 mrg end program test_nearest
10860 1.1 mrg @end smallexample
10861 1.1 mrg @end table
10862 1.1 mrg
10863 1.1 mrg
10864 1.1 mrg
10865 1.1 mrg @node NEW_LINE
10866 1.1 mrg @section @code{NEW_LINE} --- New line character
10867 1.1 mrg @fnindex NEW_LINE
10868 1.1 mrg @cindex newline
10869 1.1 mrg @cindex output, newline
10870 1.1 mrg
10871 1.1 mrg @table @asis
10872 1.1 mrg @item @emph{Description}:
10873 1.1 mrg @code{NEW_LINE(C)} returns the new-line character.
10874 1.1 mrg
10875 1.1 mrg @item @emph{Standard}:
10876 1.1 mrg Fortran 2003 and later
10877 1.1 mrg
10878 1.1 mrg @item @emph{Class}:
10879 1.1 mrg Inquiry function
10880 1.1 mrg
10881 1.1 mrg @item @emph{Syntax}:
10882 1.1 mrg @code{RESULT = NEW_LINE(C)}
10883 1.1 mrg
10884 1.1 mrg @item @emph{Arguments}:
10885 1.1 mrg @multitable @columnfractions .15 .70
10886 1.1 mrg @item @var{C} @tab The argument shall be a scalar or array of the
10887 1.1 mrg type @code{CHARACTER}.
10888 1.1 mrg @end multitable
10889 1.1 mrg
10890 1.1 mrg @item @emph{Return value}:
10891 1.1 mrg Returns a @var{CHARACTER} scalar of length one with the new-line character of
10892 1.1 mrg the same kind as parameter @var{C}.
10893 1.1 mrg
10894 1.1 mrg @item @emph{Example}:
10895 1.1 mrg @smallexample
10896 1.1 mrg program newline
10897 1.1 mrg implicit none
10898 1.1 mrg write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
10899 1.1 mrg end program newline
10900 1.1 mrg @end smallexample
10901 1.1 mrg @end table
10902 1.1 mrg
10903 1.1 mrg
10904 1.1 mrg
10905 1.1 mrg @node NINT
10906 1.1 mrg @section @code{NINT} --- Nearest whole number
10907 1.1 mrg @fnindex NINT
10908 1.1 mrg @fnindex IDNINT
10909 1.1 mrg @cindex rounding, nearest whole number
10910 1.1 mrg
10911 1.1 mrg @table @asis
10912 1.1 mrg @item @emph{Description}:
10913 1.1 mrg @code{NINT(A)} rounds its argument to the nearest whole number.
10914 1.1 mrg
10915 1.1 mrg @item @emph{Standard}:
10916 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
10917 1.1 mrg
10918 1.1 mrg @item @emph{Class}:
10919 1.1 mrg Elemental function
10920 1.1 mrg
10921 1.1 mrg @item @emph{Syntax}:
10922 1.1 mrg @code{RESULT = NINT(A [, KIND])}
10923 1.1 mrg
10924 1.1 mrg @item @emph{Arguments}:
10925 1.1 mrg @multitable @columnfractions .15 .70
10926 1.1 mrg @item @var{A} @tab The type of the argument shall be @code{REAL}.
10927 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10928 1.1 mrg expression indicating the kind parameter of the result.
10929 1.1 mrg @end multitable
10930 1.1 mrg
10931 1.1 mrg @item @emph{Return value}:
10932 1.1 mrg Returns @var{A} with the fractional portion of its magnitude eliminated by
10933 1.1 mrg rounding to the nearest whole number and with its sign preserved,
10934 1.1 mrg converted to an @code{INTEGER} of the default kind.
10935 1.1 mrg
10936 1.1 mrg @item @emph{Example}:
10937 1.1 mrg @smallexample
10938 1.1 mrg program test_nint
10939 1.1 mrg real(4) x4
10940 1.1 mrg real(8) x8
10941 1.1 mrg x4 = 1.234E0_4
10942 1.1 mrg x8 = 4.321_8
10943 1.1 mrg print *, nint(x4), idnint(x8)
10944 1.1 mrg end program test_nint
10945 1.1 mrg @end smallexample
10946 1.1 mrg
10947 1.1 mrg @item @emph{Specific names}:
10948 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
10949 1.1 mrg @item Name @tab Argument @tab Return Type @tab Standard
10950 1.1 mrg @item @code{NINT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 95 and later
10951 1.1 mrg @item @code{IDNINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 95 and later
10952 1.1 mrg @end multitable
10953 1.1 mrg
10954 1.1 mrg @item @emph{See also}:
10955 1.1 mrg @ref{CEILING}, @ref{FLOOR}
10956 1.1 mrg
10957 1.1 mrg @end table
10958 1.1 mrg
10959 1.1 mrg
10960 1.1 mrg
10961 1.1 mrg @node NORM2
10962 1.1 mrg @section @code{NORM2} --- Euclidean vector norms
10963 1.1 mrg @fnindex NORM2
10964 1.1 mrg @cindex Euclidean vector norm
10965 1.1 mrg @cindex L2 vector norm
10966 1.1 mrg @cindex norm, Euclidean
10967 1.1 mrg
10968 1.1 mrg @table @asis
10969 1.1 mrg @item @emph{Description}:
10970 1.1 mrg Calculates the Euclidean vector norm (@math{L_2} norm) of
10971 1.1 mrg of @var{ARRAY} along dimension @var{DIM}.
10972 1.1 mrg
10973 1.1 mrg @item @emph{Standard}:
10974 1.1 mrg Fortran 2008 and later
10975 1.1 mrg
10976 1.1 mrg @item @emph{Class}:
10977 1.1 mrg Transformational function
10978 1.1 mrg
10979 1.1 mrg @item @emph{Syntax}:
10980 1.1 mrg @multitable @columnfractions .80
10981 1.1 mrg @item @code{RESULT = NORM2(ARRAY[, DIM])}
10982 1.1 mrg @end multitable
10983 1.1 mrg
10984 1.1 mrg @item @emph{Arguments}:
10985 1.1 mrg @multitable @columnfractions .15 .70
10986 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
10987 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
10988 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
10989 1.1 mrg equals the rank of @var{ARRAY}.
10990 1.1 mrg @end multitable
10991 1.1 mrg
10992 1.1 mrg @item @emph{Return value}:
10993 1.1 mrg The result is of the same type as @var{ARRAY}.
10994 1.1 mrg
10995 1.1 mrg If @var{DIM} is absent, a scalar with the square root of the sum of all
10996 1.1 mrg elements in @var{ARRAY} squared is returned. Otherwise, an array of
10997 1.1 mrg rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
10998 1.1 mrg shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
10999 1.1 mrg is returned.
11000 1.1 mrg
11001 1.1 mrg @item @emph{Example}:
11002 1.1 mrg @smallexample
11003 1.1 mrg PROGRAM test_sum
11004 1.1 mrg REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
11005 1.1 mrg print *, NORM2(x) ! = sqrt(55.) ~ 7.416
11006 1.1 mrg END PROGRAM
11007 1.1 mrg @end smallexample
11008 1.1 mrg @end table
11009 1.1 mrg
11010 1.1 mrg
11011 1.1 mrg
11012 1.1 mrg @node NOT
11013 1.1 mrg @section @code{NOT} --- Logical negation
11014 1.1 mrg @fnindex NOT
11015 1.1 mrg @fnindex BNOT
11016 1.1 mrg @fnindex INOT
11017 1.1 mrg @fnindex JNOT
11018 1.1 mrg @fnindex KNOT
11019 1.1 mrg @cindex bits, negate
11020 1.1 mrg @cindex bitwise logical not
11021 1.1 mrg @cindex logical not, bitwise
11022 1.1 mrg
11023 1.1 mrg @table @asis
11024 1.1 mrg @item @emph{Description}:
11025 1.1 mrg @code{NOT} returns the bitwise Boolean inverse of @var{I}.
11026 1.1 mrg
11027 1.1 mrg @item @emph{Standard}:
11028 1.1 mrg Fortran 95 and later, has overloads that are GNU extensions
11029 1.1 mrg
11030 1.1 mrg @item @emph{Class}:
11031 1.1 mrg Elemental function
11032 1.1 mrg
11033 1.1 mrg @item @emph{Syntax}:
11034 1.1 mrg @code{RESULT = NOT(I)}
11035 1.1 mrg
11036 1.1 mrg @item @emph{Arguments}:
11037 1.1 mrg @multitable @columnfractions .15 .70
11038 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
11039 1.1 mrg @end multitable
11040 1.1 mrg
11041 1.1 mrg @item @emph{Return value}:
11042 1.1 mrg The return type is @code{INTEGER}, of the same kind as the
11043 1.1 mrg argument.
11044 1.1 mrg
11045 1.1 mrg @item @emph{Specific names}:
11046 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
11047 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
11048 1.1 mrg @item @code{NOT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
11049 1.1 mrg @item @code{BNOT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
11050 1.1 mrg @item @code{INOT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
11051 1.1 mrg @item @code{JNOT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
11052 1.1 mrg @item @code{KNOT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
11053 1.1 mrg @end multitable
11054 1.1 mrg
11055 1.1 mrg @item @emph{See also}:
11056 1.1 mrg @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
11057 1.1 mrg
11058 1.1 mrg @end table
11059 1.1 mrg
11060 1.1 mrg
11061 1.1 mrg
11062 1.1 mrg @node NULL
11063 1.1 mrg @section @code{NULL} --- Function that returns an disassociated pointer
11064 1.1 mrg @fnindex NULL
11065 1.1 mrg @cindex pointer, status
11066 1.1 mrg @cindex pointer, disassociated
11067 1.1 mrg
11068 1.1 mrg @table @asis
11069 1.1 mrg @item @emph{Description}:
11070 1.1 mrg Returns a disassociated pointer.
11071 1.1 mrg
11072 1.1 mrg If @var{MOLD} is present, a disassociated pointer of the same type is
11073 1.1 mrg returned, otherwise the type is determined by context.
11074 1.1 mrg
11075 1.1 mrg In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
11076 1.1 mrg includes cases where it is required.
11077 1.1 mrg
11078 1.1 mrg @item @emph{Standard}:
11079 1.1 mrg Fortran 95 and later
11080 1.1 mrg
11081 1.1 mrg @item @emph{Class}:
11082 1.1 mrg Transformational function
11083 1.1 mrg
11084 1.1 mrg @item @emph{Syntax}:
11085 1.1 mrg @code{PTR => NULL([MOLD])}
11086 1.1 mrg
11087 1.1 mrg @item @emph{Arguments}:
11088 1.1 mrg @multitable @columnfractions .15 .70
11089 1.1 mrg @item @var{MOLD} @tab (Optional) shall be a pointer of any association
11090 1.1 mrg status and of any type.
11091 1.1 mrg @end multitable
11092 1.1 mrg
11093 1.1 mrg @item @emph{Return value}:
11094 1.1 mrg A disassociated pointer.
11095 1.1 mrg
11096 1.1 mrg @item @emph{Example}:
11097 1.1 mrg @smallexample
11098 1.1 mrg REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
11099 1.1 mrg @end smallexample
11100 1.1 mrg
11101 1.1 mrg @item @emph{See also}:
11102 1.1 mrg @ref{ASSOCIATED}
11103 1.1 mrg @end table
11104 1.1 mrg
11105 1.1 mrg
11106 1.1 mrg
11107 1.1 mrg @node NUM_IMAGES
11108 1.1 mrg @section @code{NUM_IMAGES} --- Function that returns the number of images
11109 1.1 mrg @fnindex NUM_IMAGES
11110 1.1 mrg @cindex coarray, @code{NUM_IMAGES}
11111 1.1 mrg @cindex images, number of
11112 1.1 mrg
11113 1.1 mrg @table @asis
11114 1.1 mrg @item @emph{Description}:
11115 1.1 mrg Returns the number of images.
11116 1.1 mrg
11117 1.1 mrg @item @emph{Standard}:
11118 1.1 mrg Fortran 2008 and later. With @var{DISTANCE} or @var{FAILED} argument,
11119 1.1 mrg Technical Specification (TS) 18508 or later
11120 1.1 mrg
11121 1.1 mrg
11122 1.1 mrg @item @emph{Class}:
11123 1.1 mrg Transformational function
11124 1.1 mrg
11125 1.1 mrg @item @emph{Syntax}:
11126 1.1 mrg @code{RESULT = NUM_IMAGES(DISTANCE, FAILED)}
11127 1.1 mrg
11128 1.1 mrg @item @emph{Arguments}:
11129 1.1 mrg @multitable @columnfractions .15 .70
11130 1.1 mrg @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
11131 1.1 mrg @item @var{FAILED} @tab (optional, intent(in)) Scalar logical expression
11132 1.1 mrg @end multitable
11133 1.1 mrg
11134 1.1 mrg @item @emph{Return value}:
11135 1.1 mrg Scalar default-kind integer. If @var{DISTANCE} is not present or has value 0,
11136 1.1 mrg the number of images in the current team is returned. For values smaller or
11137 1.1 mrg equal distance to the initial team, it returns the number of images index
11138 1.1 mrg on the ancestor team which has a distance of @var{DISTANCE} from the invoking
11139 1.1 mrg team. If @var{DISTANCE} is larger than the distance to the initial team, the
11140 1.1 mrg number of images of the initial team is returned. If @var{FAILED} is not present
11141 1.1 mrg the total number of images is returned; if it has the value @code{.TRUE.},
11142 1.1 mrg the number of failed images is returned, otherwise, the number of images which
11143 1.1 mrg do have not the failed status.
11144 1.1 mrg
11145 1.1 mrg @item @emph{Example}:
11146 1.1 mrg @smallexample
11147 1.1 mrg INTEGER :: value[*]
11148 1.1 mrg INTEGER :: i
11149 1.1 mrg value = THIS_IMAGE()
11150 1.1 mrg SYNC ALL
11151 1.1 mrg IF (THIS_IMAGE() == 1) THEN
11152 1.1 mrg DO i = 1, NUM_IMAGES()
11153 1.1 mrg WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
11154 1.1 mrg END DO
11155 1.1 mrg END IF
11156 1.1 mrg @end smallexample
11157 1.1 mrg
11158 1.1 mrg @item @emph{See also}:
11159 1.1 mrg @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
11160 1.1 mrg @end table
11161 1.1 mrg
11162 1.1 mrg
11163 1.1 mrg
11164 1.1 mrg @node OR
11165 1.1 mrg @section @code{OR} --- Bitwise logical OR
11166 1.1 mrg @fnindex OR
11167 1.1 mrg @cindex bitwise logical or
11168 1.1 mrg @cindex logical or, bitwise
11169 1.1 mrg
11170 1.1 mrg @table @asis
11171 1.1 mrg @item @emph{Description}:
11172 1.1 mrg Bitwise logical @code{OR}.
11173 1.1 mrg
11174 1.1 mrg This intrinsic routine is provided for backwards compatibility with
11175 1.1 mrg GNU Fortran 77. For integer arguments, programmers should consider
11176 1.1 mrg the use of the @ref{IOR} intrinsic defined by the Fortran standard.
11177 1.1 mrg
11178 1.1 mrg @item @emph{Standard}:
11179 1.1 mrg GNU extension
11180 1.1 mrg
11181 1.1 mrg @item @emph{Class}:
11182 1.1 mrg Function
11183 1.1 mrg
11184 1.1 mrg @item @emph{Syntax}:
11185 1.1 mrg @code{RESULT = OR(I, J)}
11186 1.1 mrg
11187 1.1 mrg @item @emph{Arguments}:
11188 1.1 mrg @multitable @columnfractions .15 .70
11189 1.1 mrg @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
11190 1.1 mrg type or a scalar @code{LOGICAL} type or a boz-literal-constant.
11191 1.1 mrg @item @var{J} @tab The type shall be the same as the type of @var{I} or
11192 1.1 mrg a boz-literal-constant. @var{I} and @var{J} shall not both be
11193 1.1 mrg boz-literal-constants. If either @var{I} and @var{J} is a
11194 1.1 mrg boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
11195 1.1 mrg @end multitable
11196 1.1 mrg
11197 1.1 mrg @item @emph{Return value}:
11198 1.1 mrg The return type is either a scalar @code{INTEGER} or a scalar
11199 1.1 mrg @code{LOGICAL}. If the kind type parameters differ, then the
11200 1.1 mrg smaller kind type is implicitly converted to larger kind, and the
11201 1.1 mrg return has the larger kind. A boz-literal-constant is
11202 1.1 mrg converted to an @code{INTEGER} with the kind type parameter of
11203 1.1 mrg the other argument as-if a call to @ref{INT} occurred.
11204 1.1 mrg
11205 1.1 mrg @item @emph{Example}:
11206 1.1 mrg @smallexample
11207 1.1 mrg PROGRAM test_or
11208 1.1 mrg LOGICAL :: T = .TRUE., F = .FALSE.
11209 1.1 mrg INTEGER :: a, b
11210 1.1 mrg DATA a / Z'F' /, b / Z'3' /
11211 1.1 mrg
11212 1.1 mrg WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
11213 1.1 mrg WRITE (*,*) OR(a, b)
11214 1.1 mrg END PROGRAM
11215 1.1 mrg @end smallexample
11216 1.1 mrg
11217 1.1 mrg @item @emph{See also}:
11218 1.1 mrg Fortran 95 elemental function: @ref{IOR}
11219 1.1 mrg @end table
11220 1.1 mrg
11221 1.1 mrg
11222 1.1 mrg
11223 1.1 mrg @node PACK
11224 1.1 mrg @section @code{PACK} --- Pack an array into an array of rank one
11225 1.1 mrg @fnindex PACK
11226 1.1 mrg @cindex array, packing
11227 1.1 mrg @cindex array, reduce dimension
11228 1.1 mrg @cindex array, gather elements
11229 1.1 mrg
11230 1.1 mrg @table @asis
11231 1.1 mrg @item @emph{Description}:
11232 1.1 mrg Stores the elements of @var{ARRAY} in an array of rank one.
11233 1.1 mrg
11234 1.1 mrg The beginning of the resulting array is made up of elements whose @var{MASK}
11235 1.1 mrg equals @code{TRUE}. Afterwards, positions are filled with elements taken from
11236 1.1 mrg @var{VECTOR}.
11237 1.1 mrg
11238 1.1 mrg @item @emph{Standard}:
11239 1.1 mrg Fortran 95 and later
11240 1.1 mrg
11241 1.1 mrg @item @emph{Class}:
11242 1.1 mrg Transformational function
11243 1.1 mrg
11244 1.1 mrg @item @emph{Syntax}:
11245 1.1 mrg @code{RESULT = PACK(ARRAY, MASK[,VECTOR])}
11246 1.1 mrg
11247 1.1 mrg @item @emph{Arguments}:
11248 1.1 mrg @multitable @columnfractions .15 .70
11249 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type.
11250 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
11251 1.1 mrg of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
11252 1.1 mrg scalar.
11253 1.1 mrg @item @var{VECTOR} @tab (Optional) shall be an array of the same type
11254 1.1 mrg as @var{ARRAY} and of rank one. If present, the number of elements in
11255 1.1 mrg @var{VECTOR} shall be equal to or greater than the number of true elements
11256 1.1 mrg in @var{MASK}. If @var{MASK} is scalar, the number of elements in
11257 1.1 mrg @var{VECTOR} shall be equal to or greater than the number of elements in
11258 1.1 mrg @var{ARRAY}.
11259 1.1 mrg @end multitable
11260 1.1 mrg
11261 1.1 mrg @item @emph{Return value}:
11262 1.1 mrg The result is an array of rank one and the same type as that of @var{ARRAY}.
11263 1.1 mrg If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
11264 1.1 mrg number of @code{TRUE} values in @var{MASK} otherwise.
11265 1.1 mrg
11266 1.1 mrg @item @emph{Example}:
11267 1.1 mrg Gathering nonzero elements from an array:
11268 1.1 mrg @smallexample
11269 1.1 mrg PROGRAM test_pack_1
11270 1.1 mrg INTEGER :: m(6)
11271 1.1 mrg m = (/ 1, 0, 0, 0, 5, 0 /)
11272 1.1 mrg WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
11273 1.1 mrg END PROGRAM
11274 1.1 mrg @end smallexample
11275 1.1 mrg
11276 1.1 mrg Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
11277 1.1 mrg @smallexample
11278 1.1 mrg PROGRAM test_pack_2
11279 1.1 mrg INTEGER :: m(4)
11280 1.1 mrg m = (/ 1, 0, 0, 2 /)
11281 1.1 mrg WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
11282 1.1 mrg END PROGRAM
11283 1.1 mrg @end smallexample
11284 1.1 mrg
11285 1.1 mrg @item @emph{See also}:
11286 1.1 mrg @ref{UNPACK}
11287 1.1 mrg @end table
11288 1.1 mrg
11289 1.1 mrg
11290 1.1 mrg
11291 1.1 mrg @node PARITY
11292 1.1 mrg @section @code{PARITY} --- Reduction with exclusive OR
11293 1.1 mrg @fnindex PARITY
11294 1.1 mrg @cindex Parity
11295 1.1 mrg @cindex Reduction, XOR
11296 1.1 mrg @cindex XOR reduction
11297 1.1 mrg
11298 1.1 mrg @table @asis
11299 1.1 mrg @item @emph{Description}:
11300 1.1 mrg Calculates the parity, i.e. the reduction using @code{.XOR.},
11301 1.1 mrg of @var{MASK} along dimension @var{DIM}.
11302 1.1 mrg
11303 1.1 mrg @item @emph{Standard}:
11304 1.1 mrg Fortran 2008 and later
11305 1.1 mrg
11306 1.1 mrg @item @emph{Class}:
11307 1.1 mrg Transformational function
11308 1.1 mrg
11309 1.1 mrg @item @emph{Syntax}:
11310 1.1 mrg @multitable @columnfractions .80
11311 1.1 mrg @item @code{RESULT = PARITY(MASK[, DIM])}
11312 1.1 mrg @end multitable
11313 1.1 mrg
11314 1.1 mrg @item @emph{Arguments}:
11315 1.1 mrg @multitable @columnfractions .15 .70
11316 1.1 mrg @item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
11317 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
11318 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
11319 1.1 mrg equals the rank of @var{MASK}.
11320 1.1 mrg @end multitable
11321 1.1 mrg
11322 1.1 mrg @item @emph{Return value}:
11323 1.1 mrg The result is of the same type as @var{MASK}.
11324 1.1 mrg
11325 1.1 mrg If @var{DIM} is absent, a scalar with the parity of all elements in
11326 1.1 mrg @var{MASK} is returned, i.e. true if an odd number of elements is
11327 1.1 mrg @code{.true.} and false otherwise. If @var{DIM} is present, an array
11328 1.1 mrg of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
11329 1.1 mrg and a shape similar to that of @var{MASK} with dimension @var{DIM}
11330 1.1 mrg dropped is returned.
11331 1.1 mrg
11332 1.1 mrg @item @emph{Example}:
11333 1.1 mrg @smallexample
11334 1.1 mrg PROGRAM test_sum
11335 1.1 mrg LOGICAL :: x(2) = [ .true., .false. ]
11336 1.1 mrg print *, PARITY(x) ! prints "T" (true).
11337 1.1 mrg END PROGRAM
11338 1.1 mrg @end smallexample
11339 1.1 mrg @end table
11340 1.1 mrg
11341 1.1 mrg
11342 1.1 mrg
11343 1.1 mrg @node PERROR
11344 1.1 mrg @section @code{PERROR} --- Print system error message
11345 1.1 mrg @fnindex PERROR
11346 1.1 mrg @cindex system, error handling
11347 1.1 mrg
11348 1.1 mrg @table @asis
11349 1.1 mrg @item @emph{Description}:
11350 1.1 mrg Prints (on the C @code{stderr} stream) a newline-terminated error
11351 1.1 mrg message corresponding to the last system error. This is prefixed by
11352 1.1 mrg @var{STRING}, a colon and a space. See @code{perror(3)}.
11353 1.1 mrg
11354 1.1 mrg @item @emph{Standard}:
11355 1.1 mrg GNU extension
11356 1.1 mrg
11357 1.1 mrg @item @emph{Class}:
11358 1.1 mrg Subroutine
11359 1.1 mrg
11360 1.1 mrg @item @emph{Syntax}:
11361 1.1 mrg @code{CALL PERROR(STRING)}
11362 1.1 mrg
11363 1.1 mrg @item @emph{Arguments}:
11364 1.1 mrg @multitable @columnfractions .15 .70
11365 1.1 mrg @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
11366 1.1 mrg default kind.
11367 1.1 mrg @end multitable
11368 1.1 mrg
11369 1.1 mrg @item @emph{See also}:
11370 1.1 mrg @ref{IERRNO}
11371 1.1 mrg @end table
11372 1.1 mrg
11373 1.1 mrg
11374 1.1 mrg
11375 1.1 mrg @node POPCNT
11376 1.1 mrg @section @code{POPCNT} --- Number of bits set
11377 1.1 mrg @fnindex POPCNT
11378 1.1 mrg @cindex binary representation
11379 1.1 mrg @cindex bits set
11380 1.1 mrg
11381 1.1 mrg @table @asis
11382 1.1 mrg @item @emph{Description}:
11383 1.1 mrg @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
11384 1.1 mrg representation of @code{I}.
11385 1.1 mrg
11386 1.1 mrg @item @emph{Standard}:
11387 1.1 mrg Fortran 2008 and later
11388 1.1 mrg
11389 1.1 mrg @item @emph{Class}:
11390 1.1 mrg Elemental function
11391 1.1 mrg
11392 1.1 mrg @item @emph{Syntax}:
11393 1.1 mrg @code{RESULT = POPCNT(I)}
11394 1.1 mrg
11395 1.1 mrg @item @emph{Arguments}:
11396 1.1 mrg @multitable @columnfractions .15 .70
11397 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
11398 1.1 mrg @end multitable
11399 1.1 mrg
11400 1.1 mrg @item @emph{Return value}:
11401 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
11402 1.1 mrg kind.
11403 1.1 mrg
11404 1.1 mrg @item @emph{See also}:
11405 1.1 mrg @ref{POPPAR}, @ref{LEADZ}, @ref{TRAILZ}
11406 1.1 mrg
11407 1.1 mrg @item @emph{Example}:
11408 1.1 mrg @smallexample
11409 1.1 mrg program test_population
11410 1.1 mrg print *, popcnt(127), poppar(127)
11411 1.1 mrg print *, popcnt(huge(0_4)), poppar(huge(0_4))
11412 1.1 mrg print *, popcnt(huge(0_8)), poppar(huge(0_8))
11413 1.1 mrg end program test_population
11414 1.1 mrg @end smallexample
11415 1.1 mrg @end table
11416 1.1 mrg
11417 1.1 mrg
11418 1.1 mrg @node POPPAR
11419 1.1 mrg @section @code{POPPAR} --- Parity of the number of bits set
11420 1.1 mrg @fnindex POPPAR
11421 1.1 mrg @cindex binary representation
11422 1.1 mrg @cindex parity
11423 1.1 mrg
11424 1.1 mrg @table @asis
11425 1.1 mrg @item @emph{Description}:
11426 1.1 mrg @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
11427 1.1 mrg of the number of bits set ('1' bits) in the binary representation of
11428 1.1 mrg @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
11429 1.1 mrg and 1 for an odd number of '1' bits.
11430 1.1 mrg
11431 1.1 mrg @item @emph{Standard}:
11432 1.1 mrg Fortran 2008 and later
11433 1.1 mrg
11434 1.1 mrg @item @emph{Class}:
11435 1.1 mrg Elemental function
11436 1.1 mrg
11437 1.1 mrg @item @emph{Syntax}:
11438 1.1 mrg @code{RESULT = POPPAR(I)}
11439 1.1 mrg
11440 1.1 mrg @item @emph{Arguments}:
11441 1.1 mrg @multitable @columnfractions .15 .70
11442 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
11443 1.1 mrg @end multitable
11444 1.1 mrg
11445 1.1 mrg @item @emph{Return value}:
11446 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
11447 1.1 mrg kind.
11448 1.1 mrg
11449 1.1 mrg @item @emph{See also}:
11450 1.1 mrg @ref{POPCNT}, @ref{LEADZ}, @ref{TRAILZ}
11451 1.1 mrg
11452 1.1 mrg @item @emph{Example}:
11453 1.1 mrg @smallexample
11454 1.1 mrg program test_population
11455 1.1 mrg print *, popcnt(127), poppar(127)
11456 1.1 mrg print *, popcnt(huge(0_4)), poppar(huge(0_4))
11457 1.1 mrg print *, popcnt(huge(0_8)), poppar(huge(0_8))
11458 1.1 mrg end program test_population
11459 1.1 mrg @end smallexample
11460 1.1 mrg @end table
11461 1.1 mrg
11462 1.1 mrg
11463 1.1 mrg
11464 1.1 mrg @node PRECISION
11465 1.1 mrg @section @code{PRECISION} --- Decimal precision of a real kind
11466 1.1 mrg @fnindex PRECISION
11467 1.1 mrg @cindex model representation, precision
11468 1.1 mrg
11469 1.1 mrg @table @asis
11470 1.1 mrg @item @emph{Description}:
11471 1.1 mrg @code{PRECISION(X)} returns the decimal precision in the model of the
11472 1.1 mrg type of @code{X}.
11473 1.1 mrg
11474 1.1 mrg @item @emph{Standard}:
11475 1.1 mrg Fortran 95 and later
11476 1.1 mrg
11477 1.1 mrg @item @emph{Class}:
11478 1.1 mrg Inquiry function
11479 1.1 mrg
11480 1.1 mrg @item @emph{Syntax}:
11481 1.1 mrg @code{RESULT = PRECISION(X)}
11482 1.1 mrg
11483 1.1 mrg @item @emph{Arguments}:
11484 1.1 mrg @multitable @columnfractions .15 .70
11485 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
11486 1.1 mrg @end multitable
11487 1.1 mrg
11488 1.1 mrg @item @emph{Return value}:
11489 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
11490 1.1 mrg kind.
11491 1.1 mrg
11492 1.1 mrg @item @emph{See also}:
11493 1.1 mrg @ref{SELECTED_REAL_KIND}, @ref{RANGE}
11494 1.1 mrg
11495 1.1 mrg @item @emph{Example}:
11496 1.1 mrg @smallexample
11497 1.1 mrg program prec_and_range
11498 1.1 mrg real(kind=4) :: x(2)
11499 1.1 mrg complex(kind=8) :: y
11500 1.1 mrg
11501 1.1 mrg print *, precision(x), range(x)
11502 1.1 mrg print *, precision(y), range(y)
11503 1.1 mrg end program prec_and_range
11504 1.1 mrg @end smallexample
11505 1.1 mrg @end table
11506 1.1 mrg
11507 1.1 mrg
11508 1.1 mrg
11509 1.1 mrg @node PRESENT
11510 1.1 mrg @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
11511 1.1 mrg @fnindex PRESENT
11512 1.1 mrg
11513 1.1 mrg @table @asis
11514 1.1 mrg @item @emph{Description}:
11515 1.1 mrg Determines whether an optional dummy argument is present.
11516 1.1 mrg
11517 1.1 mrg @item @emph{Standard}:
11518 1.1 mrg Fortran 95 and later
11519 1.1 mrg
11520 1.1 mrg @item @emph{Class}:
11521 1.1 mrg Inquiry function
11522 1.1 mrg
11523 1.1 mrg @item @emph{Syntax}:
11524 1.1 mrg @code{RESULT = PRESENT(A)}
11525 1.1 mrg
11526 1.1 mrg @item @emph{Arguments}:
11527 1.1 mrg @multitable @columnfractions .15 .70
11528 1.1 mrg @item @var{A} @tab May be of any type and may be a pointer, scalar or array
11529 1.1 mrg value, or a dummy procedure. It shall be the name of an optional dummy argument
11530 1.1 mrg accessible within the current subroutine or function.
11531 1.1 mrg @end multitable
11532 1.1 mrg
11533 1.1 mrg @item @emph{Return value}:
11534 1.1 mrg Returns either @code{TRUE} if the optional argument @var{A} is present, or
11535 1.1 mrg @code{FALSE} otherwise.
11536 1.1 mrg
11537 1.1 mrg @item @emph{Example}:
11538 1.1 mrg @smallexample
11539 1.1 mrg PROGRAM test_present
11540 1.1 mrg WRITE(*,*) f(), f(42) ! "F T"
11541 1.1 mrg CONTAINS
11542 1.1 mrg LOGICAL FUNCTION f(x)
11543 1.1 mrg INTEGER, INTENT(IN), OPTIONAL :: x
11544 1.1 mrg f = PRESENT(x)
11545 1.1 mrg END FUNCTION
11546 1.1 mrg END PROGRAM
11547 1.1 mrg @end smallexample
11548 1.1 mrg @end table
11549 1.1 mrg
11550 1.1 mrg
11551 1.1 mrg
11552 1.1 mrg @node PRODUCT
11553 1.1 mrg @section @code{PRODUCT} --- Product of array elements
11554 1.1 mrg @fnindex PRODUCT
11555 1.1 mrg @cindex array, product
11556 1.1 mrg @cindex array, multiply elements
11557 1.1 mrg @cindex array, conditionally multiply elements
11558 1.1 mrg @cindex multiply array elements
11559 1.1 mrg
11560 1.1 mrg @table @asis
11561 1.1 mrg @item @emph{Description}:
11562 1.1 mrg Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
11563 1.1 mrg the corresponding element in @var{MASK} is @code{TRUE}.
11564 1.1 mrg
11565 1.1 mrg @item @emph{Standard}:
11566 1.1 mrg Fortran 95 and later
11567 1.1 mrg
11568 1.1 mrg @item @emph{Class}:
11569 1.1 mrg Transformational function
11570 1.1 mrg
11571 1.1 mrg @item @emph{Syntax}:
11572 1.1 mrg @multitable @columnfractions .80
11573 1.1 mrg @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
11574 1.1 mrg @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
11575 1.1 mrg @end multitable
11576 1.1 mrg
11577 1.1 mrg @item @emph{Arguments}:
11578 1.1 mrg @multitable @columnfractions .15 .70
11579 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
11580 1.1 mrg @code{REAL} or @code{COMPLEX}.
11581 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
11582 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
11583 1.1 mrg equals the rank of @var{ARRAY}.
11584 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
11585 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
11586 1.1 mrg @end multitable
11587 1.1 mrg
11588 1.1 mrg @item @emph{Return value}:
11589 1.1 mrg The result is of the same type as @var{ARRAY}.
11590 1.1 mrg
11591 1.1 mrg If @var{DIM} is absent, a scalar with the product of all elements in
11592 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
11593 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
11594 1.1 mrg dimension @var{DIM} dropped is returned.
11595 1.1 mrg
11596 1.1 mrg
11597 1.1 mrg @item @emph{Example}:
11598 1.1 mrg @smallexample
11599 1.1 mrg PROGRAM test_product
11600 1.1 mrg INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11601 1.1 mrg print *, PRODUCT(x) ! all elements, product = 120
11602 1.1 mrg print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
11603 1.1 mrg END PROGRAM
11604 1.1 mrg @end smallexample
11605 1.1 mrg
11606 1.1 mrg @item @emph{See also}:
11607 1.1 mrg @ref{SUM}
11608 1.1 mrg @end table
11609 1.1 mrg
11610 1.1 mrg
11611 1.1 mrg
11612 1.1 mrg @node RADIX
11613 1.1 mrg @section @code{RADIX} --- Base of a model number
11614 1.1 mrg @fnindex RADIX
11615 1.1 mrg @cindex model representation, base
11616 1.1 mrg @cindex model representation, radix
11617 1.1 mrg
11618 1.1 mrg @table @asis
11619 1.1 mrg @item @emph{Description}:
11620 1.1 mrg @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
11621 1.1 mrg
11622 1.1 mrg @item @emph{Standard}:
11623 1.1 mrg Fortran 95 and later
11624 1.1 mrg
11625 1.1 mrg @item @emph{Class}:
11626 1.1 mrg Inquiry function
11627 1.1 mrg
11628 1.1 mrg @item @emph{Syntax}:
11629 1.1 mrg @code{RESULT = RADIX(X)}
11630 1.1 mrg
11631 1.1 mrg @item @emph{Arguments}:
11632 1.1 mrg @multitable @columnfractions .15 .70
11633 1.1 mrg @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
11634 1.1 mrg @end multitable
11635 1.1 mrg
11636 1.1 mrg @item @emph{Return value}:
11637 1.1 mrg The return value is a scalar of type @code{INTEGER} and of the default
11638 1.1 mrg integer kind.
11639 1.1 mrg
11640 1.1 mrg @item @emph{See also}:
11641 1.1 mrg @ref{SELECTED_REAL_KIND}
11642 1.1 mrg
11643 1.1 mrg @item @emph{Example}:
11644 1.1 mrg @smallexample
11645 1.1 mrg program test_radix
11646 1.1 mrg print *, "The radix for the default integer kind is", radix(0)
11647 1.1 mrg print *, "The radix for the default real kind is", radix(0.0)
11648 1.1 mrg end program test_radix
11649 1.1 mrg @end smallexample
11650 1.1 mrg
11651 1.1 mrg @end table
11652 1.1 mrg
11653 1.1 mrg
11654 1.1 mrg
11655 1.1 mrg @node RAN
11656 1.1 mrg @section @code{RAN} --- Real pseudo-random number
11657 1.1 mrg @fnindex RAN
11658 1.1 mrg @cindex random number generation
11659 1.1 mrg
11660 1.1 mrg @table @asis
11661 1.1 mrg @item @emph{Description}:
11662 1.1 mrg For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
11663 1.1 mrg provided as an alias for @code{RAND}. See @ref{RAND} for complete
11664 1.1 mrg documentation.
11665 1.1 mrg
11666 1.1 mrg @item @emph{Standard}:
11667 1.1 mrg GNU extension
11668 1.1 mrg
11669 1.1 mrg @item @emph{Class}:
11670 1.1 mrg Function
11671 1.1 mrg
11672 1.1 mrg @item @emph{See also}:
11673 1.1 mrg @ref{RAND}, @ref{RANDOM_NUMBER}
11674 1.1 mrg @end table
11675 1.1 mrg
11676 1.1 mrg
11677 1.1 mrg
11678 1.1 mrg @node RAND
11679 1.1 mrg @section @code{RAND} --- Real pseudo-random number
11680 1.1 mrg @fnindex RAND
11681 1.1 mrg @cindex random number generation
11682 1.1 mrg
11683 1.1 mrg @table @asis
11684 1.1 mrg @item @emph{Description}:
11685 1.1 mrg @code{RAND(FLAG)} returns a pseudo-random number from a uniform
11686 1.1 mrg distribution between 0 and 1. If @var{FLAG} is 0, the next number
11687 1.1 mrg in the current sequence is returned; if @var{FLAG} is 1, the generator
11688 1.1 mrg is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
11689 1.1 mrg it is used as a new seed with @code{SRAND}.
11690 1.1 mrg
11691 1.1 mrg This intrinsic routine is provided for backwards compatibility with
11692 1.1 mrg GNU Fortran 77. It implements a simple modulo generator as provided
11693 1.1 mrg by @command{g77}. For new code, one should consider the use of
11694 1.1 mrg @ref{RANDOM_NUMBER} as it implements a superior algorithm.
11695 1.1 mrg
11696 1.1 mrg @item @emph{Standard}:
11697 1.1 mrg GNU extension
11698 1.1 mrg
11699 1.1 mrg @item @emph{Class}:
11700 1.1 mrg Function
11701 1.1 mrg
11702 1.1 mrg @item @emph{Syntax}:
11703 1.1 mrg @code{RESULT = RAND(I)}
11704 1.1 mrg
11705 1.1 mrg @item @emph{Arguments}:
11706 1.1 mrg @multitable @columnfractions .15 .70
11707 1.1 mrg @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
11708 1.1 mrg @end multitable
11709 1.1 mrg
11710 1.1 mrg @item @emph{Return value}:
11711 1.1 mrg The return value is of @code{REAL} type and the default kind.
11712 1.1 mrg
11713 1.1 mrg @item @emph{Example}:
11714 1.1 mrg @smallexample
11715 1.1 mrg program test_rand
11716 1.1 mrg integer,parameter :: seed = 86456
11717 1.1 mrg
11718 1.1 mrg call srand(seed)
11719 1.1 mrg print *, rand(), rand(), rand(), rand()
11720 1.1 mrg print *, rand(seed), rand(), rand(), rand()
11721 1.1 mrg end program test_rand
11722 1.1 mrg @end smallexample
11723 1.1 mrg
11724 1.1 mrg @item @emph{See also}:
11725 1.1 mrg @ref{SRAND}, @ref{RANDOM_NUMBER}
11726 1.1 mrg
11727 1.1 mrg @end table
11728 1.1 mrg
11729 1.1 mrg
11730 1.1 mrg @node RANDOM_INIT
11731 1.1 mrg @section @code{RANDOM_INIT} --- Initialize a pseudo-random number generator
11732 1.1 mrg @fnindex RANDOM_INIT
11733 1.1 mrg @cindex random number generation, initialization
11734 1.1 mrg
11735 1.1 mrg @table @asis
11736 1.1 mrg @item @emph{Description}:
11737 1.1 mrg Initializes the state of the pseudorandom number generator used by
11738 1.1 mrg @code{RANDOM_NUMBER}.
11739 1.1 mrg
11740 1.1 mrg @item @emph{Standard}:
11741 1.1 mrg Fortran 2018
11742 1.1 mrg
11743 1.1 mrg @item @emph{Class}:
11744 1.1 mrg Subroutine
11745 1.1 mrg
11746 1.1 mrg @item @emph{Syntax}:
11747 1.1 mrg @code{CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)}
11748 1.1 mrg
11749 1.1 mrg @item @emph{Arguments}:
11750 1.1 mrg @multitable @columnfractions .20 .75
11751 1.1 mrg @item @var{REPEATABLE} @tab Shall be a scalar with a @code{LOGICAL} type,
11752 1.1 mrg and it is @code{INTENT(IN)}. If it is @code{.true.}, the seed is set to
11753 1.1 mrg a processor-dependent value that is the same each time @code{RANDOM_INIT}
11754 1.1 mrg is called from the same image. The term ``same image'' means a single
11755 1.1 mrg instance of program execution. The sequence of random numbers is different
11756 1.1 mrg for repeated execution of the program. If it is @code{.false.}, the seed
11757 1.1 mrg is set to a processor-dependent value.
11758 1.1 mrg @item @var{IMAGE_DISTINCT} @tab Shall be a scalar with a
11759 1.1 mrg @code{LOGICAL} type, and it is @code{INTENT(IN)}. If it is @code{.true.},
11760 1.1 mrg the seed is set to a processor-dependent value that is distinct from th
11761 1.1 mrg seed set by a call to @code{RANDOM_INIT} in another image. If it is
11762 1.1 mrg @code{.false.}, the seed is set value that does depend which image called
11763 1.1 mrg @code{RANDOM_INIT}.
11764 1.1 mrg @end multitable
11765 1.1 mrg
11766 1.1 mrg @item @emph{Example}:
11767 1.1 mrg @smallexample
11768 1.1 mrg program test_random_seed
11769 1.1 mrg implicit none
11770 1.1 mrg real x(3), y(3)
11771 1.1 mrg call random_init(.true., .true.)
11772 1.1 mrg call random_number(x)
11773 1.1 mrg call random_init(.true., .true.)
11774 1.1 mrg call random_number(y)
11775 1.1 mrg ! x and y are the same sequence
11776 1.1 mrg if (any(x /= y)) call abort
11777 1.1 mrg end program test_random_seed
11778 1.1 mrg @end smallexample
11779 1.1 mrg
11780 1.1 mrg @item @emph{See also}:
11781 1.1 mrg @ref{RANDOM_NUMBER}, @ref{RANDOM_SEED}
11782 1.1 mrg @end table
11783 1.1 mrg
11784 1.1 mrg
11785 1.1 mrg @node RANDOM_NUMBER
11786 1.1 mrg @section @code{RANDOM_NUMBER} --- Pseudo-random number
11787 1.1 mrg @fnindex RANDOM_NUMBER
11788 1.1 mrg @cindex random number generation
11789 1.1 mrg
11790 1.1 mrg @table @asis
11791 1.1 mrg @item @emph{Description}:
11792 1.1 mrg Returns a single pseudorandom number or an array of pseudorandom numbers
11793 1.1 mrg from the uniform distribution over the range @math{ 0 \leq x < 1}.
11794 1.1 mrg
11795 1.1 mrg The runtime-library implements the xorshift1024* random number
11796 1.1 mrg generator (RNG). This generator has a period of @math{2^{1024} - 1},
11797 1.1 mrg and when using multiple threads up to @math{2^{512}} threads can each
11798 1.1 mrg generate @math{2^{512}} random numbers before any aliasing occurs.
11799 1.1 mrg
11800 1.1 mrg Note that in a multi-threaded program (e.g. using OpenMP directives),
11801 1.1 mrg each thread will have its own random number state. For details of the
11802 1.1 mrg seeding procedure, see the documentation for the @code{RANDOM_SEED}
11803 1.1 mrg intrinsic.
11804 1.1 mrg
11805 1.1 mrg
11806 1.1 mrg @item @emph{Standard}:
11807 1.1 mrg Fortran 95 and later
11808 1.1 mrg
11809 1.1 mrg @item @emph{Class}:
11810 1.1 mrg Subroutine
11811 1.1 mrg
11812 1.1 mrg @item @emph{Syntax}:
11813 1.1 mrg @code{RANDOM_NUMBER(HARVEST)}
11814 1.1 mrg
11815 1.1 mrg @item @emph{Arguments}:
11816 1.1 mrg @multitable @columnfractions .15 .70
11817 1.1 mrg @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
11818 1.1 mrg @end multitable
11819 1.1 mrg
11820 1.1 mrg @item @emph{Example}:
11821 1.1 mrg @smallexample
11822 1.1 mrg program test_random_number
11823 1.1 mrg REAL :: r(5,5)
11824 1.1 mrg CALL RANDOM_NUMBER(r)
11825 1.1 mrg end program
11826 1.1 mrg @end smallexample
11827 1.1 mrg
11828 1.1 mrg @item @emph{See also}:
11829 1.1 mrg @ref{RANDOM_SEED}, @ref{RANDOM_INIT}
11830 1.1 mrg @end table
11831 1.1 mrg
11832 1.1 mrg
11833 1.1 mrg
11834 1.1 mrg @node RANDOM_SEED
11835 1.1 mrg @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
11836 1.1 mrg @fnindex RANDOM_SEED
11837 1.1 mrg @cindex random number generation, seeding
11838 1.1 mrg @cindex seeding a random number generator
11839 1.1 mrg
11840 1.1 mrg @table @asis
11841 1.1 mrg @item @emph{Description}:
11842 1.1 mrg Restarts or queries the state of the pseudorandom number generator used by
11843 1.1 mrg @code{RANDOM_NUMBER}.
11844 1.1 mrg
11845 1.1 mrg If @code{RANDOM_SEED} is called without arguments, it is seeded with
11846 1.1 mrg random data retrieved from the operating system.
11847 1.1 mrg
11848 1.1 mrg As an extension to the Fortran standard, the GFortran
11849 1.1 mrg @code{RANDOM_NUMBER} supports multiple threads. Each thread in a
11850 1.1 mrg multi-threaded program has its own seed. When @code{RANDOM_SEED} is
11851 1.1 mrg called either without arguments or with the @var{PUT} argument, the
11852 1.1 mrg given seed is copied into a master seed as well as the seed of the
11853 1.1 mrg current thread. When a new thread uses @code{RANDOM_NUMBER} for the
11854 1.1 mrg first time, the seed is copied from the master seed, and forwarded
11855 1.1 mrg @math{N * 2^{512}} steps to guarantee that the random stream does not
11856 1.1 mrg alias any other stream in the system, where @var{N} is the number of
11857 1.1 mrg threads that have used @code{RANDOM_NUMBER} so far during the program
11858 1.1 mrg execution.
11859 1.1 mrg
11860 1.1 mrg @item @emph{Standard}:
11861 1.1 mrg Fortran 95 and later
11862 1.1 mrg
11863 1.1 mrg @item @emph{Class}:
11864 1.1 mrg Subroutine
11865 1.1 mrg
11866 1.1 mrg @item @emph{Syntax}:
11867 1.1 mrg @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
11868 1.1 mrg
11869 1.1 mrg @item @emph{Arguments}:
11870 1.1 mrg @multitable @columnfractions .15 .70
11871 1.1 mrg @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
11872 1.1 mrg @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
11873 1.1 mrg of the arrays used with the @var{PUT} and @var{GET} arguments.
11874 1.1 mrg @item @var{PUT} @tab (Optional) Shall be an array of type default
11875 1.1 mrg @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
11876 1.1 mrg the array must be larger than or equal to the number returned by the
11877 1.1 mrg @var{SIZE} argument.
11878 1.1 mrg @item @var{GET} @tab (Optional) Shall be an array of type default
11879 1.1 mrg @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
11880 1.1 mrg of the array must be larger than or equal to the number returned by
11881 1.1 mrg the @var{SIZE} argument.
11882 1.1 mrg @end multitable
11883 1.1 mrg
11884 1.1 mrg @item @emph{Example}:
11885 1.1 mrg @smallexample
11886 1.1 mrg program test_random_seed
11887 1.1 mrg implicit none
11888 1.1 mrg integer, allocatable :: seed(:)
11889 1.1 mrg integer :: n
11890 1.1 mrg
11891 1.1 mrg call random_seed(size = n)
11892 1.1 mrg allocate(seed(n))
11893 1.1 mrg call random_seed(get=seed)
11894 1.1 mrg write (*, *) seed
11895 1.1 mrg end program test_random_seed
11896 1.1 mrg @end smallexample
11897 1.1 mrg
11898 1.1 mrg @item @emph{See also}:
11899 1.1 mrg @ref{RANDOM_NUMBER}, @ref{RANDOM_INIT}
11900 1.1 mrg @end table
11901 1.1 mrg
11902 1.1 mrg
11903 1.1 mrg
11904 1.1 mrg @node RANGE
11905 1.1 mrg @section @code{RANGE} --- Decimal exponent range
11906 1.1 mrg @fnindex RANGE
11907 1.1 mrg @cindex model representation, range
11908 1.1 mrg
11909 1.1 mrg @table @asis
11910 1.1 mrg @item @emph{Description}:
11911 1.1 mrg @code{RANGE(X)} returns the decimal exponent range in the model of the
11912 1.1 mrg type of @code{X}.
11913 1.1 mrg
11914 1.1 mrg @item @emph{Standard}:
11915 1.1 mrg Fortran 95 and later
11916 1.1 mrg
11917 1.1 mrg @item @emph{Class}:
11918 1.1 mrg Inquiry function
11919 1.1 mrg
11920 1.1 mrg @item @emph{Syntax}:
11921 1.1 mrg @code{RESULT = RANGE(X)}
11922 1.1 mrg
11923 1.1 mrg @item @emph{Arguments}:
11924 1.1 mrg @multitable @columnfractions .15 .70
11925 1.1 mrg @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
11926 1.1 mrg or @code{COMPLEX}.
11927 1.1 mrg @end multitable
11928 1.1 mrg
11929 1.1 mrg @item @emph{Return value}:
11930 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
11931 1.1 mrg kind.
11932 1.1 mrg
11933 1.1 mrg @item @emph{See also}:
11934 1.1 mrg @ref{SELECTED_REAL_KIND}, @ref{PRECISION}
11935 1.1 mrg
11936 1.1 mrg @item @emph{Example}:
11937 1.1 mrg See @code{PRECISION} for an example.
11938 1.1 mrg @end table
11939 1.1 mrg
11940 1.1 mrg
11941 1.1 mrg
11942 1.1 mrg @node RANK
11943 1.1 mrg @section @code{RANK} --- Rank of a data object
11944 1.1 mrg @fnindex RANK
11945 1.1 mrg @cindex rank
11946 1.1 mrg
11947 1.1 mrg @table @asis
11948 1.1 mrg @item @emph{Description}:
11949 1.1 mrg @code{RANK(A)} returns the rank of a scalar or array data object.
11950 1.1 mrg
11951 1.1 mrg @item @emph{Standard}:
11952 1.1 mrg Technical Specification (TS) 29113
11953 1.1 mrg
11954 1.1 mrg @item @emph{Class}:
11955 1.1 mrg Inquiry function
11956 1.1 mrg
11957 1.1 mrg @item @emph{Syntax}:
11958 1.1 mrg @code{RESULT = RANK(A)}
11959 1.1 mrg
11960 1.1 mrg @item @emph{Arguments}:
11961 1.1 mrg @multitable @columnfractions .15 .70
11962 1.1 mrg @item @var{A} @tab can be of any type
11963 1.1 mrg @end multitable
11964 1.1 mrg
11965 1.1 mrg @item @emph{Return value}:
11966 1.1 mrg The return value is of type @code{INTEGER} and of the default integer
11967 1.1 mrg kind. For arrays, their rank is returned; for scalars zero is returned.
11968 1.1 mrg
11969 1.1 mrg @item @emph{Example}:
11970 1.1 mrg @smallexample
11971 1.1 mrg program test_rank
11972 1.1 mrg integer :: a
11973 1.1 mrg real, allocatable :: b(:,:)
11974 1.1 mrg
11975 1.1 mrg print *, rank(a), rank(b) ! Prints: 0 2
11976 1.1 mrg end program test_rank
11977 1.1 mrg @end smallexample
11978 1.1 mrg
11979 1.1 mrg @end table
11980 1.1 mrg
11981 1.1 mrg
11982 1.1 mrg
11983 1.1 mrg @node REAL
11984 1.1 mrg @section @code{REAL} --- Convert to real type
11985 1.1 mrg @fnindex REAL
11986 1.1 mrg @fnindex REALPART
11987 1.1 mrg @fnindex FLOAT
11988 1.1 mrg @fnindex DFLOAT
11989 1.1 mrg @fnindex FLOATI
11990 1.1 mrg @fnindex FLOATJ
11991 1.1 mrg @fnindex FLOATK
11992 1.1 mrg @fnindex SNGL
11993 1.1 mrg @cindex conversion, to real
11994 1.1 mrg @cindex complex numbers, real part
11995 1.1 mrg
11996 1.1 mrg @table @asis
11997 1.1 mrg @item @emph{Description}:
11998 1.1 mrg @code{REAL(A [, KIND])} converts its argument @var{A} to a real type. The
11999 1.1 mrg @code{REALPART} function is provided for compatibility with @command{g77},
12000 1.1 mrg and its use is strongly discouraged.
12001 1.1 mrg
12002 1.1 mrg @item @emph{Standard}:
12003 1.1 mrg Fortran 77 and later
12004 1.1 mrg
12005 1.1 mrg @item @emph{Class}:
12006 1.1 mrg Elemental function
12007 1.1 mrg
12008 1.1 mrg @item @emph{Syntax}:
12009 1.1 mrg @multitable @columnfractions .80
12010 1.1 mrg @item @code{RESULT = REAL(A [, KIND])}
12011 1.1 mrg @item @code{RESULT = REALPART(Z)}
12012 1.1 mrg @end multitable
12013 1.1 mrg
12014 1.1 mrg @item @emph{Arguments}:
12015 1.1 mrg @multitable @columnfractions .15 .70
12016 1.1 mrg @item @var{A} @tab Shall be @code{INTEGER}, @code{REAL}, or
12017 1.1 mrg @code{COMPLEX}.
12018 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12019 1.1 mrg expression indicating the kind parameter of the result.
12020 1.1 mrg @end multitable
12021 1.1 mrg
12022 1.1 mrg @item @emph{Return value}:
12023 1.1 mrg These functions return a @code{REAL} variable or array under
12024 1.1 mrg the following rules:
12025 1.1 mrg
12026 1.1 mrg @table @asis
12027 1.1 mrg @item (A)
12028 1.1 mrg @code{REAL(A)} is converted to a default real type if @var{A} is an
12029 1.1 mrg integer or real variable.
12030 1.1 mrg @item (B)
12031 1.1 mrg @code{REAL(A)} is converted to a real type with the kind type parameter
12032 1.1 mrg of @var{A} if @var{A} is a complex variable.
12033 1.1 mrg @item (C)
12034 1.1 mrg @code{REAL(A, KIND)} is converted to a real type with kind type
12035 1.1 mrg parameter @var{KIND} if @var{A} is a complex, integer, or real
12036 1.1 mrg variable.
12037 1.1 mrg @end table
12038 1.1 mrg
12039 1.1 mrg @item @emph{Example}:
12040 1.1 mrg @smallexample
12041 1.1 mrg program test_real
12042 1.1 mrg complex :: x = (1.0, 2.0)
12043 1.1 mrg print *, real(x), real(x,8), realpart(x)
12044 1.1 mrg end program test_real
12045 1.1 mrg @end smallexample
12046 1.1 mrg
12047 1.1 mrg @item @emph{Specific names}:
12048 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
12049 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
12050 1.1 mrg @item @code{FLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab Fortran 77 and later
12051 1.1 mrg @item @code{DFLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(8)} @tab GNU extension
12052 1.1 mrg @item @code{FLOATI(A)} @tab @code{INTEGER(2)} @tab @code{REAL(4)} @tab GNU extension
12053 1.1 mrg @item @code{FLOATJ(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab GNU extension
12054 1.1 mrg @item @code{FLOATK(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab GNU extension
12055 1.1 mrg @item @code{SNGL(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab Fortran 77 and later
12056 1.1 mrg @end multitable
12057 1.1 mrg
12058 1.1 mrg
12059 1.1 mrg @item @emph{See also}:
12060 1.1 mrg @ref{DBLE}
12061 1.1 mrg
12062 1.1 mrg @end table
12063 1.1 mrg
12064 1.1 mrg
12065 1.1 mrg
12066 1.1 mrg @node RENAME
12067 1.1 mrg @section @code{RENAME} --- Rename a file
12068 1.1 mrg @fnindex RENAME
12069 1.1 mrg @cindex file system, rename file
12070 1.1 mrg
12071 1.1 mrg @table @asis
12072 1.1 mrg @item @emph{Description}:
12073 1.1 mrg Renames a file from file @var{PATH1} to @var{PATH2}. A null
12074 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in
12075 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
12076 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it
12077 1.1 mrg contains 0 on success or a nonzero error code upon return; see
12078 1.1 mrg @code{rename(2)}.
12079 1.1 mrg
12080 1.1 mrg This intrinsic is provided in both subroutine and function forms;
12081 1.1 mrg however, only one form can be used in any given program unit.
12082 1.1 mrg
12083 1.1 mrg @item @emph{Standard}:
12084 1.1 mrg GNU extension
12085 1.1 mrg
12086 1.1 mrg @item @emph{Class}:
12087 1.1 mrg Subroutine, function
12088 1.1 mrg
12089 1.1 mrg @item @emph{Syntax}:
12090 1.1 mrg @multitable @columnfractions .80
12091 1.1 mrg @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
12092 1.1 mrg @item @code{STATUS = RENAME(PATH1, PATH2)}
12093 1.1 mrg @end multitable
12094 1.1 mrg
12095 1.1 mrg @item @emph{Arguments}:
12096 1.1 mrg @multitable @columnfractions .15 .70
12097 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
12098 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
12099 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12100 1.1 mrg @end multitable
12101 1.1 mrg
12102 1.1 mrg @item @emph{See also}:
12103 1.1 mrg @ref{LINK}
12104 1.1 mrg
12105 1.1 mrg @end table
12106 1.1 mrg
12107 1.1 mrg
12108 1.1 mrg
12109 1.1 mrg @node REPEAT
12110 1.1 mrg @section @code{REPEAT} --- Repeated string concatenation
12111 1.1 mrg @fnindex REPEAT
12112 1.1 mrg @cindex string, repeat
12113 1.1 mrg @cindex string, concatenate
12114 1.1 mrg
12115 1.1 mrg @table @asis
12116 1.1 mrg @item @emph{Description}:
12117 1.1 mrg Concatenates @var{NCOPIES} copies of a string.
12118 1.1 mrg
12119 1.1 mrg @item @emph{Standard}:
12120 1.1 mrg Fortran 95 and later
12121 1.1 mrg
12122 1.1 mrg @item @emph{Class}:
12123 1.1 mrg Transformational function
12124 1.1 mrg
12125 1.1 mrg @item @emph{Syntax}:
12126 1.1 mrg @code{RESULT = REPEAT(STRING, NCOPIES)}
12127 1.1 mrg
12128 1.1 mrg @item @emph{Arguments}:
12129 1.1 mrg @multitable @columnfractions .15 .70
12130 1.1 mrg @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}.
12131 1.1 mrg @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
12132 1.1 mrg @end multitable
12133 1.1 mrg
12134 1.1 mrg @item @emph{Return value}:
12135 1.1 mrg A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
12136 1.1 mrg of @var{STRING}.
12137 1.1 mrg
12138 1.1 mrg @item @emph{Example}:
12139 1.1 mrg @smallexample
12140 1.1 mrg program test_repeat
12141 1.1 mrg write(*,*) repeat("x", 5) ! "xxxxx"
12142 1.1 mrg end program
12143 1.1 mrg @end smallexample
12144 1.1 mrg @end table
12145 1.1 mrg
12146 1.1 mrg
12147 1.1 mrg
12148 1.1 mrg @node RESHAPE
12149 1.1 mrg @section @code{RESHAPE} --- Function to reshape an array
12150 1.1 mrg @fnindex RESHAPE
12151 1.1 mrg @cindex array, change dimensions
12152 1.1 mrg @cindex array, transmogrify
12153 1.1 mrg
12154 1.1 mrg @table @asis
12155 1.1 mrg @item @emph{Description}:
12156 1.1 mrg Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
12157 1.1 mrg the new array may be padded with elements from @var{PAD} or permuted
12158 1.1 mrg as defined by @var{ORDER}.
12159 1.1 mrg
12160 1.1 mrg @item @emph{Standard}:
12161 1.1 mrg Fortran 95 and later
12162 1.1 mrg
12163 1.1 mrg @item @emph{Class}:
12164 1.1 mrg Transformational function
12165 1.1 mrg
12166 1.1 mrg @item @emph{Syntax}:
12167 1.1 mrg @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
12168 1.1 mrg
12169 1.1 mrg @item @emph{Arguments}:
12170 1.1 mrg @multitable @columnfractions .15 .70
12171 1.1 mrg @item @var{SOURCE} @tab Shall be an array of any type.
12172 1.1 mrg @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
12173 1.1 mrg array of rank one. Its values must be positive or zero.
12174 1.1 mrg @item @var{PAD} @tab (Optional) shall be an array of the same
12175 1.1 mrg type as @var{SOURCE}.
12176 1.1 mrg @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
12177 1.1 mrg and an array of the same shape as @var{SHAPE}. Its values shall
12178 1.1 mrg be a permutation of the numbers from 1 to n, where n is the size of
12179 1.1 mrg @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
12180 1.1 mrg be assumed.
12181 1.1 mrg @end multitable
12182 1.1 mrg
12183 1.1 mrg @item @emph{Return value}:
12184 1.1 mrg The result is an array of shape @var{SHAPE} with the same type as
12185 1.1 mrg @var{SOURCE}.
12186 1.1 mrg
12187 1.1 mrg @item @emph{Example}:
12188 1.1 mrg @smallexample
12189 1.1 mrg PROGRAM test_reshape
12190 1.1 mrg INTEGER, DIMENSION(4) :: x
12191 1.1 mrg WRITE(*,*) SHAPE(x) ! prints "4"
12192 1.1 mrg WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
12193 1.1 mrg END PROGRAM
12194 1.1 mrg @end smallexample
12195 1.1 mrg
12196 1.1 mrg @item @emph{See also}:
12197 1.1 mrg @ref{SHAPE}
12198 1.1 mrg @end table
12199 1.1 mrg
12200 1.1 mrg
12201 1.1 mrg
12202 1.1 mrg @node RRSPACING
12203 1.1 mrg @section @code{RRSPACING} --- Reciprocal of the relative spacing
12204 1.1 mrg @fnindex RRSPACING
12205 1.1 mrg @cindex real number, relative spacing
12206 1.1 mrg @cindex floating point, relative spacing
12207 1.1 mrg
12208 1.1 mrg
12209 1.1 mrg @table @asis
12210 1.1 mrg @item @emph{Description}:
12211 1.1 mrg @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
12212 1.1 mrg model numbers near @var{X}.
12213 1.1 mrg
12214 1.1 mrg @item @emph{Standard}:
12215 1.1 mrg Fortran 95 and later
12216 1.1 mrg
12217 1.1 mrg @item @emph{Class}:
12218 1.1 mrg Elemental function
12219 1.1 mrg
12220 1.1 mrg @item @emph{Syntax}:
12221 1.1 mrg @code{RESULT = RRSPACING(X)}
12222 1.1 mrg
12223 1.1 mrg @item @emph{Arguments}:
12224 1.1 mrg @multitable @columnfractions .15 .70
12225 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
12226 1.1 mrg @end multitable
12227 1.1 mrg
12228 1.1 mrg @item @emph{Return value}:
12229 1.1 mrg The return value is of the same type and kind as @var{X}.
12230 1.1 mrg The value returned is equal to
12231 1.1 mrg @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
12232 1.1 mrg
12233 1.1 mrg @item @emph{See also}:
12234 1.1 mrg @ref{SPACING}
12235 1.1 mrg @end table
12236 1.1 mrg
12237 1.1 mrg
12238 1.1 mrg
12239 1.1 mrg @node RSHIFT
12240 1.1 mrg @section @code{RSHIFT} --- Right shift bits
12241 1.1 mrg @fnindex RSHIFT
12242 1.1 mrg @cindex bits, shift right
12243 1.1 mrg
12244 1.1 mrg @table @asis
12245 1.1 mrg @item @emph{Description}:
12246 1.1 mrg @code{RSHIFT} returns a value corresponding to @var{I} with all of the
12247 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be
12248 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
12249 1.1 mrg the result value is undefined. Bits shifted out from the right end
12250 1.1 mrg are lost. The fill is arithmetic: the bits shifted in from the left
12251 1.1 mrg end are equal to the leftmost bit, which in two's complement
12252 1.1 mrg representation is the sign bit.
12253 1.1 mrg
12254 1.1 mrg This function has been superseded by the @code{SHIFTA} intrinsic, which
12255 1.1 mrg is standard in Fortran 2008 and later.
12256 1.1 mrg
12257 1.1 mrg @item @emph{Standard}:
12258 1.1 mrg GNU extension
12259 1.1 mrg
12260 1.1 mrg @item @emph{Class}:
12261 1.1 mrg Elemental function
12262 1.1 mrg
12263 1.1 mrg @item @emph{Syntax}:
12264 1.1 mrg @code{RESULT = RSHIFT(I, SHIFT)}
12265 1.1 mrg
12266 1.1 mrg @item @emph{Arguments}:
12267 1.1 mrg @multitable @columnfractions .15 .70
12268 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
12269 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12270 1.1 mrg @end multitable
12271 1.1 mrg
12272 1.1 mrg @item @emph{Return value}:
12273 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
12274 1.1 mrg @var{I}.
12275 1.1 mrg
12276 1.1 mrg @item @emph{See also}:
12277 1.1 mrg @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}, @ref{SHIFTA}, @ref{SHIFTR},
12278 1.1 mrg @ref{SHIFTL}
12279 1.1 mrg
12280 1.1 mrg @end table
12281 1.1 mrg
12282 1.1 mrg
12283 1.1 mrg
12284 1.1 mrg @node SAME_TYPE_AS
12285 1.1 mrg @section @code{SAME_TYPE_AS} --- Query dynamic types for equality
12286 1.1 mrg @fnindex SAME_TYPE_AS
12287 1.1 mrg
12288 1.1 mrg @table @asis
12289 1.1 mrg @item @emph{Description}:
12290 1.1 mrg Query dynamic types for equality.
12291 1.1 mrg
12292 1.1 mrg @item @emph{Standard}:
12293 1.1 mrg Fortran 2003 and later
12294 1.1 mrg
12295 1.1 mrg @item @emph{Class}:
12296 1.1 mrg Inquiry function
12297 1.1 mrg
12298 1.1 mrg @item @emph{Syntax}:
12299 1.1 mrg @code{RESULT = SAME_TYPE_AS(A, B)}
12300 1.1 mrg
12301 1.1 mrg @item @emph{Arguments}:
12302 1.1 mrg @multitable @columnfractions .15 .70
12303 1.1 mrg @item @var{A} @tab Shall be an object of extensible declared type or
12304 1.1 mrg unlimited polymorphic.
12305 1.1 mrg @item @var{B} @tab Shall be an object of extensible declared type or
12306 1.1 mrg unlimited polymorphic.
12307 1.1 mrg @end multitable
12308 1.1 mrg
12309 1.1 mrg @item @emph{Return value}:
12310 1.1 mrg The return value is a scalar of type default logical. It is true if and
12311 1.1 mrg only if the dynamic type of A is the same as the dynamic type of B.
12312 1.1 mrg
12313 1.1 mrg @item @emph{See also}:
12314 1.1 mrg @ref{EXTENDS_TYPE_OF}
12315 1.1 mrg
12316 1.1 mrg @end table
12317 1.1 mrg
12318 1.1 mrg
12319 1.1 mrg
12320 1.1 mrg @node SCALE
12321 1.1 mrg @section @code{SCALE} --- Scale a real value
12322 1.1 mrg @fnindex SCALE
12323 1.1 mrg @cindex real number, scale
12324 1.1 mrg @cindex floating point, scale
12325 1.1 mrg
12326 1.1 mrg @table @asis
12327 1.1 mrg @item @emph{Description}:
12328 1.1 mrg @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
12329 1.1 mrg
12330 1.1 mrg @item @emph{Standard}:
12331 1.1 mrg Fortran 95 and later
12332 1.1 mrg
12333 1.1 mrg @item @emph{Class}:
12334 1.1 mrg Elemental function
12335 1.1 mrg
12336 1.1 mrg @item @emph{Syntax}:
12337 1.1 mrg @code{RESULT = SCALE(X, I)}
12338 1.1 mrg
12339 1.1 mrg @item @emph{Arguments}:
12340 1.1 mrg @multitable @columnfractions .15 .70
12341 1.1 mrg @item @var{X} @tab The type of the argument shall be a @code{REAL}.
12342 1.1 mrg @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
12343 1.1 mrg @end multitable
12344 1.1 mrg
12345 1.1 mrg @item @emph{Return value}:
12346 1.1 mrg The return value is of the same type and kind as @var{X}.
12347 1.1 mrg Its value is @code{X * RADIX(X)**I}.
12348 1.1 mrg
12349 1.1 mrg @item @emph{Example}:
12350 1.1 mrg @smallexample
12351 1.1 mrg program test_scale
12352 1.1 mrg real :: x = 178.1387e-4
12353 1.1 mrg integer :: i = 5
12354 1.1 mrg print *, scale(x,i), x*radix(x)**i
12355 1.1 mrg end program test_scale
12356 1.1 mrg @end smallexample
12357 1.1 mrg
12358 1.1 mrg @end table
12359 1.1 mrg
12360 1.1 mrg
12361 1.1 mrg
12362 1.1 mrg @node SCAN
12363 1.1 mrg @section @code{SCAN} --- Scan a string for the presence of a set of characters
12364 1.1 mrg @fnindex SCAN
12365 1.1 mrg @cindex string, find subset
12366 1.1 mrg
12367 1.1 mrg @table @asis
12368 1.1 mrg @item @emph{Description}:
12369 1.1 mrg Scans a @var{STRING} for any of the characters in a @var{SET}
12370 1.1 mrg of characters.
12371 1.1 mrg
12372 1.1 mrg If @var{BACK} is either absent or equals @code{FALSE}, this function
12373 1.1 mrg returns the position of the leftmost character of @var{STRING} that is
12374 1.1 mrg in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
12375 1.1 mrg is returned. If no character of @var{SET} is found in @var{STRING}, the
12376 1.1 mrg result is zero.
12377 1.1 mrg
12378 1.1 mrg @item @emph{Standard}:
12379 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12380 1.1 mrg
12381 1.1 mrg @item @emph{Class}:
12382 1.1 mrg Elemental function
12383 1.1 mrg
12384 1.1 mrg @item @emph{Syntax}:
12385 1.1 mrg @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
12386 1.1 mrg
12387 1.1 mrg @item @emph{Arguments}:
12388 1.1 mrg @multitable @columnfractions .15 .70
12389 1.1 mrg @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12390 1.1 mrg @item @var{SET} @tab Shall be of type @code{CHARACTER}.
12391 1.1 mrg @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
12392 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12393 1.1 mrg expression indicating the kind parameter of the result.
12394 1.1 mrg @end multitable
12395 1.1 mrg
12396 1.1 mrg @item @emph{Return value}:
12397 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12398 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
12399 1.1 mrg
12400 1.1 mrg @item @emph{Example}:
12401 1.1 mrg @smallexample
12402 1.1 mrg PROGRAM test_scan
12403 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
12404 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
12405 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
12406 1.1 mrg END PROGRAM
12407 1.1 mrg @end smallexample
12408 1.1 mrg
12409 1.1 mrg @item @emph{See also}:
12410 1.1 mrg @ref{INDEX intrinsic}, @ref{VERIFY}
12411 1.1 mrg @end table
12412 1.1 mrg
12413 1.1 mrg
12414 1.1 mrg
12415 1.1 mrg @node SECNDS
12416 1.1 mrg @section @code{SECNDS} --- Time function
12417 1.1 mrg @fnindex SECNDS
12418 1.1 mrg @cindex time, elapsed
12419 1.1 mrg @cindex elapsed time
12420 1.1 mrg
12421 1.1 mrg @table @asis
12422 1.1 mrg @item @emph{Description}:
12423 1.1 mrg @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
12424 1.1 mrg @var{X} is a reference time, also in seconds. If this is zero, the time in
12425 1.1 mrg seconds from midnight is returned. This function is non-standard and its
12426 1.1 mrg use is discouraged.
12427 1.1 mrg
12428 1.1 mrg @item @emph{Standard}:
12429 1.1 mrg GNU extension
12430 1.1 mrg
12431 1.1 mrg @item @emph{Class}:
12432 1.1 mrg Function
12433 1.1 mrg
12434 1.1 mrg @item @emph{Syntax}:
12435 1.1 mrg @code{RESULT = SECNDS (X)}
12436 1.1 mrg
12437 1.1 mrg @item @emph{Arguments}:
12438 1.1 mrg @multitable @columnfractions .15 .70
12439 1.1 mrg @item @var{T} @tab Shall be of type @code{REAL(4)}.
12440 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL(4)}.
12441 1.1 mrg @end multitable
12442 1.1 mrg
12443 1.1 mrg @item @emph{Return value}:
12444 1.1 mrg None
12445 1.1 mrg
12446 1.1 mrg @item @emph{Example}:
12447 1.1 mrg @smallexample
12448 1.1 mrg program test_secnds
12449 1.1 mrg integer :: i
12450 1.1 mrg real(4) :: t1, t2
12451 1.1 mrg print *, secnds (0.0) ! seconds since midnight
12452 1.1 mrg t1 = secnds (0.0) ! reference time
12453 1.1 mrg do i = 1, 10000000 ! do something
12454 1.1 mrg end do
12455 1.1 mrg t2 = secnds (t1) ! elapsed time
12456 1.1 mrg print *, "Something took ", t2, " seconds."
12457 1.1 mrg end program test_secnds
12458 1.1 mrg @end smallexample
12459 1.1 mrg @end table
12460 1.1 mrg
12461 1.1 mrg
12462 1.1 mrg
12463 1.1 mrg @node SECOND
12464 1.1 mrg @section @code{SECOND} --- CPU time function
12465 1.1 mrg @fnindex SECOND
12466 1.1 mrg @cindex time, elapsed
12467 1.1 mrg @cindex elapsed time
12468 1.1 mrg
12469 1.1 mrg @table @asis
12470 1.1 mrg @item @emph{Description}:
12471 1.1 mrg Returns a @code{REAL(4)} value representing the elapsed CPU time in
12472 1.1 mrg seconds. This provides the same functionality as the standard
12473 1.1 mrg @code{CPU_TIME} intrinsic, and is only included for backwards
12474 1.1 mrg compatibility.
12475 1.1 mrg
12476 1.1 mrg This intrinsic is provided in both subroutine and function forms;
12477 1.1 mrg however, only one form can be used in any given program unit.
12478 1.1 mrg
12479 1.1 mrg @item @emph{Standard}:
12480 1.1 mrg GNU extension
12481 1.1 mrg
12482 1.1 mrg @item @emph{Class}:
12483 1.1 mrg Subroutine, function
12484 1.1 mrg
12485 1.1 mrg @item @emph{Syntax}:
12486 1.1 mrg @multitable @columnfractions .80
12487 1.1 mrg @item @code{CALL SECOND(TIME)}
12488 1.1 mrg @item @code{TIME = SECOND()}
12489 1.1 mrg @end multitable
12490 1.1 mrg
12491 1.1 mrg @item @emph{Arguments}:
12492 1.1 mrg @multitable @columnfractions .15 .70
12493 1.1 mrg @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
12494 1.1 mrg @end multitable
12495 1.1 mrg
12496 1.1 mrg @item @emph{Return value}:
12497 1.1 mrg In either syntax, @var{TIME} is set to the process's current runtime in
12498 1.1 mrg seconds.
12499 1.1 mrg
12500 1.1 mrg @item @emph{See also}:
12501 1.1 mrg @ref{CPU_TIME}
12502 1.1 mrg
12503 1.1 mrg @end table
12504 1.1 mrg
12505 1.1 mrg
12506 1.1 mrg
12507 1.1 mrg @node SELECTED_CHAR_KIND
12508 1.1 mrg @section @code{SELECTED_CHAR_KIND} --- Choose character kind
12509 1.1 mrg @fnindex SELECTED_CHAR_KIND
12510 1.1 mrg @cindex character kind
12511 1.1 mrg @cindex kind, character
12512 1.1 mrg
12513 1.1 mrg @table @asis
12514 1.1 mrg @item @emph{Description}:
12515 1.1 mrg
12516 1.1 mrg @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
12517 1.1 mrg set named @var{NAME}, if a character set with such a name is supported,
12518 1.1 mrg or @math{-1} otherwise. Currently, supported character sets include
12519 1.1 mrg ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
12520 1.1 mrg (Universal Character Set, UCS-4) which is commonly known as Unicode.
12521 1.1 mrg
12522 1.1 mrg @item @emph{Standard}:
12523 1.1 mrg Fortran 2003 and later
12524 1.1 mrg
12525 1.1 mrg @item @emph{Class}:
12526 1.1 mrg Transformational function
12527 1.1 mrg
12528 1.1 mrg @item @emph{Syntax}:
12529 1.1 mrg @code{RESULT = SELECTED_CHAR_KIND(NAME)}
12530 1.1 mrg
12531 1.1 mrg @item @emph{Arguments}:
12532 1.1 mrg @multitable @columnfractions .15 .70
12533 1.1 mrg @item @var{NAME} @tab Shall be a scalar and of the default character type.
12534 1.1 mrg @end multitable
12535 1.1 mrg
12536 1.1 mrg @item @emph{Example}:
12537 1.1 mrg @smallexample
12538 1.1 mrg program character_kind
12539 1.1 mrg use iso_fortran_env
12540 1.1 mrg implicit none
12541 1.1 mrg integer, parameter :: ascii = selected_char_kind ("ascii")
12542 1.1 mrg integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
12543 1.1 mrg
12544 1.1 mrg character(kind=ascii, len=26) :: alphabet
12545 1.1 mrg character(kind=ucs4, len=30) :: hello_world
12546 1.1 mrg
12547 1.1 mrg alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
12548 1.1 mrg hello_world = ucs4_'Hello World and Ni Hao -- ' &
12549 1.1 mrg // char (int (z'4F60'), ucs4) &
12550 1.1 mrg // char (int (z'597D'), ucs4)
12551 1.1 mrg
12552 1.1 mrg write (*,*) alphabet
12553 1.1 mrg
12554 1.1 mrg open (output_unit, encoding='UTF-8')
12555 1.1 mrg write (*,*) trim (hello_world)
12556 1.1 mrg end program character_kind
12557 1.1 mrg @end smallexample
12558 1.1 mrg @end table
12559 1.1 mrg
12560 1.1 mrg
12561 1.1 mrg
12562 1.1 mrg @node SELECTED_INT_KIND
12563 1.1 mrg @section @code{SELECTED_INT_KIND} --- Choose integer kind
12564 1.1 mrg @fnindex SELECTED_INT_KIND
12565 1.1 mrg @cindex integer kind
12566 1.1 mrg @cindex kind, integer
12567 1.1 mrg
12568 1.1 mrg @table @asis
12569 1.1 mrg @item @emph{Description}:
12570 1.1 mrg @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
12571 1.1 mrg type that can represent all values ranging from @math{-10^R} (exclusive)
12572 1.1 mrg to @math{10^R} (exclusive). If there is no integer kind that accommodates
12573 1.1 mrg this range, @code{SELECTED_INT_KIND} returns @math{-1}.
12574 1.1 mrg
12575 1.1 mrg @item @emph{Standard}:
12576 1.1 mrg Fortran 95 and later
12577 1.1 mrg
12578 1.1 mrg @item @emph{Class}:
12579 1.1 mrg Transformational function
12580 1.1 mrg
12581 1.1 mrg @item @emph{Syntax}:
12582 1.1 mrg @code{RESULT = SELECTED_INT_KIND(R)}
12583 1.1 mrg
12584 1.1 mrg @item @emph{Arguments}:
12585 1.1 mrg @multitable @columnfractions .15 .70
12586 1.1 mrg @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
12587 1.1 mrg @end multitable
12588 1.1 mrg
12589 1.1 mrg @item @emph{Example}:
12590 1.1 mrg @smallexample
12591 1.1 mrg program large_integers
12592 1.1 mrg integer,parameter :: k5 = selected_int_kind(5)
12593 1.1 mrg integer,parameter :: k15 = selected_int_kind(15)
12594 1.1 mrg integer(kind=k5) :: i5
12595 1.1 mrg integer(kind=k15) :: i15
12596 1.1 mrg
12597 1.1 mrg print *, huge(i5), huge(i15)
12598 1.1 mrg
12599 1.1 mrg ! The following inequalities are always true
12600 1.1 mrg print *, huge(i5) >= 10_k5**5-1
12601 1.1 mrg print *, huge(i15) >= 10_k15**15-1
12602 1.1 mrg end program large_integers
12603 1.1 mrg @end smallexample
12604 1.1 mrg @end table
12605 1.1 mrg
12606 1.1 mrg
12607 1.1 mrg
12608 1.1 mrg @node SELECTED_REAL_KIND
12609 1.1 mrg @section @code{SELECTED_REAL_KIND} --- Choose real kind
12610 1.1 mrg @fnindex SELECTED_REAL_KIND
12611 1.1 mrg @cindex real kind
12612 1.1 mrg @cindex kind, real
12613 1.1 mrg @cindex radix, real
12614 1.1 mrg
12615 1.1 mrg @table @asis
12616 1.1 mrg @item @emph{Description}:
12617 1.1 mrg @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
12618 1.1 mrg with decimal precision of at least @code{P} digits, exponent range of
12619 1.1 mrg at least @code{R}, and with a radix of @code{RADIX}.
12620 1.1 mrg
12621 1.1 mrg @item @emph{Standard}:
12622 1.1 mrg Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
12623 1.1 mrg
12624 1.1 mrg @item @emph{Class}:
12625 1.1 mrg Transformational function
12626 1.1 mrg
12627 1.1 mrg @item @emph{Syntax}:
12628 1.1 mrg @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
12629 1.1 mrg
12630 1.1 mrg @item @emph{Arguments}:
12631 1.1 mrg @multitable @columnfractions .15 .70
12632 1.1 mrg @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12633 1.1 mrg @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12634 1.1 mrg @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12635 1.1 mrg @end multitable
12636 1.1 mrg Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
12637 1.1 mrg be present; since Fortran 2008, they are assumed to be zero if absent.
12638 1.1 mrg
12639 1.1 mrg @item @emph{Return value}:
12640 1.1 mrg
12641 1.1 mrg @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
12642 1.1 mrg a real data type with decimal precision of at least @code{P} digits, a
12643 1.1 mrg decimal exponent range of at least @code{R}, and with the requested
12644 1.1 mrg @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
12645 1.1 mrg any radix can be returned. If more than one real data type meet the
12646 1.1 mrg criteria, the kind of the data type with the smallest decimal precision
12647 1.1 mrg is returned. If no real data type matches the criteria, the result is
12648 1.1 mrg @table @asis
12649 1.1 mrg @item -1 if the processor does not support a real data type with a
12650 1.1 mrg precision greater than or equal to @code{P}, but the @code{R} and
12651 1.1 mrg @code{RADIX} requirements can be fulfilled
12652 1.1 mrg @item -2 if the processor does not support a real type with an exponent
12653 1.1 mrg range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
12654 1.1 mrg are fulfillable
12655 1.1 mrg @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
12656 1.1 mrg are fulfillable
12657 1.1 mrg @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
12658 1.1 mrg are fulfillable
12659 1.1 mrg @item -5 if there is no real type with the given @code{RADIX}
12660 1.1 mrg @end table
12661 1.1 mrg
12662 1.1 mrg @item @emph{See also}:
12663 1.1 mrg @ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
12664 1.1 mrg
12665 1.1 mrg @item @emph{Example}:
12666 1.1 mrg @smallexample
12667 1.1 mrg program real_kinds
12668 1.1 mrg integer,parameter :: p6 = selected_real_kind(6)
12669 1.1 mrg integer,parameter :: p10r100 = selected_real_kind(10,100)
12670 1.1 mrg integer,parameter :: r400 = selected_real_kind(r=400)
12671 1.1 mrg real(kind=p6) :: x
12672 1.1 mrg real(kind=p10r100) :: y
12673 1.1 mrg real(kind=r400) :: z
12674 1.1 mrg
12675 1.1 mrg print *, precision(x), range(x)
12676 1.1 mrg print *, precision(y), range(y)
12677 1.1 mrg print *, precision(z), range(z)
12678 1.1 mrg end program real_kinds
12679 1.1 mrg @end smallexample
12680 1.1 mrg @end table
12681 1.1 mrg
12682 1.1 mrg
12683 1.1 mrg
12684 1.1 mrg @node SET_EXPONENT
12685 1.1 mrg @section @code{SET_EXPONENT} --- Set the exponent of the model
12686 1.1 mrg @fnindex SET_EXPONENT
12687 1.1 mrg @cindex real number, set exponent
12688 1.1 mrg @cindex floating point, set exponent
12689 1.1 mrg
12690 1.1 mrg @table @asis
12691 1.1 mrg @item @emph{Description}:
12692 1.1 mrg @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
12693 1.1 mrg is that that of @var{X} and whose exponent part is @var{I}.
12694 1.1 mrg
12695 1.1 mrg @item @emph{Standard}:
12696 1.1 mrg Fortran 95 and later
12697 1.1 mrg
12698 1.1 mrg @item @emph{Class}:
12699 1.1 mrg Elemental function
12700 1.1 mrg
12701 1.1 mrg @item @emph{Syntax}:
12702 1.1 mrg @code{RESULT = SET_EXPONENT(X, I)}
12703 1.1 mrg
12704 1.1 mrg @item @emph{Arguments}:
12705 1.1 mrg @multitable @columnfractions .15 .70
12706 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
12707 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
12708 1.1 mrg @end multitable
12709 1.1 mrg
12710 1.1 mrg @item @emph{Return value}:
12711 1.1 mrg The return value is of the same type and kind as @var{X}.
12712 1.1 mrg The real number whose fractional part
12713 1.1 mrg is that that of @var{X} and whose exponent part if @var{I} is returned;
12714 1.1 mrg it is @code{FRACTION(X) * RADIX(X)**I}.
12715 1.1 mrg
12716 1.1 mrg @item @emph{Example}:
12717 1.1 mrg @smallexample
12718 1.1 mrg PROGRAM test_setexp
12719 1.1 mrg REAL :: x = 178.1387e-4
12720 1.1 mrg INTEGER :: i = 17
12721 1.1 mrg PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
12722 1.1 mrg END PROGRAM
12723 1.1 mrg @end smallexample
12724 1.1 mrg
12725 1.1 mrg @end table
12726 1.1 mrg
12727 1.1 mrg
12728 1.1 mrg
12729 1.1 mrg @node SHAPE
12730 1.1 mrg @section @code{SHAPE} --- Determine the shape of an array
12731 1.1 mrg @fnindex SHAPE
12732 1.1 mrg @cindex array, shape
12733 1.1 mrg
12734 1.1 mrg @table @asis
12735 1.1 mrg @item @emph{Description}:
12736 1.1 mrg Determines the shape of an array.
12737 1.1 mrg
12738 1.1 mrg @item @emph{Standard}:
12739 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12740 1.1 mrg
12741 1.1 mrg @item @emph{Class}:
12742 1.1 mrg Inquiry function
12743 1.1 mrg
12744 1.1 mrg @item @emph{Syntax}:
12745 1.1 mrg @code{RESULT = SHAPE(SOURCE [, KIND])}
12746 1.1 mrg
12747 1.1 mrg @item @emph{Arguments}:
12748 1.1 mrg @multitable @columnfractions .15 .70
12749 1.1 mrg @item @var{SOURCE} @tab Shall be an array or scalar of any type.
12750 1.1 mrg If @var{SOURCE} is a pointer it must be associated and allocatable
12751 1.1 mrg arrays must be allocated.
12752 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12753 1.1 mrg expression indicating the kind parameter of the result.
12754 1.1 mrg @end multitable
12755 1.1 mrg
12756 1.1 mrg @item @emph{Return value}:
12757 1.1 mrg An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
12758 1.1 mrg has dimensions. The elements of the resulting array correspond to the extend
12759 1.1 mrg of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
12760 1.1 mrg the result is the rank one array of size zero. If @var{KIND} is absent, the
12761 1.1 mrg return value has the default integer kind otherwise the specified kind.
12762 1.1 mrg
12763 1.1 mrg @item @emph{Example}:
12764 1.1 mrg @smallexample
12765 1.1 mrg PROGRAM test_shape
12766 1.1 mrg INTEGER, DIMENSION(-1:1, -1:2) :: A
12767 1.1 mrg WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
12768 1.1 mrg WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
12769 1.1 mrg END PROGRAM
12770 1.1 mrg @end smallexample
12771 1.1 mrg
12772 1.1 mrg @item @emph{See also}:
12773 1.1 mrg @ref{RESHAPE}, @ref{SIZE}
12774 1.1 mrg @end table
12775 1.1 mrg
12776 1.1 mrg
12777 1.1 mrg
12778 1.1 mrg @node SHIFTA
12779 1.1 mrg @section @code{SHIFTA} --- Right shift with fill
12780 1.1 mrg @fnindex SHIFTA
12781 1.1 mrg @cindex bits, shift right
12782 1.1 mrg @cindex shift, right with fill
12783 1.1 mrg
12784 1.1 mrg @table @asis
12785 1.1 mrg @item @emph{Description}:
12786 1.1 mrg @code{SHIFTA} returns a value corresponding to @var{I} with all of the
12787 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} that be
12788 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
12789 1.1 mrg the result value is undefined. Bits shifted out from the right end
12790 1.1 mrg are lost. The fill is arithmetic: the bits shifted in from the left
12791 1.1 mrg end are equal to the leftmost bit, which in two's complement
12792 1.1 mrg representation is the sign bit.
12793 1.1 mrg
12794 1.1 mrg @item @emph{Standard}:
12795 1.1 mrg Fortran 2008 and later
12796 1.1 mrg
12797 1.1 mrg @item @emph{Class}:
12798 1.1 mrg Elemental function
12799 1.1 mrg
12800 1.1 mrg @item @emph{Syntax}:
12801 1.1 mrg @code{RESULT = SHIFTA(I, SHIFT)}
12802 1.1 mrg
12803 1.1 mrg @item @emph{Arguments}:
12804 1.1 mrg @multitable @columnfractions .15 .70
12805 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
12806 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12807 1.1 mrg @end multitable
12808 1.1 mrg
12809 1.1 mrg @item @emph{Return value}:
12810 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
12811 1.1 mrg @var{I}.
12812 1.1 mrg
12813 1.1 mrg @item @emph{See also}:
12814 1.1 mrg @ref{SHIFTL}, @ref{SHIFTR}
12815 1.1 mrg @end table
12816 1.1 mrg
12817 1.1 mrg
12818 1.1 mrg
12819 1.1 mrg @node SHIFTL
12820 1.1 mrg @section @code{SHIFTL} --- Left shift
12821 1.1 mrg @fnindex SHIFTL
12822 1.1 mrg @cindex bits, shift left
12823 1.1 mrg @cindex shift, left
12824 1.1 mrg
12825 1.1 mrg @table @asis
12826 1.1 mrg @item @emph{Description}:
12827 1.1 mrg @code{SHIFTL} returns a value corresponding to @var{I} with all of the
12828 1.1 mrg bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be
12829 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
12830 1.1 mrg the result value is undefined. Bits shifted out from the left end are
12831 1.1 mrg lost, and bits shifted in from the right end are set to 0.
12832 1.1 mrg
12833 1.1 mrg @item @emph{Standard}:
12834 1.1 mrg Fortran 2008 and later
12835 1.1 mrg
12836 1.1 mrg @item @emph{Class}:
12837 1.1 mrg Elemental function
12838 1.1 mrg
12839 1.1 mrg @item @emph{Syntax}:
12840 1.1 mrg @code{RESULT = SHIFTL(I, SHIFT)}
12841 1.1 mrg
12842 1.1 mrg @item @emph{Arguments}:
12843 1.1 mrg @multitable @columnfractions .15 .70
12844 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
12845 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12846 1.1 mrg @end multitable
12847 1.1 mrg
12848 1.1 mrg @item @emph{Return value}:
12849 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
12850 1.1 mrg @var{I}.
12851 1.1 mrg
12852 1.1 mrg @item @emph{See also}:
12853 1.1 mrg @ref{SHIFTA}, @ref{SHIFTR}
12854 1.1 mrg @end table
12855 1.1 mrg
12856 1.1 mrg
12857 1.1 mrg
12858 1.1 mrg @node SHIFTR
12859 1.1 mrg @section @code{SHIFTR} --- Right shift
12860 1.1 mrg @fnindex SHIFTR
12861 1.1 mrg @cindex bits, shift right
12862 1.1 mrg @cindex shift, right
12863 1.1 mrg
12864 1.1 mrg @table @asis
12865 1.1 mrg @item @emph{Description}:
12866 1.1 mrg @code{SHIFTR} returns a value corresponding to @var{I} with all of the
12867 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be
12868 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
12869 1.1 mrg the result value is undefined. Bits shifted out from the right end
12870 1.1 mrg are lost, and bits shifted in from the left end are set to 0.
12871 1.1 mrg
12872 1.1 mrg @item @emph{Standard}:
12873 1.1 mrg Fortran 2008 and later
12874 1.1 mrg
12875 1.1 mrg @item @emph{Class}:
12876 1.1 mrg Elemental function
12877 1.1 mrg
12878 1.1 mrg @item @emph{Syntax}:
12879 1.1 mrg @code{RESULT = SHIFTR(I, SHIFT)}
12880 1.1 mrg
12881 1.1 mrg @item @emph{Arguments}:
12882 1.1 mrg @multitable @columnfractions .15 .70
12883 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}.
12884 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12885 1.1 mrg @end multitable
12886 1.1 mrg
12887 1.1 mrg @item @emph{Return value}:
12888 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as
12889 1.1 mrg @var{I}.
12890 1.1 mrg
12891 1.1 mrg @item @emph{See also}:
12892 1.1 mrg @ref{SHIFTA}, @ref{SHIFTL}
12893 1.1 mrg @end table
12894 1.1 mrg
12895 1.1 mrg
12896 1.1 mrg
12897 1.1 mrg @node SIGN
12898 1.1 mrg @section @code{SIGN} --- Sign copying function
12899 1.1 mrg @fnindex SIGN
12900 1.1 mrg @fnindex ISIGN
12901 1.1 mrg @fnindex DSIGN
12902 1.1 mrg @cindex sign copying
12903 1.1 mrg
12904 1.1 mrg @table @asis
12905 1.1 mrg @item @emph{Description}:
12906 1.1 mrg @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
12907 1.1 mrg
12908 1.1 mrg @item @emph{Standard}:
12909 1.1 mrg Fortran 77 and later
12910 1.1 mrg
12911 1.1 mrg @item @emph{Class}:
12912 1.1 mrg Elemental function
12913 1.1 mrg
12914 1.1 mrg @item @emph{Syntax}:
12915 1.1 mrg @code{RESULT = SIGN(A, B)}
12916 1.1 mrg
12917 1.1 mrg @item @emph{Arguments}:
12918 1.1 mrg @multitable @columnfractions .15 .70
12919 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
12920 1.1 mrg @item @var{B} @tab Shall be of the same type and kind as @var{A}
12921 1.1 mrg @end multitable
12922 1.1 mrg
12923 1.1 mrg @item @emph{Return value}:
12924 1.1 mrg The kind of the return value is that of @var{A} and @var{B}.
12925 1.1 mrg If @math{B\ge 0} then the result is @code{ABS(A)}, else
12926 1.1 mrg it is @code{-ABS(A)}.
12927 1.1 mrg
12928 1.1 mrg @item @emph{Example}:
12929 1.1 mrg @smallexample
12930 1.1 mrg program test_sign
12931 1.1 mrg print *, sign(-12,1)
12932 1.1 mrg print *, sign(-12,0)
12933 1.1 mrg print *, sign(-12,-1)
12934 1.1 mrg
12935 1.1 mrg print *, sign(-12.,1.)
12936 1.1 mrg print *, sign(-12.,0.)
12937 1.1 mrg print *, sign(-12.,-1.)
12938 1.1 mrg end program test_sign
12939 1.1 mrg @end smallexample
12940 1.1 mrg
12941 1.1 mrg @item @emph{Specific names}:
12942 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
12943 1.1 mrg @item Name @tab Arguments @tab Return type @tab Standard
12944 1.1 mrg @item @code{SIGN(A,B)} @tab @code{REAL(4) A, B} @tab @code{REAL(4)} @tab f77, gnu
12945 1.1 mrg @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
12946 1.1 mrg @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B} @tab @code{REAL(8)} @tab f77, gnu
12947 1.1 mrg @end multitable
12948 1.1 mrg @end table
12949 1.1 mrg
12950 1.1 mrg
12951 1.1 mrg
12952 1.1 mrg @node SIGNAL
12953 1.1 mrg @section @code{SIGNAL} --- Signal handling subroutine (or function)
12954 1.1 mrg @fnindex SIGNAL
12955 1.1 mrg @cindex system, signal handling
12956 1.1 mrg
12957 1.1 mrg @table @asis
12958 1.1 mrg @item @emph{Description}:
12959 1.1 mrg @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
12960 1.1 mrg @var{HANDLER} to be executed with a single integer argument when signal
12961 1.1 mrg @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
12962 1.1 mrg turn off handling of signal @var{NUMBER} or revert to its default
12963 1.1 mrg action. See @code{signal(2)}.
12964 1.1 mrg
12965 1.1 mrg If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
12966 1.1 mrg is supplied, it is set to the value returned by @code{signal(2)}.
12967 1.1 mrg
12968 1.1 mrg @item @emph{Standard}:
12969 1.1 mrg GNU extension
12970 1.1 mrg
12971 1.1 mrg @item @emph{Class}:
12972 1.1 mrg Subroutine, function
12973 1.1 mrg
12974 1.1 mrg @item @emph{Syntax}:
12975 1.1 mrg @multitable @columnfractions .80
12976 1.1 mrg @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
12977 1.1 mrg @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
12978 1.1 mrg @end multitable
12979 1.1 mrg
12980 1.1 mrg @item @emph{Arguments}:
12981 1.1 mrg @multitable @columnfractions .15 .70
12982 1.1 mrg @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
12983 1.1 mrg @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
12984 1.1 mrg @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
12985 1.1 mrg @code{INTEGER}. It is @code{INTENT(IN)}.
12986 1.1 mrg @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
12987 1.1 mrg integer. It has @code{INTENT(OUT)}.
12988 1.1 mrg @end multitable
12989 1.1 mrg @c TODO: What should the interface of the handler be? Does it take arguments?
12990 1.1 mrg
12991 1.1 mrg @item @emph{Return value}:
12992 1.1 mrg The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
12993 1.1 mrg
12994 1.1 mrg @item @emph{Example}:
12995 1.1 mrg @smallexample
12996 1.1 mrg program test_signal
12997 1.1 mrg intrinsic signal
12998 1.1 mrg external handler_print
12999 1.1 mrg
13000 1.1 mrg call signal (12, handler_print)
13001 1.1 mrg call signal (10, 1)
13002 1.1 mrg
13003 1.1 mrg call sleep (30)
13004 1.1 mrg end program test_signal
13005 1.1 mrg @end smallexample
13006 1.1 mrg @end table
13007 1.1 mrg
13008 1.1 mrg
13009 1.1 mrg
13010 1.1 mrg @node SIN
13011 1.1 mrg @section @code{SIN} --- Sine function
13012 1.1 mrg @fnindex SIN
13013 1.1 mrg @fnindex DSIN
13014 1.1 mrg @fnindex CSIN
13015 1.1 mrg @fnindex ZSIN
13016 1.1 mrg @fnindex CDSIN
13017 1.1 mrg @cindex trigonometric function, sine
13018 1.1 mrg @cindex sine
13019 1.1 mrg
13020 1.1 mrg @table @asis
13021 1.1 mrg @item @emph{Description}:
13022 1.1 mrg @code{SIN(X)} computes the sine of @var{X}.
13023 1.1 mrg
13024 1.1 mrg @item @emph{Standard}:
13025 1.1 mrg Fortran 77 and later
13026 1.1 mrg
13027 1.1 mrg @item @emph{Class}:
13028 1.1 mrg Elemental function
13029 1.1 mrg
13030 1.1 mrg @item @emph{Syntax}:
13031 1.1 mrg @code{RESULT = SIN(X)}
13032 1.1 mrg
13033 1.1 mrg @item @emph{Arguments}:
13034 1.1 mrg @multitable @columnfractions .15 .70
13035 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
13036 1.1 mrg @code{COMPLEX}.
13037 1.1 mrg @end multitable
13038 1.1 mrg
13039 1.1 mrg @item @emph{Return value}:
13040 1.1 mrg The return value has same type and kind as @var{X}.
13041 1.1 mrg
13042 1.1 mrg @item @emph{Example}:
13043 1.1 mrg @smallexample
13044 1.1 mrg program test_sin
13045 1.1 mrg real :: x = 0.0
13046 1.1 mrg x = sin(x)
13047 1.1 mrg end program test_sin
13048 1.1 mrg @end smallexample
13049 1.1 mrg
13050 1.1 mrg @item @emph{Specific names}:
13051 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13052 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13053 1.1 mrg @item @code{SIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f77, gnu
13054 1.1 mrg @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
13055 1.1 mrg @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
13056 1.1 mrg @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
13057 1.1 mrg @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
13058 1.1 mrg @end multitable
13059 1.1 mrg
13060 1.1 mrg @item @emph{See also}:
13061 1.1 mrg Inverse function: @ref{ASIN}
13062 1.1 mrg Degrees function: @ref{SIND}
13063 1.1 mrg @end table
13064 1.1 mrg
13065 1.1 mrg
13066 1.1 mrg
13067 1.1 mrg @node SIND
13068 1.1 mrg @section @code{SIND} --- Sine function, degrees
13069 1.1 mrg @fnindex SIND
13070 1.1 mrg @fnindex DSIND
13071 1.1 mrg @fnindex CSIND
13072 1.1 mrg @fnindex ZSIND
13073 1.1 mrg @fnindex CDSIND
13074 1.1 mrg @cindex trigonometric function, sine, degrees
13075 1.1 mrg @cindex sine, degrees
13076 1.1 mrg
13077 1.1 mrg @table @asis
13078 1.1 mrg @item @emph{Description}:
13079 1.1 mrg @code{SIND(X)} computes the sine of @var{X} in degrees.
13080 1.1 mrg
13081 1.1 mrg This function is for compatibility only and should be avoided in favor of
13082 1.1 mrg standard constructs wherever possible.
13083 1.1 mrg
13084 1.1 mrg @item @emph{Standard}:
13085 1.1 mrg GNU Extension, enabled with @option{-fdec-math}.
13086 1.1 mrg
13087 1.1 mrg @item @emph{Class}:
13088 1.1 mrg Elemental function
13089 1.1 mrg
13090 1.1 mrg @item @emph{Syntax}:
13091 1.1 mrg @code{RESULT = SIND(X)}
13092 1.1 mrg
13093 1.1 mrg @item @emph{Arguments}:
13094 1.1 mrg @multitable @columnfractions .15 .70
13095 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
13096 1.1 mrg @code{COMPLEX}.
13097 1.1 mrg @end multitable
13098 1.1 mrg
13099 1.1 mrg @item @emph{Return value}:
13100 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees.
13101 1.1 mrg
13102 1.1 mrg @item @emph{Example}:
13103 1.1 mrg @smallexample
13104 1.1 mrg program test_sind
13105 1.1 mrg real :: x = 0.0
13106 1.1 mrg x = sind(x)
13107 1.1 mrg end program test_sind
13108 1.1 mrg @end smallexample
13109 1.1 mrg
13110 1.1 mrg @item @emph{Specific names}:
13111 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13112 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13113 1.1 mrg @item @code{SIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
13114 1.1 mrg @item @code{DSIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
13115 1.1 mrg @item @code{CSIND(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU Extension
13116 1.1 mrg @item @code{ZSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU Extension
13117 1.1 mrg @item @code{CDSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU Extension
13118 1.1 mrg @end multitable
13119 1.1 mrg
13120 1.1 mrg @item @emph{See also}:
13121 1.1 mrg Inverse function: @ref{ASIND}
13122 1.1 mrg Radians function: @ref{SIN}
13123 1.1 mrg
13124 1.1 mrg @end table
13125 1.1 mrg
13126 1.1 mrg
13127 1.1 mrg
13128 1.1 mrg @node SINH
13129 1.1 mrg @section @code{SINH} --- Hyperbolic sine function
13130 1.1 mrg @fnindex SINH
13131 1.1 mrg @fnindex DSINH
13132 1.1 mrg @cindex hyperbolic sine
13133 1.1 mrg @cindex hyperbolic function, sine
13134 1.1 mrg @cindex sine, hyperbolic
13135 1.1 mrg
13136 1.1 mrg @table @asis
13137 1.1 mrg @item @emph{Description}:
13138 1.1 mrg @code{SINH(X)} computes the hyperbolic sine of @var{X}.
13139 1.1 mrg
13140 1.1 mrg @item @emph{Standard}:
13141 1.1 mrg Fortran 95 and later, for a complex argument Fortran 2008 or later
13142 1.1 mrg
13143 1.1 mrg @item @emph{Class}:
13144 1.1 mrg Elemental function
13145 1.1 mrg
13146 1.1 mrg @item @emph{Syntax}:
13147 1.1 mrg @code{RESULT = SINH(X)}
13148 1.1 mrg
13149 1.1 mrg @item @emph{Arguments}:
13150 1.1 mrg @multitable @columnfractions .15 .70
13151 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13152 1.1 mrg @end multitable
13153 1.1 mrg
13154 1.1 mrg @item @emph{Return value}:
13155 1.1 mrg The return value has same type and kind as @var{X}.
13156 1.1 mrg
13157 1.1 mrg @item @emph{Example}:
13158 1.1 mrg @smallexample
13159 1.1 mrg program test_sinh
13160 1.1 mrg real(8) :: x = - 1.0_8
13161 1.1 mrg x = sinh(x)
13162 1.1 mrg end program test_sinh
13163 1.1 mrg @end smallexample
13164 1.1 mrg
13165 1.1 mrg @item @emph{Specific names}:
13166 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13167 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13168 1.1 mrg @item @code{SINH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13169 1.1 mrg @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13170 1.1 mrg @end multitable
13171 1.1 mrg
13172 1.1 mrg @item @emph{See also}:
13173 1.1 mrg @ref{ASINH}
13174 1.1 mrg @end table
13175 1.1 mrg
13176 1.1 mrg
13177 1.1 mrg
13178 1.1 mrg @node SIZE
13179 1.1 mrg @section @code{SIZE} --- Determine the size of an array
13180 1.1 mrg @fnindex SIZE
13181 1.1 mrg @cindex array, size
13182 1.1 mrg @cindex array, number of elements
13183 1.1 mrg @cindex array, count elements
13184 1.1 mrg
13185 1.1 mrg @table @asis
13186 1.1 mrg @item @emph{Description}:
13187 1.1 mrg Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
13188 1.1 mrg or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
13189 1.1 mrg
13190 1.1 mrg @item @emph{Standard}:
13191 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
13192 1.1 mrg
13193 1.1 mrg @item @emph{Class}:
13194 1.1 mrg Inquiry function
13195 1.1 mrg
13196 1.1 mrg @item @emph{Syntax}:
13197 1.1 mrg @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
13198 1.1 mrg
13199 1.1 mrg @item @emph{Arguments}:
13200 1.1 mrg @multitable @columnfractions .15 .70
13201 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
13202 1.1 mrg a pointer it must be associated and allocatable arrays must be allocated.
13203 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
13204 1.1 mrg and its value shall be in the range from 1 to n, where n equals the rank
13205 1.1 mrg of @var{ARRAY}.
13206 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
13207 1.1 mrg expression indicating the kind parameter of the result.
13208 1.1 mrg @end multitable
13209 1.1 mrg
13210 1.1 mrg @item @emph{Return value}:
13211 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
13212 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
13213 1.1 mrg
13214 1.1 mrg @item @emph{Example}:
13215 1.1 mrg @smallexample
13216 1.1 mrg PROGRAM test_size
13217 1.1 mrg WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
13218 1.1 mrg END PROGRAM
13219 1.1 mrg @end smallexample
13220 1.1 mrg
13221 1.1 mrg @item @emph{See also}:
13222 1.1 mrg @ref{SHAPE}, @ref{RESHAPE}
13223 1.1 mrg @end table
13224 1.1 mrg
13225 1.1 mrg
13226 1.1 mrg @node SIZEOF
13227 1.1 mrg @section @code{SIZEOF} --- Size in bytes of an expression
13228 1.1 mrg @fnindex SIZEOF
13229 1.1 mrg @cindex expression size
13230 1.1 mrg @cindex size of an expression
13231 1.1 mrg
13232 1.1 mrg @table @asis
13233 1.1 mrg @item @emph{Description}:
13234 1.1 mrg @code{SIZEOF(X)} calculates the number of bytes of storage the
13235 1.1 mrg expression @code{X} occupies.
13236 1.1 mrg
13237 1.1 mrg @item @emph{Standard}:
13238 1.1 mrg GNU extension
13239 1.1 mrg
13240 1.1 mrg @item @emph{Class}:
13241 1.1 mrg Inquiry function
13242 1.1 mrg
13243 1.1 mrg @item @emph{Syntax}:
13244 1.1 mrg @code{N = SIZEOF(X)}
13245 1.1 mrg
13246 1.1 mrg @item @emph{Arguments}:
13247 1.1 mrg @multitable @columnfractions .15 .70
13248 1.1 mrg @item @var{X} @tab The argument shall be of any type, rank or shape.
13249 1.1 mrg @end multitable
13250 1.1 mrg
13251 1.1 mrg @item @emph{Return value}:
13252 1.1 mrg The return value is of type integer and of the system-dependent kind
13253 1.1 mrg @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
13254 1.1 mrg number of bytes occupied by the argument. If the argument has the
13255 1.1 mrg @code{POINTER} attribute, the number of bytes of the storage area pointed
13256 1.1 mrg to is returned. If the argument is of a derived type with @code{POINTER}
13257 1.1 mrg or @code{ALLOCATABLE} components, the return value does not account for
13258 1.1 mrg the sizes of the data pointed to by these components. If the argument is
13259 1.1 mrg polymorphic, the size according to the dynamic type is returned. The argument
13260 1.1 mrg may not be a procedure or procedure pointer. Note that the code assumes for
13261 1.1 mrg arrays that those are contiguous; for contiguous arrays, it returns the
13262 1.1 mrg storage or an array element multiplied by the size of the array.
13263 1.1 mrg
13264 1.1 mrg @item @emph{Example}:
13265 1.1 mrg @smallexample
13266 1.1 mrg integer :: i
13267 1.1 mrg real :: r, s(5)
13268 1.1 mrg print *, (sizeof(s)/sizeof(r) == 5)
13269 1.1 mrg end
13270 1.1 mrg @end smallexample
13271 1.1 mrg The example will print @code{.TRUE.} unless you are using a platform
13272 1.1 mrg where default @code{REAL} variables are unusually padded.
13273 1.1 mrg
13274 1.1 mrg @item @emph{See also}:
13275 1.1 mrg @ref{C_SIZEOF}, @ref{STORAGE_SIZE}
13276 1.1 mrg @end table
13277 1.1 mrg
13278 1.1 mrg
13279 1.1 mrg @node SLEEP
13280 1.1 mrg @section @code{SLEEP} --- Sleep for the specified number of seconds
13281 1.1 mrg @fnindex SLEEP
13282 1.1 mrg @cindex delayed execution
13283 1.1 mrg
13284 1.1 mrg @table @asis
13285 1.1 mrg @item @emph{Description}:
13286 1.1 mrg Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
13287 1.1 mrg
13288 1.1 mrg @item @emph{Standard}:
13289 1.1 mrg GNU extension
13290 1.1 mrg
13291 1.1 mrg @item @emph{Class}:
13292 1.1 mrg Subroutine
13293 1.1 mrg
13294 1.1 mrg @item @emph{Syntax}:
13295 1.1 mrg @code{CALL SLEEP(SECONDS)}
13296 1.1 mrg
13297 1.1 mrg @item @emph{Arguments}:
13298 1.1 mrg @multitable @columnfractions .15 .70
13299 1.1 mrg @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
13300 1.1 mrg @end multitable
13301 1.1 mrg
13302 1.1 mrg @item @emph{Example}:
13303 1.1 mrg @smallexample
13304 1.1 mrg program test_sleep
13305 1.1 mrg call sleep(5)
13306 1.1 mrg end
13307 1.1 mrg @end smallexample
13308 1.1 mrg @end table
13309 1.1 mrg
13310 1.1 mrg
13311 1.1 mrg
13312 1.1 mrg @node SPACING
13313 1.1 mrg @section @code{SPACING} --- Smallest distance between two numbers of a given type
13314 1.1 mrg @fnindex SPACING
13315 1.1 mrg @cindex real number, relative spacing
13316 1.1 mrg @cindex floating point, relative spacing
13317 1.1 mrg
13318 1.1 mrg @table @asis
13319 1.1 mrg @item @emph{Description}:
13320 1.1 mrg Determines the distance between the argument @var{X} and the nearest
13321 1.1 mrg adjacent number of the same type.
13322 1.1 mrg
13323 1.1 mrg @item @emph{Standard}:
13324 1.1 mrg Fortran 95 and later
13325 1.1 mrg
13326 1.1 mrg @item @emph{Class}:
13327 1.1 mrg Elemental function
13328 1.1 mrg
13329 1.1 mrg @item @emph{Syntax}:
13330 1.1 mrg @code{RESULT = SPACING(X)}
13331 1.1 mrg
13332 1.1 mrg @item @emph{Arguments}:
13333 1.1 mrg @multitable @columnfractions .15 .70
13334 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
13335 1.1 mrg @end multitable
13336 1.1 mrg
13337 1.1 mrg @item @emph{Return value}:
13338 1.1 mrg The result is of the same type as the input argument @var{X}.
13339 1.1 mrg
13340 1.1 mrg @item @emph{Example}:
13341 1.1 mrg @smallexample
13342 1.1 mrg PROGRAM test_spacing
13343 1.1 mrg INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
13344 1.1 mrg INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
13345 1.1 mrg
13346 1.1 mrg WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
13347 1.1 mrg WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
13348 1.1 mrg END PROGRAM
13349 1.1 mrg @end smallexample
13350 1.1 mrg
13351 1.1 mrg @item @emph{See also}:
13352 1.1 mrg @ref{RRSPACING}
13353 1.1 mrg @end table
13354 1.1 mrg
13355 1.1 mrg
13356 1.1 mrg
13357 1.1 mrg @node SPREAD
13358 1.1 mrg @section @code{SPREAD} --- Add a dimension to an array
13359 1.1 mrg @fnindex SPREAD
13360 1.1 mrg @cindex array, increase dimension
13361 1.1 mrg @cindex array, duplicate elements
13362 1.1 mrg @cindex array, duplicate dimensions
13363 1.1 mrg
13364 1.1 mrg @table @asis
13365 1.1 mrg @item @emph{Description}:
13366 1.1 mrg Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
13367 1.1 mrg dimension @var{DIM}.
13368 1.1 mrg
13369 1.1 mrg @item @emph{Standard}:
13370 1.1 mrg Fortran 95 and later
13371 1.1 mrg
13372 1.1 mrg @item @emph{Class}:
13373 1.1 mrg Transformational function
13374 1.1 mrg
13375 1.1 mrg @item @emph{Syntax}:
13376 1.1 mrg @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
13377 1.1 mrg
13378 1.1 mrg @item @emph{Arguments}:
13379 1.1 mrg @multitable @columnfractions .15 .70
13380 1.1 mrg @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
13381 1.1 mrg a rank less than seven.
13382 1.1 mrg @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
13383 1.1 mrg value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
13384 1.1 mrg @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
13385 1.1 mrg @end multitable
13386 1.1 mrg
13387 1.1 mrg @item @emph{Return value}:
13388 1.1 mrg The result is an array of the same type as @var{SOURCE} and has rank n+1
13389 1.1 mrg where n equals the rank of @var{SOURCE}.
13390 1.1 mrg
13391 1.1 mrg @item @emph{Example}:
13392 1.1 mrg @smallexample
13393 1.1 mrg PROGRAM test_spread
13394 1.1 mrg INTEGER :: a = 1, b(2) = (/ 1, 2 /)
13395 1.1 mrg WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
13396 1.1 mrg WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
13397 1.1 mrg END PROGRAM
13398 1.1 mrg @end smallexample
13399 1.1 mrg
13400 1.1 mrg @item @emph{See also}:
13401 1.1 mrg @ref{UNPACK}
13402 1.1 mrg @end table
13403 1.1 mrg
13404 1.1 mrg
13405 1.1 mrg
13406 1.1 mrg @node SQRT
13407 1.1 mrg @section @code{SQRT} --- Square-root function
13408 1.1 mrg @fnindex SQRT
13409 1.1 mrg @fnindex DSQRT
13410 1.1 mrg @fnindex CSQRT
13411 1.1 mrg @fnindex ZSQRT
13412 1.1 mrg @fnindex CDSQRT
13413 1.1 mrg @cindex root
13414 1.1 mrg @cindex square-root
13415 1.1 mrg
13416 1.1 mrg @table @asis
13417 1.1 mrg @item @emph{Description}:
13418 1.1 mrg @code{SQRT(X)} computes the square root of @var{X}.
13419 1.1 mrg
13420 1.1 mrg @item @emph{Standard}:
13421 1.1 mrg Fortran 77 and later
13422 1.1 mrg
13423 1.1 mrg @item @emph{Class}:
13424 1.1 mrg Elemental function
13425 1.1 mrg
13426 1.1 mrg @item @emph{Syntax}:
13427 1.1 mrg @code{RESULT = SQRT(X)}
13428 1.1 mrg
13429 1.1 mrg @item @emph{Arguments}:
13430 1.1 mrg @multitable @columnfractions .15 .70
13431 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or
13432 1.1 mrg @code{COMPLEX}.
13433 1.1 mrg @end multitable
13434 1.1 mrg
13435 1.1 mrg @item @emph{Return value}:
13436 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}.
13437 1.1 mrg The kind type parameter is the same as @var{X}.
13438 1.1 mrg
13439 1.1 mrg @item @emph{Example}:
13440 1.1 mrg @smallexample
13441 1.1 mrg program test_sqrt
13442 1.1 mrg real(8) :: x = 2.0_8
13443 1.1 mrg complex :: z = (1.0, 2.0)
13444 1.1 mrg x = sqrt(x)
13445 1.1 mrg z = sqrt(z)
13446 1.1 mrg end program test_sqrt
13447 1.1 mrg @end smallexample
13448 1.1 mrg
13449 1.1 mrg @item @emph{Specific names}:
13450 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13451 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13452 1.1 mrg @item @code{SQRT(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13453 1.1 mrg @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13454 1.1 mrg @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 95 and later
13455 1.1 mrg @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13456 1.1 mrg @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13457 1.1 mrg @end multitable
13458 1.1 mrg @end table
13459 1.1 mrg
13460 1.1 mrg
13461 1.1 mrg
13462 1.1 mrg @node SRAND
13463 1.1 mrg @section @code{SRAND} --- Reinitialize the random number generator
13464 1.1 mrg @fnindex SRAND
13465 1.1 mrg @cindex random number generation, seeding
13466 1.1 mrg @cindex seeding a random number generator
13467 1.1 mrg
13468 1.1 mrg @table @asis
13469 1.1 mrg @item @emph{Description}:
13470 1.1 mrg @code{SRAND} reinitializes the pseudo-random number generator
13471 1.1 mrg called by @code{RAND} and @code{IRAND}. The new seed used by the
13472 1.1 mrg generator is specified by the required argument @var{SEED}.
13473 1.1 mrg
13474 1.1 mrg @item @emph{Standard}:
13475 1.1 mrg GNU extension
13476 1.1 mrg
13477 1.1 mrg @item @emph{Class}:
13478 1.1 mrg Subroutine
13479 1.1 mrg
13480 1.1 mrg @item @emph{Syntax}:
13481 1.1 mrg @code{CALL SRAND(SEED)}
13482 1.1 mrg
13483 1.1 mrg @item @emph{Arguments}:
13484 1.1 mrg @multitable @columnfractions .15 .70
13485 1.1 mrg @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
13486 1.1 mrg @end multitable
13487 1.1 mrg
13488 1.1 mrg @item @emph{Return value}:
13489 1.1 mrg Does not return anything.
13490 1.1 mrg
13491 1.1 mrg @item @emph{Example}:
13492 1.1 mrg See @code{RAND} and @code{IRAND} for examples.
13493 1.1 mrg
13494 1.1 mrg @item @emph{Notes}:
13495 1.1 mrg The Fortran standard specifies the intrinsic subroutines
13496 1.1 mrg @code{RANDOM_SEED} to initialize the pseudo-random number
13497 1.1 mrg generator and @code{RANDOM_NUMBER} to generate pseudo-random numbers.
13498 1.1 mrg These subroutines should be used in new codes.
13499 1.1 mrg
13500 1.1 mrg Please note that in GNU Fortran, these two sets of intrinsics (@code{RAND},
13501 1.1 mrg @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
13502 1.1 mrg @code{RANDOM_SEED} on the other hand) access two independent
13503 1.1 mrg pseudo-random number generators.
13504 1.1 mrg
13505 1.1 mrg @item @emph{See also}:
13506 1.1 mrg @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
13507 1.1 mrg
13508 1.1 mrg @end table
13509 1.1 mrg
13510 1.1 mrg
13511 1.1 mrg
13512 1.1 mrg @node STAT
13513 1.1 mrg @section @code{STAT} --- Get file status
13514 1.1 mrg @fnindex STAT
13515 1.1 mrg @cindex file system, file status
13516 1.1 mrg
13517 1.1 mrg @table @asis
13518 1.1 mrg @item @emph{Description}:
13519 1.1 mrg This function returns information about a file. No permissions are required on
13520 1.1 mrg the file itself, but execute (search) permission is required on all of the
13521 1.1 mrg directories in path that lead to the file.
13522 1.1 mrg
13523 1.1 mrg The elements that are obtained and stored in the array @code{VALUES}:
13524 1.1 mrg @multitable @columnfractions .15 .70
13525 1.1 mrg @item @code{VALUES(1)} @tab Device ID
13526 1.1 mrg @item @code{VALUES(2)} @tab Inode number
13527 1.1 mrg @item @code{VALUES(3)} @tab File mode
13528 1.1 mrg @item @code{VALUES(4)} @tab Number of links
13529 1.1 mrg @item @code{VALUES(5)} @tab Owner's uid
13530 1.1 mrg @item @code{VALUES(6)} @tab Owner's gid
13531 1.1 mrg @item @code{VALUES(7)} @tab ID of device containing directory entry for file (0 if not available)
13532 1.1 mrg @item @code{VALUES(8)} @tab File size (bytes)
13533 1.1 mrg @item @code{VALUES(9)} @tab Last access time
13534 1.1 mrg @item @code{VALUES(10)} @tab Last modification time
13535 1.1 mrg @item @code{VALUES(11)} @tab Last file status change time
13536 1.1 mrg @item @code{VALUES(12)} @tab Preferred I/O block size (-1 if not available)
13537 1.1 mrg @item @code{VALUES(13)} @tab Number of blocks allocated (-1 if not available)
13538 1.1 mrg @end multitable
13539 1.1 mrg
13540 1.1 mrg Not all these elements are relevant on all systems.
13541 1.1 mrg If an element is not relevant, it is returned as 0.
13542 1.1 mrg
13543 1.1 mrg This intrinsic is provided in both subroutine and function forms; however,
13544 1.1 mrg only one form can be used in any given program unit.
13545 1.1 mrg
13546 1.1 mrg @item @emph{Standard}:
13547 1.1 mrg GNU extension
13548 1.1 mrg
13549 1.1 mrg @item @emph{Class}:
13550 1.1 mrg Subroutine, function
13551 1.1 mrg
13552 1.1 mrg @item @emph{Syntax}:
13553 1.1 mrg @multitable @columnfractions .80
13554 1.1 mrg @item @code{CALL STAT(NAME, VALUES [, STATUS])}
13555 1.1 mrg @item @code{STATUS = STAT(NAME, VALUES)}
13556 1.1 mrg @end multitable
13557 1.1 mrg
13558 1.1 mrg @item @emph{Arguments}:
13559 1.1 mrg @multitable @columnfractions .15 .70
13560 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER}, of the
13561 1.1 mrg default kind and a valid path within the file system.
13562 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
13563 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
13564 1.1 mrg on success and a system specific error code otherwise.
13565 1.1 mrg @end multitable
13566 1.1 mrg
13567 1.1 mrg @item @emph{Example}:
13568 1.1 mrg @smallexample
13569 1.1 mrg PROGRAM test_stat
13570 1.1 mrg INTEGER, DIMENSION(13) :: buff
13571 1.1 mrg INTEGER :: status
13572 1.1 mrg
13573 1.1 mrg CALL STAT("/etc/passwd", buff, status)
13574 1.1 mrg
13575 1.1 mrg IF (status == 0) THEN
13576 1.1 mrg WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
13577 1.1 mrg WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
13578 1.1 mrg WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
13579 1.1 mrg WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
13580 1.1 mrg WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
13581 1.1 mrg WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
13582 1.1 mrg WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
13583 1.1 mrg WRITE (*, FMT="('File size:', T30, I19)") buff(8)
13584 1.1 mrg WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
13585 1.1 mrg WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
13586 1.1 mrg WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
13587 1.1 mrg WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
13588 1.1 mrg WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
13589 1.1 mrg END IF
13590 1.1 mrg END PROGRAM
13591 1.1 mrg @end smallexample
13592 1.1 mrg
13593 1.1 mrg @item @emph{See also}:
13594 1.1 mrg To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
13595 1.1 mrg @end table
13596 1.1 mrg
13597 1.1 mrg
13598 1.1 mrg
13599 1.1 mrg @node STORAGE_SIZE
13600 1.1 mrg @section @code{STORAGE_SIZE} --- Storage size in bits
13601 1.1 mrg @fnindex STORAGE_SIZE
13602 1.1 mrg @cindex storage size
13603 1.1 mrg
13604 1.1 mrg @table @asis
13605 1.1 mrg @item @emph{Description}:
13606 1.1 mrg Returns the storage size of argument @var{A} in bits.
13607 1.1 mrg @item @emph{Standard}:
13608 1.1 mrg Fortran 2008 and later
13609 1.1 mrg @item @emph{Class}:
13610 1.1 mrg Inquiry function
13611 1.1 mrg @item @emph{Syntax}:
13612 1.1 mrg @code{RESULT = STORAGE_SIZE(A [, KIND])}
13613 1.1 mrg
13614 1.1 mrg @item @emph{Arguments}:
13615 1.1 mrg @multitable @columnfractions .15 .70
13616 1.1 mrg @item @var{A} @tab Shall be a scalar or array of any type.
13617 1.1 mrg @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
13618 1.1 mrg @end multitable
13619 1.1 mrg
13620 1.1 mrg @item @emph{Return Value}:
13621 1.1 mrg The result is a scalar integer with the kind type parameter specified by KIND
13622 1.1 mrg (or default integer type if KIND is missing). The result value is the size
13623 1.1 mrg expressed in bits for an element of an array that has the dynamic type and type
13624 1.1 mrg parameters of A.
13625 1.1 mrg
13626 1.1 mrg @item @emph{See also}:
13627 1.1 mrg @ref{C_SIZEOF}, @ref{SIZEOF}
13628 1.1 mrg @end table
13629 1.1 mrg
13630 1.1 mrg
13631 1.1 mrg
13632 1.1 mrg @node SUM
13633 1.1 mrg @section @code{SUM} --- Sum of array elements
13634 1.1 mrg @fnindex SUM
13635 1.1 mrg @cindex array, sum
13636 1.1 mrg @cindex array, add elements
13637 1.1 mrg @cindex array, conditionally add elements
13638 1.1 mrg @cindex sum array elements
13639 1.1 mrg
13640 1.1 mrg @table @asis
13641 1.1 mrg @item @emph{Description}:
13642 1.1 mrg Adds the elements of @var{ARRAY} along dimension @var{DIM} if
13643 1.1 mrg the corresponding element in @var{MASK} is @code{TRUE}.
13644 1.1 mrg
13645 1.1 mrg @item @emph{Standard}:
13646 1.1 mrg Fortran 95 and later
13647 1.1 mrg
13648 1.1 mrg @item @emph{Class}:
13649 1.1 mrg Transformational function
13650 1.1 mrg
13651 1.1 mrg @item @emph{Syntax}:
13652 1.1 mrg @multitable @columnfractions .80
13653 1.1 mrg @item @code{RESULT = SUM(ARRAY[, MASK])}
13654 1.1 mrg @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
13655 1.1 mrg @end multitable
13656 1.1 mrg
13657 1.1 mrg @item @emph{Arguments}:
13658 1.1 mrg @multitable @columnfractions .15 .70
13659 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
13660 1.1 mrg @code{REAL} or @code{COMPLEX}.
13661 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type
13662 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n
13663 1.1 mrg equals the rank of @var{ARRAY}.
13664 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
13665 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}.
13666 1.1 mrg @end multitable
13667 1.1 mrg
13668 1.1 mrg @item @emph{Return value}:
13669 1.1 mrg The result is of the same type as @var{ARRAY}.
13670 1.1 mrg
13671 1.1 mrg If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
13672 1.1 mrg is returned. Otherwise, an array of rank n-1, where n equals the rank of
13673 1.1 mrg @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
13674 1.1 mrg dropped is returned.
13675 1.1 mrg
13676 1.1 mrg @item @emph{Example}:
13677 1.1 mrg @smallexample
13678 1.1 mrg PROGRAM test_sum
13679 1.1 mrg INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
13680 1.1 mrg print *, SUM(x) ! all elements, sum = 15
13681 1.1 mrg print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
13682 1.1 mrg END PROGRAM
13683 1.1 mrg @end smallexample
13684 1.1 mrg
13685 1.1 mrg @item @emph{See also}:
13686 1.1 mrg @ref{PRODUCT}
13687 1.1 mrg @end table
13688 1.1 mrg
13689 1.1 mrg
13690 1.1 mrg
13691 1.1 mrg @node SYMLNK
13692 1.1 mrg @section @code{SYMLNK} --- Create a symbolic link
13693 1.1 mrg @fnindex SYMLNK
13694 1.1 mrg @cindex file system, create link
13695 1.1 mrg @cindex file system, soft link
13696 1.1 mrg
13697 1.1 mrg @table @asis
13698 1.1 mrg @item @emph{Description}:
13699 1.1 mrg Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
13700 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in
13701 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
13702 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it
13703 1.1 mrg contains 0 on success or a nonzero error code upon return; see
13704 1.1 mrg @code{symlink(2)}. If the system does not supply @code{symlink(2)},
13705 1.1 mrg @code{ENOSYS} is returned.
13706 1.1 mrg
13707 1.1 mrg This intrinsic is provided in both subroutine and function forms;
13708 1.1 mrg however, only one form can be used in any given program unit.
13709 1.1 mrg
13710 1.1 mrg @item @emph{Standard}:
13711 1.1 mrg GNU extension
13712 1.1 mrg
13713 1.1 mrg @item @emph{Class}:
13714 1.1 mrg Subroutine, function
13715 1.1 mrg
13716 1.1 mrg @item @emph{Syntax}:
13717 1.1 mrg @multitable @columnfractions .80
13718 1.1 mrg @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
13719 1.1 mrg @item @code{STATUS = SYMLNK(PATH1, PATH2)}
13720 1.1 mrg @end multitable
13721 1.1 mrg
13722 1.1 mrg @item @emph{Arguments}:
13723 1.1 mrg @multitable @columnfractions .15 .70
13724 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
13725 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
13726 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13727 1.1 mrg @end multitable
13728 1.1 mrg
13729 1.1 mrg @item @emph{See also}:
13730 1.1 mrg @ref{LINK}, @ref{UNLINK}
13731 1.1 mrg
13732 1.1 mrg @end table
13733 1.1 mrg
13734 1.1 mrg
13735 1.1 mrg
13736 1.1 mrg @node SYSTEM
13737 1.1 mrg @section @code{SYSTEM} --- Execute a shell command
13738 1.1 mrg @fnindex SYSTEM
13739 1.1 mrg @cindex system, system call
13740 1.1 mrg
13741 1.1 mrg @table @asis
13742 1.1 mrg @item @emph{Description}:
13743 1.1 mrg Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
13744 1.1 mrg argument @var{STATUS} is present, it contains the value returned by
13745 1.1 mrg @code{system(3)}, which is presumably 0 if the shell command succeeded.
13746 1.1 mrg Note that which shell is used to invoke the command is system-dependent
13747 1.1 mrg and environment-dependent.
13748 1.1 mrg
13749 1.1 mrg This intrinsic is provided in both subroutine and function forms;
13750 1.1 mrg however, only one form can be used in any given program unit.
13751 1.1 mrg
13752 1.1 mrg Note that the @code{system} function need not be thread-safe. It is
13753 1.1 mrg the responsibility of the user to ensure that @code{system} is not
13754 1.1 mrg called concurrently.
13755 1.1 mrg
13756 1.1 mrg @item @emph{Standard}:
13757 1.1 mrg GNU extension
13758 1.1 mrg
13759 1.1 mrg @item @emph{Class}:
13760 1.1 mrg Subroutine, function
13761 1.1 mrg
13762 1.1 mrg @item @emph{Syntax}:
13763 1.1 mrg @multitable @columnfractions .80
13764 1.1 mrg @item @code{CALL SYSTEM(COMMAND [, STATUS])}
13765 1.1 mrg @item @code{STATUS = SYSTEM(COMMAND)}
13766 1.1 mrg @end multitable
13767 1.1 mrg
13768 1.1 mrg @item @emph{Arguments}:
13769 1.1 mrg @multitable @columnfractions .15 .70
13770 1.1 mrg @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
13771 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13772 1.1 mrg @end multitable
13773 1.1 mrg
13774 1.1 mrg @item @emph{See also}:
13775 1.1 mrg @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
13776 1.1 mrg and should considered in new code for future portability.
13777 1.1 mrg @end table
13778 1.1 mrg
13779 1.1 mrg
13780 1.1 mrg
13781 1.1 mrg @node SYSTEM_CLOCK
13782 1.1 mrg @section @code{SYSTEM_CLOCK} --- Time function
13783 1.1 mrg @fnindex SYSTEM_CLOCK
13784 1.1 mrg @cindex time, clock ticks
13785 1.1 mrg @cindex clock ticks
13786 1.1 mrg
13787 1.1 mrg @table @asis
13788 1.1 mrg @item @emph{Description}:
13789 1.1 mrg Determines the @var{COUNT} of a processor clock since an unspecified
13790 1.1 mrg time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
13791 1.1 mrg the number of clock ticks per second. If the platform supports a
13792 1.1 mrg monotonic clock, that clock is used and can, depending on the platform
13793 1.1 mrg clock implementation, provide up to nanosecond resolution. If a
13794 1.1 mrg monotonic clock is not available, the implementation falls back to a
13795 1.1 mrg realtime clock.
13796 1.1 mrg
13797 1.1 mrg @var{COUNT_RATE} is system dependent and can vary depending on the kind of
13798 1.1 mrg the arguments. For @var{kind=4} arguments (and smaller integer kinds),
13799 1.1 mrg @var{COUNT} represents milliseconds, while for @var{kind=8} arguments (and
13800 1.1 mrg larger integer kinds), @var{COUNT} typically represents micro- or
13801 1.1 mrg nanoseconds depending on resolution of the underlying platform clock.
13802 1.1 mrg @var{COUNT_MAX} usually equals @code{HUGE(COUNT_MAX)}. Note that the
13803 1.1 mrg millisecond resolution of the @var{kind=4} version implies that the
13804 1.1 mrg @var{COUNT} will wrap around in roughly 25 days. In order to avoid issues
13805 1.1 mrg with the wrap around and for more precise timing, please use the
13806 1.1 mrg @var{kind=8} version.
13807 1.1 mrg
13808 1.1 mrg If there is no clock, or querying the clock fails, @var{COUNT} is set
13809 1.1 mrg to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are
13810 1.1 mrg set to zero.
13811 1.1 mrg
13812 1.1 mrg When running on a platform using the GNU C library (glibc) version
13813 1.1 mrg 2.16 or older, or a derivative thereof, the high resolution monotonic
13814 1.1 mrg clock is available only when linking with the @var{rt} library. This
13815 1.1 mrg can be done explicitly by adding the @code{-lrt} flag when linking the
13816 1.1 mrg application, but is also done implicitly when using OpenMP.
13817 1.1 mrg
13818 1.1 mrg On the Windows platform, the version with @var{kind=4} arguments uses
13819 1.1 mrg the @code{GetTickCount} function, whereas the @var{kind=8} version
13820 1.1 mrg uses @code{QueryPerformanceCounter} and
13821 1.1 mrg @code{QueryPerformanceCounterFrequency}. For more information, and
13822 1.1 mrg potential caveats, please see the platform documentation.
13823 1.1 mrg
13824 1.1 mrg @item @emph{Standard}:
13825 1.1 mrg Fortran 95 and later
13826 1.1 mrg
13827 1.1 mrg @item @emph{Class}:
13828 1.1 mrg Subroutine
13829 1.1 mrg
13830 1.1 mrg @item @emph{Syntax}:
13831 1.1 mrg @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
13832 1.1 mrg
13833 1.1 mrg @item @emph{Arguments}:
13834 1.1 mrg @multitable @columnfractions .15 .70
13835 1.1 mrg @item @var{COUNT} @tab (Optional) shall be a scalar of type
13836 1.1 mrg @code{INTEGER} with @code{INTENT(OUT)}.
13837 1.1 mrg @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type
13838 1.1 mrg @code{INTEGER} or @code{REAL}, with @code{INTENT(OUT)}.
13839 1.1 mrg @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type
13840 1.1 mrg @code{INTEGER} with @code{INTENT(OUT)}.
13841 1.1 mrg @end multitable
13842 1.1 mrg
13843 1.1 mrg @item @emph{Example}:
13844 1.1 mrg @smallexample
13845 1.1 mrg PROGRAM test_system_clock
13846 1.1 mrg INTEGER :: count, count_rate, count_max
13847 1.1 mrg CALL SYSTEM_CLOCK(count, count_rate, count_max)
13848 1.1 mrg WRITE(*,*) count, count_rate, count_max
13849 1.1 mrg END PROGRAM
13850 1.1 mrg @end smallexample
13851 1.1 mrg
13852 1.1 mrg @item @emph{See also}:
13853 1.1 mrg @ref{DATE_AND_TIME}, @ref{CPU_TIME}
13854 1.1 mrg @end table
13855 1.1 mrg
13856 1.1 mrg
13857 1.1 mrg
13858 1.1 mrg @node TAN
13859 1.1 mrg @section @code{TAN} --- Tangent function
13860 1.1 mrg @fnindex TAN
13861 1.1 mrg @fnindex DTAN
13862 1.1 mrg @cindex trigonometric function, tangent
13863 1.1 mrg @cindex tangent
13864 1.1 mrg
13865 1.1 mrg @table @asis
13866 1.1 mrg @item @emph{Description}:
13867 1.1 mrg @code{TAN(X)} computes the tangent of @var{X}.
13868 1.1 mrg
13869 1.1 mrg @item @emph{Standard}:
13870 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
13871 1.1 mrg
13872 1.1 mrg @item @emph{Class}:
13873 1.1 mrg Elemental function
13874 1.1 mrg
13875 1.1 mrg @item @emph{Syntax}:
13876 1.1 mrg @code{RESULT = TAN(X)}
13877 1.1 mrg
13878 1.1 mrg @item @emph{Arguments}:
13879 1.1 mrg @multitable @columnfractions .15 .70
13880 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13881 1.1 mrg @end multitable
13882 1.1 mrg
13883 1.1 mrg @item @emph{Return value}:
13884 1.1 mrg The return value has same type and kind as @var{X}, and its value is in radians.
13885 1.1 mrg
13886 1.1 mrg @item @emph{Example}:
13887 1.1 mrg @smallexample
13888 1.1 mrg program test_tan
13889 1.1 mrg real(8) :: x = 0.165_8
13890 1.1 mrg x = tan(x)
13891 1.1 mrg end program test_tan
13892 1.1 mrg @end smallexample
13893 1.1 mrg
13894 1.1 mrg @item @emph{Specific names}:
13895 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13896 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13897 1.1 mrg @item @code{TAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13898 1.1 mrg @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13899 1.1 mrg @end multitable
13900 1.1 mrg
13901 1.1 mrg @item @emph{See also}:
13902 1.1 mrg Inverse function: @ref{ATAN}
13903 1.1 mrg Degrees function: @ref{TAND}
13904 1.1 mrg @end table
13905 1.1 mrg
13906 1.1 mrg
13907 1.1 mrg
13908 1.1 mrg @node TAND
13909 1.1 mrg @section @code{TAND} --- Tangent function, degrees
13910 1.1 mrg @fnindex TAND
13911 1.1 mrg @fnindex DTAND
13912 1.1 mrg @cindex trigonometric function, tangent, degrees
13913 1.1 mrg @cindex tangent, degrees
13914 1.1 mrg
13915 1.1 mrg @table @asis
13916 1.1 mrg @item @emph{Description}:
13917 1.1 mrg @code{TAND(X)} computes the tangent of @var{X} in degrees.
13918 1.1 mrg
13919 1.1 mrg This function is for compatibility only and should be avoided in favor of
13920 1.1 mrg standard constructs wherever possible.
13921 1.1 mrg
13922 1.1 mrg @item @emph{Standard}:
13923 1.1 mrg GNU Extension, enabled with @option{-fdec-math}.
13924 1.1 mrg
13925 1.1 mrg @item @emph{Class}:
13926 1.1 mrg Elemental function
13927 1.1 mrg
13928 1.1 mrg @item @emph{Syntax}:
13929 1.1 mrg @code{RESULT = TAND(X)}
13930 1.1 mrg
13931 1.1 mrg @item @emph{Arguments}:
13932 1.1 mrg @multitable @columnfractions .15 .70
13933 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13934 1.1 mrg @end multitable
13935 1.1 mrg
13936 1.1 mrg @item @emph{Return value}:
13937 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees.
13938 1.1 mrg
13939 1.1 mrg @item @emph{Example}:
13940 1.1 mrg @smallexample
13941 1.1 mrg program test_tand
13942 1.1 mrg real(8) :: x = 0.165_8
13943 1.1 mrg x = tand(x)
13944 1.1 mrg end program test_tand
13945 1.1 mrg @end smallexample
13946 1.1 mrg
13947 1.1 mrg @item @emph{Specific names}:
13948 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
13949 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
13950 1.1 mrg @item @code{TAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
13951 1.1 mrg @item @code{DTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
13952 1.1 mrg @end multitable
13953 1.1 mrg
13954 1.1 mrg @item @emph{See also}:
13955 1.1 mrg Inverse function: @ref{ATAND}
13956 1.1 mrg Radians function: @ref{TAN}
13957 1.1 mrg @end table
13958 1.1 mrg
13959 1.1 mrg
13960 1.1 mrg
13961 1.1 mrg @node TANH
13962 1.1 mrg @section @code{TANH} --- Hyperbolic tangent function
13963 1.1 mrg @fnindex TANH
13964 1.1 mrg @fnindex DTANH
13965 1.1 mrg @cindex hyperbolic tangent
13966 1.1 mrg @cindex hyperbolic function, tangent
13967 1.1 mrg @cindex tangent, hyperbolic
13968 1.1 mrg
13969 1.1 mrg @table @asis
13970 1.1 mrg @item @emph{Description}:
13971 1.1 mrg @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
13972 1.1 mrg
13973 1.1 mrg @item @emph{Standard}:
13974 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later
13975 1.1 mrg
13976 1.1 mrg @item @emph{Class}:
13977 1.1 mrg Elemental function
13978 1.1 mrg
13979 1.1 mrg @item @emph{Syntax}:
13980 1.1 mrg @code{X = TANH(X)}
13981 1.1 mrg
13982 1.1 mrg @item @emph{Arguments}:
13983 1.1 mrg @multitable @columnfractions .15 .70
13984 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13985 1.1 mrg @end multitable
13986 1.1 mrg
13987 1.1 mrg @item @emph{Return value}:
13988 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is
13989 1.1 mrg complex, the imaginary part of the result is in radians. If @var{X}
13990 1.1 mrg is @code{REAL}, the return value lies in the range
13991 1.1 mrg @math{ - 1 \leq tanh(x) \leq 1 }.
13992 1.1 mrg
13993 1.1 mrg @item @emph{Example}:
13994 1.1 mrg @smallexample
13995 1.1 mrg program test_tanh
13996 1.1 mrg real(8) :: x = 2.1_8
13997 1.1 mrg x = tanh(x)
13998 1.1 mrg end program test_tanh
13999 1.1 mrg @end smallexample
14000 1.1 mrg
14001 1.1 mrg @item @emph{Specific names}:
14002 1.1 mrg @multitable @columnfractions .20 .20 .20 .25
14003 1.1 mrg @item Name @tab Argument @tab Return type @tab Standard
14004 1.1 mrg @item @code{TANH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
14005 1.1 mrg @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
14006 1.1 mrg @end multitable
14007 1.1 mrg
14008 1.1 mrg @item @emph{See also}:
14009 1.1 mrg @ref{ATANH}
14010 1.1 mrg @end table
14011 1.1 mrg
14012 1.1 mrg
14013 1.1 mrg
14014 1.1 mrg @node THIS_IMAGE
14015 1.1 mrg @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
14016 1.1 mrg @fnindex THIS_IMAGE
14017 1.1 mrg @cindex coarray, @code{THIS_IMAGE}
14018 1.1 mrg @cindex images, index of this image
14019 1.1 mrg
14020 1.1 mrg @table @asis
14021 1.1 mrg @item @emph{Description}:
14022 1.1 mrg Returns the cosubscript for this image.
14023 1.1 mrg
14024 1.1 mrg @item @emph{Standard}:
14025 1.1 mrg Fortran 2008 and later. With @var{DISTANCE} argument,
14026 1.1 mrg Technical Specification (TS) 18508 or later
14027 1.1 mrg
14028 1.1 mrg @item @emph{Class}:
14029 1.1 mrg Transformational function
14030 1.1 mrg
14031 1.1 mrg @item @emph{Syntax}:
14032 1.1 mrg @multitable @columnfractions .80
14033 1.1 mrg @item @code{RESULT = THIS_IMAGE()}
14034 1.1 mrg @item @code{RESULT = THIS_IMAGE(DISTANCE)}
14035 1.1 mrg @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
14036 1.1 mrg @end multitable
14037 1.1 mrg
14038 1.1 mrg @item @emph{Arguments}:
14039 1.1 mrg @multitable @columnfractions .15 .70
14040 1.1 mrg @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
14041 1.1 mrg (not permitted together with @var{COARRAY}).
14042 1.1 mrg @item @var{COARRAY} @tab Coarray of any type (optional; if @var{DIM}
14043 1.1 mrg present, required).
14044 1.1 mrg @item @var{DIM} @tab default integer scalar (optional). If present,
14045 1.1 mrg @var{DIM} shall be between one and the corank of @var{COARRAY}.
14046 1.1 mrg @end multitable
14047 1.1 mrg
14048 1.1 mrg
14049 1.1 mrg @item @emph{Return value}:
14050 1.1 mrg Default integer. If @var{COARRAY} is not present, it is scalar; if
14051 1.1 mrg @var{DISTANCE} is not present or has value 0, its value is the image index on
14052 1.1 mrg the invoking image for the current team, for values smaller or equal
14053 1.1 mrg distance to the initial team, it returns the image index on the ancestor team
14054 1.1 mrg which has a distance of @var{DISTANCE} from the invoking team. If
14055 1.1 mrg @var{DISTANCE} is larger than the distance to the initial team, the image
14056 1.1 mrg index of the initial team is returned. Otherwise when the @var{COARRAY} is
14057 1.1 mrg present, if @var{DIM} is not present, a rank-1 array with corank elements is
14058 1.1 mrg returned, containing the cosubscripts for @var{COARRAY} specifying the invoking
14059 1.1 mrg image. If @var{DIM} is present, a scalar is returned, with the value of
14060 1.1 mrg the @var{DIM} element of @code{THIS_IMAGE(COARRAY)}.
14061 1.1 mrg
14062 1.1 mrg @item @emph{Example}:
14063 1.1 mrg @smallexample
14064 1.1 mrg INTEGER :: value[*]
14065 1.1 mrg INTEGER :: i
14066 1.1 mrg value = THIS_IMAGE()
14067 1.1 mrg SYNC ALL
14068 1.1 mrg IF (THIS_IMAGE() == 1) THEN
14069 1.1 mrg DO i = 1, NUM_IMAGES()
14070 1.1 mrg WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
14071 1.1 mrg END DO
14072 1.1 mrg END IF
14073 1.1 mrg
14074 1.1 mrg ! Check whether the current image is the initial image
14075 1.1 mrg IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE())
14076 1.1 mrg error stop "something is rotten here"
14077 1.1 mrg @end smallexample
14078 1.1 mrg
14079 1.1 mrg @item @emph{See also}:
14080 1.1 mrg @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
14081 1.1 mrg @end table
14082 1.1 mrg
14083 1.1 mrg
14084 1.1 mrg
14085 1.1 mrg @node TIME
14086 1.1 mrg @section @code{TIME} --- Time function
14087 1.1 mrg @fnindex TIME
14088 1.1 mrg @cindex time, current
14089 1.1 mrg @cindex current time
14090 1.1 mrg
14091 1.1 mrg @table @asis
14092 1.1 mrg @item @emph{Description}:
14093 1.1 mrg Returns the current time encoded as an integer (in the manner of the
14094 1.1 mrg function @code{time(3)} in the C standard library). This value is
14095 1.1 mrg suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
14096 1.1 mrg
14097 1.1 mrg This intrinsic is not fully portable, such as to systems with 32-bit
14098 1.1 mrg @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
14099 1.1 mrg the values returned by this intrinsic might be, or become, negative, or
14100 1.1 mrg numerically less than previous values, during a single run of the
14101 1.1 mrg compiled program.
14102 1.1 mrg
14103 1.1 mrg See @ref{TIME8}, for information on a similar intrinsic that might be
14104 1.1 mrg portable to more GNU Fortran implementations, though to fewer Fortran
14105 1.1 mrg compilers.
14106 1.1 mrg
14107 1.1 mrg @item @emph{Standard}:
14108 1.1 mrg GNU extension
14109 1.1 mrg
14110 1.1 mrg @item @emph{Class}:
14111 1.1 mrg Function
14112 1.1 mrg
14113 1.1 mrg @item @emph{Syntax}:
14114 1.1 mrg @code{RESULT = TIME()}
14115 1.1 mrg
14116 1.1 mrg @item @emph{Return value}:
14117 1.1 mrg The return value is a scalar of type @code{INTEGER(4)}.
14118 1.1 mrg
14119 1.1 mrg @item @emph{See also}:
14120 1.1 mrg @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
14121 1.1 mrg
14122 1.1 mrg @end table
14123 1.1 mrg
14124 1.1 mrg
14125 1.1 mrg
14126 1.1 mrg @node TIME8
14127 1.1 mrg @section @code{TIME8} --- Time function (64-bit)
14128 1.1 mrg @fnindex TIME8
14129 1.1 mrg @cindex time, current
14130 1.1 mrg @cindex current time
14131 1.1 mrg
14132 1.1 mrg @table @asis
14133 1.1 mrg @item @emph{Description}:
14134 1.1 mrg Returns the current time encoded as an integer (in the manner of the
14135 1.1 mrg function @code{time(3)} in the C standard library). This value is
14136 1.1 mrg suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
14137 1.1 mrg
14138 1.1 mrg @emph{Warning:} this intrinsic does not increase the range of the timing
14139 1.1 mrg values over that returned by @code{time(3)}. On a system with a 32-bit
14140 1.1 mrg @code{time(3)}, @code{TIME8} will return a 32-bit value, even though
14141 1.1 mrg it is converted to a 64-bit @code{INTEGER(8)} value. That means
14142 1.1 mrg overflows of the 32-bit value can still occur. Therefore, the values
14143 1.1 mrg returned by this intrinsic might be or become negative or numerically
14144 1.1 mrg less than previous values during a single run of the compiled program.
14145 1.1 mrg
14146 1.1 mrg @item @emph{Standard}:
14147 1.1 mrg GNU extension
14148 1.1 mrg
14149 1.1 mrg @item @emph{Class}:
14150 1.1 mrg Function
14151 1.1 mrg
14152 1.1 mrg @item @emph{Syntax}:
14153 1.1 mrg @code{RESULT = TIME8()}
14154 1.1 mrg
14155 1.1 mrg @item @emph{Return value}:
14156 1.1 mrg The return value is a scalar of type @code{INTEGER(8)}.
14157 1.1 mrg
14158 1.1 mrg @item @emph{See also}:
14159 1.1 mrg @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
14160 1.1 mrg
14161 1.1 mrg @end table
14162 1.1 mrg
14163 1.1 mrg
14164 1.1 mrg
14165 1.1 mrg @node TINY
14166 1.1 mrg @section @code{TINY} --- Smallest positive number of a real kind
14167 1.1 mrg @fnindex TINY
14168 1.1 mrg @cindex limits, smallest number
14169 1.1 mrg @cindex model representation, smallest number
14170 1.1 mrg
14171 1.1 mrg @table @asis
14172 1.1 mrg @item @emph{Description}:
14173 1.1 mrg @code{TINY(X)} returns the smallest positive (non zero) number
14174 1.1 mrg in the model of the type of @code{X}.
14175 1.1 mrg
14176 1.1 mrg @item @emph{Standard}:
14177 1.1 mrg Fortran 95 and later
14178 1.1 mrg
14179 1.1 mrg @item @emph{Class}:
14180 1.1 mrg Inquiry function
14181 1.1 mrg
14182 1.1 mrg @item @emph{Syntax}:
14183 1.1 mrg @code{RESULT = TINY(X)}
14184 1.1 mrg
14185 1.1 mrg @item @emph{Arguments}:
14186 1.1 mrg @multitable @columnfractions .15 .70
14187 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}.
14188 1.1 mrg @end multitable
14189 1.1 mrg
14190 1.1 mrg @item @emph{Return value}:
14191 1.1 mrg The return value is of the same type and kind as @var{X}
14192 1.1 mrg
14193 1.1 mrg @item @emph{Example}:
14194 1.1 mrg See @code{HUGE} for an example.
14195 1.1 mrg @end table
14196 1.1 mrg
14197 1.1 mrg
14198 1.1 mrg
14199 1.1 mrg @node TRAILZ
14200 1.1 mrg @section @code{TRAILZ} --- Number of trailing zero bits of an integer
14201 1.1 mrg @fnindex TRAILZ
14202 1.1 mrg @cindex zero bits
14203 1.1 mrg
14204 1.1 mrg @table @asis
14205 1.1 mrg @item @emph{Description}:
14206 1.1 mrg @code{TRAILZ} returns the number of trailing zero bits of an integer.
14207 1.1 mrg
14208 1.1 mrg @item @emph{Standard}:
14209 1.1 mrg Fortran 2008 and later
14210 1.1 mrg
14211 1.1 mrg @item @emph{Class}:
14212 1.1 mrg Elemental function
14213 1.1 mrg
14214 1.1 mrg @item @emph{Syntax}:
14215 1.1 mrg @code{RESULT = TRAILZ(I)}
14216 1.1 mrg
14217 1.1 mrg @item @emph{Arguments}:
14218 1.1 mrg @multitable @columnfractions .15 .70
14219 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}.
14220 1.1 mrg @end multitable
14221 1.1 mrg
14222 1.1 mrg @item @emph{Return value}:
14223 1.1 mrg The type of the return value is the default @code{INTEGER}.
14224 1.1 mrg If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
14225 1.1 mrg
14226 1.1 mrg @item @emph{Example}:
14227 1.1 mrg @smallexample
14228 1.1 mrg PROGRAM test_trailz
14229 1.1 mrg WRITE (*,*) TRAILZ(8) ! prints 3
14230 1.1 mrg END PROGRAM
14231 1.1 mrg @end smallexample
14232 1.1 mrg
14233 1.1 mrg @item @emph{See also}:
14234 1.1 mrg @ref{BIT_SIZE}, @ref{LEADZ}, @ref{POPPAR}, @ref{POPCNT}
14235 1.1 mrg @end table
14236 1.1 mrg
14237 1.1 mrg
14238 1.1 mrg
14239 1.1 mrg @node TRANSFER
14240 1.1 mrg @section @code{TRANSFER} --- Transfer bit patterns
14241 1.1 mrg @fnindex TRANSFER
14242 1.1 mrg @cindex bits, move
14243 1.1 mrg @cindex type cast
14244 1.1 mrg
14245 1.1 mrg @table @asis
14246 1.1 mrg @item @emph{Description}:
14247 1.1 mrg Interprets the bitwise representation of @var{SOURCE} in memory as if it
14248 1.1 mrg is the representation of a variable or array of the same type and type
14249 1.1 mrg parameters as @var{MOLD}.
14250 1.1 mrg
14251 1.1 mrg This is approximately equivalent to the C concept of @emph{casting} one
14252 1.1 mrg type to another.
14253 1.1 mrg
14254 1.1 mrg @item @emph{Standard}:
14255 1.1 mrg Fortran 95 and later
14256 1.1 mrg
14257 1.1 mrg @item @emph{Class}:
14258 1.1 mrg Transformational function
14259 1.1 mrg
14260 1.1 mrg @item @emph{Syntax}:
14261 1.1 mrg @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
14262 1.1 mrg
14263 1.1 mrg @item @emph{Arguments}:
14264 1.1 mrg @multitable @columnfractions .15 .70
14265 1.1 mrg @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
14266 1.1 mrg @item @var{MOLD} @tab Shall be a scalar or an array of any type.
14267 1.1 mrg @item @var{SIZE} @tab (Optional) shall be a scalar of type
14268 1.1 mrg @code{INTEGER}.
14269 1.1 mrg @end multitable
14270 1.1 mrg
14271 1.1 mrg @item @emph{Return value}:
14272 1.1 mrg The result has the same type as @var{MOLD}, with the bit level
14273 1.1 mrg representation of @var{SOURCE}. If @var{SIZE} is present, the result is
14274 1.1 mrg a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
14275 1.1 mrg but @var{MOLD} is an array (of any size or shape), the result is a one-
14276 1.1 mrg dimensional array of the minimum length needed to contain the entirety
14277 1.1 mrg of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
14278 1.1 mrg and @var{MOLD} is a scalar, the result is a scalar.
14279 1.1 mrg
14280 1.1 mrg If the bitwise representation of the result is longer than that of
14281 1.1 mrg @var{SOURCE}, then the leading bits of the result correspond to those of
14282 1.1 mrg @var{SOURCE} and any trailing bits are filled arbitrarily.
14283 1.1 mrg
14284 1.1 mrg When the resulting bit representation does not correspond to a valid
14285 1.1 mrg representation of a variable of the same type as @var{MOLD}, the results
14286 1.1 mrg are undefined, and subsequent operations on the result cannot be
14287 1.1 mrg guaranteed to produce sensible behavior. For example, it is possible to
14288 1.1 mrg create @code{LOGICAL} variables for which @code{@var{VAR}} and
14289 1.1 mrg @code{.NOT.@var{VAR}} both appear to be true.
14290 1.1 mrg
14291 1.1 mrg @item @emph{Example}:
14292 1.1 mrg @smallexample
14293 1.1 mrg PROGRAM test_transfer
14294 1.1 mrg integer :: x = 2143289344
14295 1.1 mrg print *, transfer(x, 1.0) ! prints "NaN" on i686
14296 1.1 mrg END PROGRAM
14297 1.1 mrg @end smallexample
14298 1.1 mrg @end table
14299 1.1 mrg
14300 1.1 mrg
14301 1.1 mrg
14302 1.1 mrg @node TRANSPOSE
14303 1.1 mrg @section @code{TRANSPOSE} --- Transpose an array of rank two
14304 1.1 mrg @fnindex TRANSPOSE
14305 1.1 mrg @cindex array, transpose
14306 1.1 mrg @cindex matrix, transpose
14307 1.1 mrg @cindex transpose
14308 1.1 mrg
14309 1.1 mrg @table @asis
14310 1.1 mrg @item @emph{Description}:
14311 1.1 mrg Transpose an array of rank two. Element (i, j) of the result has the value
14312 1.1 mrg @code{MATRIX(j, i)}, for all i, j.
14313 1.1 mrg
14314 1.1 mrg @item @emph{Standard}:
14315 1.1 mrg Fortran 95 and later
14316 1.1 mrg
14317 1.1 mrg @item @emph{Class}:
14318 1.1 mrg Transformational function
14319 1.1 mrg
14320 1.1 mrg @item @emph{Syntax}:
14321 1.1 mrg @code{RESULT = TRANSPOSE(MATRIX)}
14322 1.1 mrg
14323 1.1 mrg @item @emph{Arguments}:
14324 1.1 mrg @multitable @columnfractions .15 .70
14325 1.1 mrg @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
14326 1.1 mrg @end multitable
14327 1.1 mrg
14328 1.1 mrg @item @emph{Return value}:
14329 1.1 mrg The result has the same type as @var{MATRIX}, and has shape
14330 1.1 mrg @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
14331 1.1 mrg @end table
14332 1.1 mrg
14333 1.1 mrg
14334 1.1 mrg
14335 1.1 mrg @node TRIM
14336 1.1 mrg @section @code{TRIM} --- Remove trailing blank characters of a string
14337 1.1 mrg @fnindex TRIM
14338 1.1 mrg @cindex string, remove trailing whitespace
14339 1.1 mrg
14340 1.1 mrg @table @asis
14341 1.1 mrg @item @emph{Description}:
14342 1.1 mrg Removes trailing blank characters of a string.
14343 1.1 mrg
14344 1.1 mrg @item @emph{Standard}:
14345 1.1 mrg Fortran 95 and later
14346 1.1 mrg
14347 1.1 mrg @item @emph{Class}:
14348 1.1 mrg Transformational function
14349 1.1 mrg
14350 1.1 mrg @item @emph{Syntax}:
14351 1.1 mrg @code{RESULT = TRIM(STRING)}
14352 1.1 mrg
14353 1.1 mrg @item @emph{Arguments}:
14354 1.1 mrg @multitable @columnfractions .15 .70
14355 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
14356 1.1 mrg @end multitable
14357 1.1 mrg
14358 1.1 mrg @item @emph{Return value}:
14359 1.1 mrg A scalar of type @code{CHARACTER} which length is that of @var{STRING}
14360 1.1 mrg less the number of trailing blanks.
14361 1.1 mrg
14362 1.1 mrg @item @emph{Example}:
14363 1.1 mrg @smallexample
14364 1.1 mrg PROGRAM test_trim
14365 1.1 mrg CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
14366 1.1 mrg WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
14367 1.1 mrg END PROGRAM
14368 1.1 mrg @end smallexample
14369 1.1 mrg
14370 1.1 mrg @item @emph{See also}:
14371 1.1 mrg @ref{ADJUSTL}, @ref{ADJUSTR}
14372 1.1 mrg @end table
14373 1.1 mrg
14374 1.1 mrg
14375 1.1 mrg
14376 1.1 mrg @node TTYNAM
14377 1.1 mrg @section @code{TTYNAM} --- Get the name of a terminal device.
14378 1.1 mrg @fnindex TTYNAM
14379 1.1 mrg @cindex system, terminal
14380 1.1 mrg
14381 1.1 mrg @table @asis
14382 1.1 mrg @item @emph{Description}:
14383 1.1 mrg Get the name of a terminal device. For more information,
14384 1.1 mrg see @code{ttyname(3)}.
14385 1.1 mrg
14386 1.1 mrg This intrinsic is provided in both subroutine and function forms;
14387 1.1 mrg however, only one form can be used in any given program unit.
14388 1.1 mrg
14389 1.1 mrg @item @emph{Standard}:
14390 1.1 mrg GNU extension
14391 1.1 mrg
14392 1.1 mrg @item @emph{Class}:
14393 1.1 mrg Subroutine, function
14394 1.1 mrg
14395 1.1 mrg @item @emph{Syntax}:
14396 1.1 mrg @multitable @columnfractions .80
14397 1.1 mrg @item @code{CALL TTYNAM(UNIT, NAME)}
14398 1.1 mrg @item @code{NAME = TTYNAM(UNIT)}
14399 1.1 mrg @end multitable
14400 1.1 mrg
14401 1.1 mrg @item @emph{Arguments}:
14402 1.1 mrg @multitable @columnfractions .15 .70
14403 1.1 mrg @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
14404 1.1 mrg @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
14405 1.1 mrg @end multitable
14406 1.1 mrg
14407 1.1 mrg @item @emph{Example}:
14408 1.1 mrg @smallexample
14409 1.1 mrg PROGRAM test_ttynam
14410 1.1 mrg INTEGER :: unit
14411 1.1 mrg DO unit = 1, 10
14412 1.1 mrg IF (isatty(unit=unit)) write(*,*) ttynam(unit)
14413 1.1 mrg END DO
14414 1.1 mrg END PROGRAM
14415 1.1 mrg @end smallexample
14416 1.1 mrg
14417 1.1 mrg @item @emph{See also}:
14418 1.1 mrg @ref{ISATTY}
14419 1.1 mrg @end table
14420 1.1 mrg
14421 1.1 mrg
14422 1.1 mrg
14423 1.1 mrg @node UBOUND
14424 1.1 mrg @section @code{UBOUND} --- Upper dimension bounds of an array
14425 1.1 mrg @fnindex UBOUND
14426 1.1 mrg @cindex array, upper bound
14427 1.1 mrg
14428 1.1 mrg @table @asis
14429 1.1 mrg @item @emph{Description}:
14430 1.1 mrg Returns the upper bounds of an array, or a single upper bound
14431 1.1 mrg along the @var{DIM} dimension.
14432 1.1 mrg @item @emph{Standard}:
14433 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
14434 1.1 mrg
14435 1.1 mrg @item @emph{Class}:
14436 1.1 mrg Inquiry function
14437 1.1 mrg
14438 1.1 mrg @item @emph{Syntax}:
14439 1.1 mrg @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
14440 1.1 mrg
14441 1.1 mrg @item @emph{Arguments}:
14442 1.1 mrg @multitable @columnfractions .15 .70
14443 1.1 mrg @item @var{ARRAY} @tab Shall be an array, of any type.
14444 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14445 1.1 mrg @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
14446 1.1 mrg expression indicating the kind parameter of the result.
14447 1.1 mrg @end multitable
14448 1.1 mrg
14449 1.1 mrg @item @emph{Return value}:
14450 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14451 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
14452 1.1 mrg If @var{DIM} is absent, the result is an array of the upper bounds of
14453 1.1 mrg @var{ARRAY}. If @var{DIM} is present, the result is a scalar
14454 1.1 mrg corresponding to the upper bound of the array along that dimension. If
14455 1.1 mrg @var{ARRAY} is an expression rather than a whole array or array
14456 1.1 mrg structure component, or if it has a zero extent along the relevant
14457 1.1 mrg dimension, the upper bound is taken to be the number of elements along
14458 1.1 mrg the relevant dimension.
14459 1.1 mrg
14460 1.1 mrg @item @emph{See also}:
14461 1.1 mrg @ref{LBOUND}, @ref{LCOBOUND}
14462 1.1 mrg @end table
14463 1.1 mrg
14464 1.1 mrg
14465 1.1 mrg
14466 1.1 mrg @node UCOBOUND
14467 1.1 mrg @section @code{UCOBOUND} --- Upper codimension bounds of an array
14468 1.1 mrg @fnindex UCOBOUND
14469 1.1 mrg @cindex coarray, upper bound
14470 1.1 mrg
14471 1.1 mrg @table @asis
14472 1.1 mrg @item @emph{Description}:
14473 1.1 mrg Returns the upper cobounds of a coarray, or a single upper cobound
14474 1.1 mrg along the @var{DIM} codimension.
14475 1.1 mrg @item @emph{Standard}:
14476 1.1 mrg Fortran 2008 and later
14477 1.1 mrg
14478 1.1 mrg @item @emph{Class}:
14479 1.1 mrg Inquiry function
14480 1.1 mrg
14481 1.1 mrg @item @emph{Syntax}:
14482 1.1 mrg @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
14483 1.1 mrg
14484 1.1 mrg @item @emph{Arguments}:
14485 1.1 mrg @multitable @columnfractions .15 .70
14486 1.1 mrg @item @var{ARRAY} @tab Shall be an coarray, of any type.
14487 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14488 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
14489 1.1 mrg expression indicating the kind parameter of the result.
14490 1.1 mrg @end multitable
14491 1.1 mrg
14492 1.1 mrg @item @emph{Return value}:
14493 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14494 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
14495 1.1 mrg If @var{DIM} is absent, the result is an array of the lower cobounds of
14496 1.1 mrg @var{COARRAY}. If @var{DIM} is present, the result is a scalar
14497 1.1 mrg corresponding to the lower cobound of the array along that codimension.
14498 1.1 mrg
14499 1.1 mrg @item @emph{See also}:
14500 1.1 mrg @ref{LCOBOUND}, @ref{LBOUND}
14501 1.1 mrg @end table
14502 1.1 mrg
14503 1.1 mrg
14504 1.1 mrg
14505 1.1 mrg @node UMASK
14506 1.1 mrg @section @code{UMASK} --- Set the file creation mask
14507 1.1 mrg @fnindex UMASK
14508 1.1 mrg @cindex file system, file creation mask
14509 1.1 mrg
14510 1.1 mrg @table @asis
14511 1.1 mrg @item @emph{Description}:
14512 1.1 mrg Sets the file creation mask to @var{MASK}. If called as a function, it
14513 1.1 mrg returns the old value. If called as a subroutine and argument @var{OLD}
14514 1.1 mrg if it is supplied, it is set to the old value. See @code{umask(2)}.
14515 1.1 mrg
14516 1.1 mrg @item @emph{Standard}:
14517 1.1 mrg GNU extension
14518 1.1 mrg
14519 1.1 mrg @item @emph{Class}:
14520 1.1 mrg Subroutine, function
14521 1.1 mrg
14522 1.1 mrg @item @emph{Syntax}:
14523 1.1 mrg @multitable @columnfractions .80
14524 1.1 mrg @item @code{CALL UMASK(MASK [, OLD])}
14525 1.1 mrg @item @code{OLD = UMASK(MASK)}
14526 1.1 mrg @end multitable
14527 1.1 mrg
14528 1.1 mrg @item @emph{Arguments}:
14529 1.1 mrg @multitable @columnfractions .15 .70
14530 1.1 mrg @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
14531 1.1 mrg @item @var{OLD} @tab (Optional) Shall be a scalar of type
14532 1.1 mrg @code{INTEGER}.
14533 1.1 mrg @end multitable
14534 1.1 mrg
14535 1.1 mrg @end table
14536 1.1 mrg
14537 1.1 mrg
14538 1.1 mrg
14539 1.1 mrg @node UNLINK
14540 1.1 mrg @section @code{UNLINK} --- Remove a file from the file system
14541 1.1 mrg @fnindex UNLINK
14542 1.1 mrg @cindex file system, remove file
14543 1.1 mrg
14544 1.1 mrg @table @asis
14545 1.1 mrg @item @emph{Description}:
14546 1.1 mrg Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
14547 1.1 mrg used to mark the end of the name in @var{PATH}; otherwise, trailing
14548 1.1 mrg blanks in the file name are ignored. If the @var{STATUS} argument is
14549 1.1 mrg supplied, it contains 0 on success or a nonzero error code upon return;
14550 1.1 mrg see @code{unlink(2)}.
14551 1.1 mrg
14552 1.1 mrg This intrinsic is provided in both subroutine and function forms;
14553 1.1 mrg however, only one form can be used in any given program unit.
14554 1.1 mrg
14555 1.1 mrg @item @emph{Standard}:
14556 1.1 mrg GNU extension
14557 1.1 mrg
14558 1.1 mrg @item @emph{Class}:
14559 1.1 mrg Subroutine, function
14560 1.1 mrg
14561 1.1 mrg @item @emph{Syntax}:
14562 1.1 mrg @multitable @columnfractions .80
14563 1.1 mrg @item @code{CALL UNLINK(PATH [, STATUS])}
14564 1.1 mrg @item @code{STATUS = UNLINK(PATH)}
14565 1.1 mrg @end multitable
14566 1.1 mrg
14567 1.1 mrg @item @emph{Arguments}:
14568 1.1 mrg @multitable @columnfractions .15 .70
14569 1.1 mrg @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
14570 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
14571 1.1 mrg @end multitable
14572 1.1 mrg
14573 1.1 mrg @item @emph{See also}:
14574 1.1 mrg @ref{LINK}, @ref{SYMLNK}
14575 1.1 mrg @end table
14576 1.1 mrg
14577 1.1 mrg
14578 1.1 mrg
14579 1.1 mrg @node UNPACK
14580 1.1 mrg @section @code{UNPACK} --- Unpack an array of rank one into an array
14581 1.1 mrg @fnindex UNPACK
14582 1.1 mrg @cindex array, unpacking
14583 1.1 mrg @cindex array, increase dimension
14584 1.1 mrg @cindex array, scatter elements
14585 1.1 mrg
14586 1.1 mrg @table @asis
14587 1.1 mrg @item @emph{Description}:
14588 1.1 mrg Store the elements of @var{VECTOR} in an array of higher rank.
14589 1.1 mrg
14590 1.1 mrg @item @emph{Standard}:
14591 1.1 mrg Fortran 95 and later
14592 1.1 mrg
14593 1.1 mrg @item @emph{Class}:
14594 1.1 mrg Transformational function
14595 1.1 mrg
14596 1.1 mrg @item @emph{Syntax}:
14597 1.1 mrg @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
14598 1.1 mrg
14599 1.1 mrg @item @emph{Arguments}:
14600 1.1 mrg @multitable @columnfractions .15 .70
14601 1.1 mrg @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
14602 1.1 mrg shall have at least as many elements as @var{MASK} has @code{TRUE} values.
14603 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
14604 1.1 mrg @item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have
14605 1.1 mrg the same shape as @var{MASK}.
14606 1.1 mrg @end multitable
14607 1.1 mrg
14608 1.1 mrg @item @emph{Return value}:
14609 1.1 mrg The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
14610 1.1 mrg of @var{MASK} replaced by values from @var{VECTOR} in array element order.
14611 1.1 mrg
14612 1.1 mrg @item @emph{Example}:
14613 1.1 mrg @smallexample
14614 1.1 mrg PROGRAM test_unpack
14615 1.1 mrg integer :: vector(2) = (/1,1/)
14616 1.1 mrg logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
14617 1.1 mrg integer :: field(2,2) = 0, unity(2,2)
14618 1.1 mrg
14619 1.1 mrg ! result: unity matrix
14620 1.1 mrg unity = unpack(vector, reshape(mask, (/2,2/)), field)
14621 1.1 mrg END PROGRAM
14622 1.1 mrg @end smallexample
14623 1.1 mrg
14624 1.1 mrg @item @emph{See also}:
14625 1.1 mrg @ref{PACK}, @ref{SPREAD}
14626 1.1 mrg @end table
14627 1.1 mrg
14628 1.1 mrg
14629 1.1 mrg
14630 1.1 mrg @node VERIFY
14631 1.1 mrg @section @code{VERIFY} --- Scan a string for characters not a given set
14632 1.1 mrg @fnindex VERIFY
14633 1.1 mrg @cindex string, find missing set
14634 1.1 mrg
14635 1.1 mrg @table @asis
14636 1.1 mrg @item @emph{Description}:
14637 1.1 mrg Verifies that all the characters in @var{STRING} belong to the set of
14638 1.1 mrg characters in @var{SET}.
14639 1.1 mrg
14640 1.1 mrg If @var{BACK} is either absent or equals @code{FALSE}, this function
14641 1.1 mrg returns the position of the leftmost character of @var{STRING} that is
14642 1.1 mrg not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost
14643 1.1 mrg position is returned. If all characters of @var{STRING} are found in
14644 1.1 mrg @var{SET}, the result is zero.
14645 1.1 mrg
14646 1.1 mrg @item @emph{Standard}:
14647 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
14648 1.1 mrg
14649 1.1 mrg @item @emph{Class}:
14650 1.1 mrg Elemental function
14651 1.1 mrg
14652 1.1 mrg @item @emph{Syntax}:
14653 1.1 mrg @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
14654 1.1 mrg
14655 1.1 mrg @item @emph{Arguments}:
14656 1.1 mrg @multitable @columnfractions .15 .70
14657 1.1 mrg @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
14658 1.1 mrg @item @var{SET} @tab Shall be of type @code{CHARACTER}.
14659 1.1 mrg @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
14660 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
14661 1.1 mrg expression indicating the kind parameter of the result.
14662 1.1 mrg @end multitable
14663 1.1 mrg
14664 1.1 mrg @item @emph{Return value}:
14665 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14666 1.1 mrg @var{KIND} is absent, the return value is of default integer kind.
14667 1.1 mrg
14668 1.1 mrg @item @emph{Example}:
14669 1.1 mrg @smallexample
14670 1.1 mrg PROGRAM test_verify
14671 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
14672 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
14673 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
14674 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
14675 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
14676 1.1 mrg END PROGRAM
14677 1.1 mrg @end smallexample
14678 1.1 mrg
14679 1.1 mrg @item @emph{See also}:
14680 1.1 mrg @ref{SCAN}, @ref{INDEX intrinsic}
14681 1.1 mrg @end table
14682 1.1 mrg
14683 1.1 mrg
14684 1.1 mrg
14685 1.1 mrg @node XOR
14686 1.1 mrg @section @code{XOR} --- Bitwise logical exclusive OR
14687 1.1 mrg @fnindex XOR
14688 1.1 mrg @cindex bitwise logical exclusive or
14689 1.1 mrg @cindex logical exclusive or, bitwise
14690 1.1 mrg
14691 1.1 mrg @table @asis
14692 1.1 mrg @item @emph{Description}:
14693 1.1 mrg Bitwise logical exclusive or.
14694 1.1 mrg
14695 1.1 mrg This intrinsic routine is provided for backwards compatibility with
14696 1.1 mrg GNU Fortran 77. For integer arguments, programmers should consider
14697 1.1 mrg the use of the @ref{IEOR} intrinsic and for logical arguments the
14698 1.1 mrg @code{.NEQV.} operator, which are both defined by the Fortran standard.
14699 1.1 mrg
14700 1.1 mrg @item @emph{Standard}:
14701 1.1 mrg GNU extension
14702 1.1 mrg
14703 1.1 mrg @item @emph{Class}:
14704 1.1 mrg Function
14705 1.1 mrg
14706 1.1 mrg @item @emph{Syntax}:
14707 1.1 mrg @code{RESULT = XOR(I, J)}
14708 1.1 mrg
14709 1.1 mrg @item @emph{Arguments}:
14710 1.1 mrg @multitable @columnfractions .15 .70
14711 1.1 mrg @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
14712 1.1 mrg type or a scalar @code{LOGICAL} type or a boz-literal-constant.
14713 1.1 mrg @item @var{J} @tab The type shall be the same as the type of @var{I} or
14714 1.1 mrg a boz-literal-constant. @var{I} and @var{J} shall not both be
14715 1.1 mrg boz-literal-constants. If either @var{I} and @var{J} is a
14716 1.1 mrg boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
14717 1.1 mrg @end multitable
14718 1.1 mrg
14719 1.1 mrg @item @emph{Return value}:
14720 1.1 mrg The return type is either a scalar @code{INTEGER} or a scalar
14721 1.1 mrg @code{LOGICAL}. If the kind type parameters differ, then the
14722 1.1 mrg smaller kind type is implicitly converted to larger kind, and the
14723 1.1 mrg return has the larger kind. A boz-literal-constant is
14724 1.1 mrg converted to an @code{INTEGER} with the kind type parameter of
14725 1.1 mrg the other argument as-if a call to @ref{INT} occurred.
14726 1.1 mrg
14727 1.1 mrg @item @emph{Example}:
14728 1.1 mrg @smallexample
14729 1.1 mrg PROGRAM test_xor
14730 1.1 mrg LOGICAL :: T = .TRUE., F = .FALSE.
14731 1.1 mrg INTEGER :: a, b
14732 1.1 mrg DATA a / Z'F' /, b / Z'3' /
14733 1.1 mrg
14734 1.1 mrg WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
14735 1.1 mrg WRITE (*,*) XOR(a, b)
14736 1.1 mrg END PROGRAM
14737 1.1 mrg @end smallexample
14738 1.1 mrg
14739 1.1 mrg @item @emph{See also}:
14740 1.1 mrg Fortran 95 elemental function: @ref{IEOR}
14741 1.1 mrg @end table
14742 1.1 mrg
14743 1.1 mrg
14744 1.1 mrg
14745 1.1 mrg @node Intrinsic Modules
14746 1.1 mrg @chapter Intrinsic Modules
14747 1.1 mrg @cindex intrinsic Modules
14748 1.1 mrg
14749 1.1 mrg @menu
14750 1.1 mrg * ISO_FORTRAN_ENV::
14751 1.1 mrg * ISO_C_BINDING::
14752 1.1 mrg * IEEE modules::
14753 1.1 mrg * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
14754 1.1 mrg * OpenACC Module OPENACC::
14755 1.1 mrg @end menu
14756 1.1 mrg
14757 1.1 mrg @node ISO_FORTRAN_ENV
14758 1.1 mrg @section @code{ISO_FORTRAN_ENV}
14759 1.1 mrg @table @asis
14760 1.1 mrg @item @emph{Standard}:
14761 1.1 mrg Fortran 2003 and later, except when otherwise noted
14762 1.1 mrg @end table
14763 1.1 mrg
14764 1.1 mrg The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
14765 1.1 mrg named constants:
14766 1.1 mrg
14767 1.1 mrg @table @asis
14768 1.1 mrg @item @code{ATOMIC_INT_KIND}:
14769 1.1 mrg Default-kind integer constant to be used as kind parameter when defining
14770 1.1 mrg integer variables used in atomic operations. (Fortran 2008 or later.)
14771 1.1 mrg
14772 1.1 mrg @item @code{ATOMIC_LOGICAL_KIND}:
14773 1.1 mrg Default-kind integer constant to be used as kind parameter when defining
14774 1.1 mrg logical variables used in atomic operations. (Fortran 2008 or later.)
14775 1.1 mrg
14776 1.1 mrg @item @code{CHARACTER_KINDS}:
14777 1.1 mrg Default-kind integer constant array of rank one containing the supported kind
14778 1.1 mrg parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
14779 1.1 mrg
14780 1.1 mrg @item @code{CHARACTER_STORAGE_SIZE}:
14781 1.1 mrg Size in bits of the character storage unit.
14782 1.1 mrg
14783 1.1 mrg @item @code{ERROR_UNIT}:
14784 1.1 mrg Identifies the preconnected unit used for error reporting.
14785 1.1 mrg
14786 1.1 mrg @item @code{FILE_STORAGE_SIZE}:
14787 1.1 mrg Size in bits of the file-storage unit.
14788 1.1 mrg
14789 1.1 mrg @item @code{INPUT_UNIT}:
14790 1.1 mrg Identifies the preconnected unit identified by the asterisk
14791 1.1 mrg (@code{*}) in @code{READ} statement.
14792 1.1 mrg
14793 1.1 mrg @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
14794 1.1 mrg Kind type parameters to specify an INTEGER type with a storage
14795 1.1 mrg size of 16, 32, and 64 bits. It is negative if a target platform
14796 1.1 mrg does not support the particular kind. (Fortran 2008 or later.)
14797 1.1 mrg
14798 1.1 mrg @item @code{INTEGER_KINDS}:
14799 1.1 mrg Default-kind integer constant array of rank one containing the supported kind
14800 1.1 mrg parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
14801 1.1 mrg
14802 1.1 mrg @item @code{IOSTAT_END}:
14803 1.1 mrg The value assigned to the variable passed to the @code{IOSTAT=} specifier of
14804 1.1 mrg an input/output statement if an end-of-file condition occurred.
14805 1.1 mrg
14806 1.1 mrg @item @code{IOSTAT_EOR}:
14807 1.1 mrg The value assigned to the variable passed to the @code{IOSTAT=} specifier of
14808 1.1 mrg an input/output statement if an end-of-record condition occurred.
14809 1.1 mrg
14810 1.1 mrg @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
14811 1.1 mrg Scalar default-integer constant, used by @code{INQUIRE} for the
14812 1.1 mrg @code{IOSTAT=} specifier to denote an that a unit number identifies an
14813 1.1 mrg internal unit. (Fortran 2008 or later.)
14814 1.1 mrg
14815 1.1 mrg @item @code{NUMERIC_STORAGE_SIZE}:
14816 1.1 mrg The size in bits of the numeric storage unit.
14817 1.1 mrg
14818 1.1 mrg @item @code{LOGICAL_KINDS}:
14819 1.1 mrg Default-kind integer constant array of rank one containing the supported kind
14820 1.1 mrg parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
14821 1.1 mrg
14822 1.1 mrg @item @code{OUTPUT_UNIT}:
14823 1.1 mrg Identifies the preconnected unit identified by the asterisk
14824 1.1 mrg (@code{*}) in @code{WRITE} statement.
14825 1.1 mrg
14826 1.1 mrg @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
14827 1.1 mrg Kind type parameters to specify a REAL type with a storage
14828 1.1 mrg size of 32, 64, and 128 bits. It is negative if a target platform
14829 1.1 mrg does not support the particular kind. (Fortran 2008 or later.)
14830 1.1 mrg
14831 1.1 mrg @item @code{REAL_KINDS}:
14832 1.1 mrg Default-kind integer constant array of rank one containing the supported kind
14833 1.1 mrg parameters of the @code{REAL} type. (Fortran 2008 or later.)
14834 1.1 mrg
14835 1.1 mrg @item @code{STAT_LOCKED}:
14836 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{LOCK} to
14837 1.1 mrg denote that the lock variable is locked by the executing image. (Fortran 2008
14838 1.1 mrg or later.)
14839 1.1 mrg
14840 1.1 mrg @item @code{STAT_LOCKED_OTHER_IMAGE}:
14841 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
14842 1.1 mrg denote that the lock variable is locked by another image. (Fortran 2008 or
14843 1.1 mrg later.)
14844 1.1 mrg
14845 1.1 mrg @item @code{STAT_STOPPED_IMAGE}:
14846 1.1 mrg Positive, scalar default-integer constant used as STAT= return value if the
14847 1.1 mrg argument in the statement requires synchronisation with an image, which has
14848 1.1 mrg initiated the termination of the execution. (Fortran 2008 or later.)
14849 1.1 mrg
14850 1.1 mrg @item @code{STAT_FAILED_IMAGE}:
14851 1.1 mrg Positive, scalar default-integer constant used as STAT= return value if the
14852 1.1 mrg argument in the statement requires communication with an image, which has
14853 1.1 mrg is in the failed state. (TS 18508 or later.)
14854 1.1 mrg
14855 1.1 mrg @item @code{STAT_UNLOCKED}:
14856 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
14857 1.1 mrg denote that the lock variable is unlocked. (Fortran 2008 or later.)
14858 1.1 mrg @end table
14859 1.1 mrg
14860 1.1 mrg The module provides the following derived type:
14861 1.1 mrg
14862 1.1 mrg @table @asis
14863 1.1 mrg @item @code{LOCK_TYPE}:
14864 1.1 mrg Derived type with private components to be use with the @code{LOCK} and
14865 1.1 mrg @code{UNLOCK} statement. A variable of its type has to be always declared
14866 1.1 mrg as coarray and may not appear in a variable-definition context.
14867 1.1 mrg (Fortran 2008 or later.)
14868 1.1 mrg @end table
14869 1.1 mrg
14870 1.1 mrg The module also provides the following intrinsic procedures:
14871 1.1 mrg @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
14872 1.1 mrg
14873 1.1 mrg
14874 1.1 mrg
14875 1.1 mrg @node ISO_C_BINDING
14876 1.1 mrg @section @code{ISO_C_BINDING}
14877 1.1 mrg @table @asis
14878 1.1 mrg @item @emph{Standard}:
14879 1.1 mrg Fortran 2003 and later, GNU extensions
14880 1.1 mrg @end table
14881 1.1 mrg
14882 1.1 mrg The following intrinsic procedures are provided by the module; their
14883 1.1 mrg definition can be found in the section Intrinsic Procedures of this
14884 1.1 mrg manual.
14885 1.1 mrg
14886 1.1 mrg @table @asis
14887 1.1 mrg @item @code{C_ASSOCIATED}
14888 1.1 mrg @item @code{C_F_POINTER}
14889 1.1 mrg @item @code{C_F_PROCPOINTER}
14890 1.1 mrg @item @code{C_FUNLOC}
14891 1.1 mrg @item @code{C_LOC}
14892 1.1 mrg @item @code{C_SIZEOF}
14893 1.1 mrg @end table
14894 1.1 mrg @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
14895 1.1 mrg @c don't really know why.
14896 1.1 mrg
14897 1.1 mrg The @code{ISO_C_BINDING} module provides the following named constants of
14898 1.1 mrg type default integer, which can be used as KIND type parameters.
14899 1.1 mrg
14900 1.1 mrg In addition to the integer named constants required by the Fortran 2003
14901 1.1 mrg standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an
14902 1.1 mrg extension named constants for the 128-bit integer types supported by the
14903 1.1 mrg C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}.
14904 1.1 mrg Furthermore, if @code{__float128} is supported in C, the named constants
14905 1.1 mrg @code{C_FLOAT128, C_FLOAT128_COMPLEX} are defined.
14906 1.1 mrg
14907 1.1 mrg @multitable @columnfractions .15 .35 .35 .35
14908 1.1 mrg @item Fortran Type @tab Named constant @tab C type @tab Extension
14909 1.1 mrg @item @code{INTEGER}@tab @code{C_INT} @tab @code{int}
14910 1.1 mrg @item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int}
14911 1.1 mrg @item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int}
14912 1.1 mrg @item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int}
14913 1.1 mrg @item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char}
14914 1.1 mrg @item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t}
14915 1.1 mrg @item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t}
14916 1.1 mrg @item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t}
14917 1.1 mrg @item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t}
14918 1.1 mrg @item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t}
14919 1.1 mrg @item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
14920 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t}
14921 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
14922 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
14923 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
14924 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext.
14925 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t}
14926 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t}
14927 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t}
14928 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t}
14929 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext.
14930 1.1 mrg @item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t}
14931 1.1 mrg @item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t}
14932 1.1 mrg @item @code{INTEGER}@tab @code{C_PTRDIFF_T} @tab @code{ptrdiff_t} @tab TS 29113
14933 1.1 mrg @item @code{REAL} @tab @code{C_FLOAT} @tab @code{float}
14934 1.1 mrg @item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double}
14935 1.1 mrg @item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double}
14936 1.1 mrg @item @code{REAL} @tab @code{C_FLOAT128} @tab @code{__float128} @tab Ext.
14937 1.1 mrg @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
14938 1.1 mrg @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
14939 1.1 mrg @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
14940 1.1 mrg @item @code{REAL} @tab @code{C_FLOAT128_COMPLEX} @tab @code{__float128 _Complex} @tab Ext.
14941 1.1 mrg @item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool}
14942 1.1 mrg @item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char}
14943 1.1 mrg @end multitable
14944 1.1 mrg
14945 1.1 mrg Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
14946 1.1 mrg are defined.
14947 1.1 mrg
14948 1.1 mrg @multitable @columnfractions .20 .45 .15
14949 1.1 mrg @item Name @tab C definition @tab Value
14950 1.1 mrg @item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'}
14951 1.1 mrg @item @code{C_ALERT} @tab alert @tab @code{'\a'}
14952 1.1 mrg @item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'}
14953 1.1 mrg @item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'}
14954 1.1 mrg @item @code{C_NEW_LINE} @tab new line @tab @code{'\n'}
14955 1.1 mrg @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
14956 1.1 mrg @item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'}
14957 1.1 mrg @item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'}
14958 1.1 mrg @end multitable
14959 1.1 mrg
14960 1.1 mrg Moreover, the following two named constants are defined:
14961 1.1 mrg
14962 1.1 mrg @multitable @columnfractions .20 .80
14963 1.1 mrg @item Name @tab Type
14964 1.1 mrg @item @code{C_NULL_PTR} @tab @code{C_PTR}
14965 1.1 mrg @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
14966 1.1 mrg @end multitable
14967 1.1 mrg
14968 1.1 mrg Both are equivalent to the value @code{NULL} in C.
14969 1.1 mrg
14970 1.1 mrg
14971 1.1 mrg
14972 1.1 mrg @node IEEE modules
14973 1.1 mrg @section IEEE modules: @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
14974 1.1 mrg @table @asis
14975 1.1 mrg @item @emph{Standard}:
14976 1.1 mrg Fortran 2003 and later
14977 1.1 mrg @end table
14978 1.1 mrg
14979 1.1 mrg The @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
14980 1.1 mrg intrinsic modules provide support for exceptions and IEEE arithmetic, as
14981 1.1 mrg defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard
14982 1.1 mrg (@emph{Binary floating-point arithmetic for microprocessor systems}). These
14983 1.1 mrg modules are only provided on the following supported platforms:
14984 1.1 mrg
14985 1.1 mrg @itemize @bullet
14986 1.1 mrg @item i386 and x86_64 processors
14987 1.1 mrg @item platforms which use the GNU C Library (glibc)
14988 1.1 mrg @item platforms with support for SysV/386 routines for floating point
14989 1.1 mrg interface (including Solaris and BSDs)
14990 1.1 mrg @item platforms with the AIX OS
14991 1.1 mrg @end itemize
14992 1.1 mrg
14993 1.1 mrg For full compliance with the Fortran standards, code using the
14994 1.1 mrg @code{IEEE_EXCEPTIONS} or @code{IEEE_ARITHMETIC} modules should be compiled
14995 1.1 mrg with the following options: @code{-fno-unsafe-math-optimizations
14996 1.1 mrg -frounding-math -fsignaling-nans}.
14997 1.1 mrg
14998 1.1 mrg
14999 1.1 mrg
15000 1.1 mrg @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
15001 1.1 mrg @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
15002 1.1 mrg @table @asis
15003 1.1 mrg @item @emph{Standard}:
15004 1.1 mrg OpenMP Application Program Interface v4.5
15005 1.1 mrg @end table
15006 1.1 mrg
15007 1.1 mrg
15008 1.1 mrg The OpenMP Fortran runtime library routines are provided both in
15009 1.1 mrg a form of two Fortran 90 modules, named @code{OMP_LIB} and
15010 1.1 mrg @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
15011 1.1 mrg @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
15012 1.1 mrg in the @ref{Top,,Introduction,libgomp,GNU Offloading and Multi
15013 1.1 mrg Processing Runtime Library} manual,
15014 1.1 mrg the named constants defined in the modules are listed
15015 1.1 mrg below.
15016 1.1 mrg
15017 1.1 mrg For details refer to the actual
15018 1.1 mrg @uref{http://www.openmp.org/wp-content/uploads/openmp-4.5.pdf,
15019 1.1 mrg OpenMP Application Program Interface v4.5}.
15020 1.1 mrg And for the @code{pause}-related constants to the OpenMP 5.0 specification.
15021 1.1 mrg
15022 1.1 mrg @code{OMP_LIB_KINDS} provides the following scalar default-integer
15023 1.1 mrg named constants:
15024 1.1 mrg
15025 1.1 mrg @table @asis
15026 1.1 mrg @item @code{omp_lock_kind}
15027 1.1 mrg @item @code{omp_lock_hint_kind}
15028 1.1 mrg @item @code{omp_nest_lock_kind}
15029 1.1 mrg @item @code{omp_pause_resource_kind}
15030 1.1 mrg @item @code{omp_proc_bind_kind}
15031 1.1 mrg @item @code{omp_sched_kind}
15032 1.1 mrg @end table
15033 1.1 mrg
15034 1.1 mrg @code{OMP_LIB} provides the scalar default-integer
15035 1.1 mrg named constant @code{openmp_version} with a value of the form
15036 1.1 mrg @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
15037 1.1 mrg of the OpenMP version; for OpenMP v4.5 the value is @code{201511}.
15038 1.1 mrg
15039 1.1 mrg The following scalar integer named constants of the
15040 1.1 mrg kind @code{omp_sched_kind}:
15041 1.1 mrg
15042 1.1 mrg @table @asis
15043 1.1 mrg @item @code{omp_sched_static}
15044 1.1 mrg @item @code{omp_sched_dynamic}
15045 1.1 mrg @item @code{omp_sched_guided}
15046 1.1 mrg @item @code{omp_sched_auto}
15047 1.1 mrg @end table
15048 1.1 mrg
15049 1.1 mrg And the following scalar integer named constants of the
15050 1.1 mrg kind @code{omp_proc_bind_kind}:
15051 1.1 mrg
15052 1.1 mrg @table @asis
15053 1.1 mrg @item @code{omp_proc_bind_false}
15054 1.1 mrg @item @code{omp_proc_bind_true}
15055 1.1 mrg @item @code{omp_proc_bind_master}
15056 1.1 mrg @item @code{omp_proc_bind_close}
15057 1.1 mrg @item @code{omp_proc_bind_spread}
15058 1.1 mrg @end table
15059 1.1 mrg
15060 1.1 mrg The following scalar integer named constants are of the
15061 1.1 mrg kind @code{omp_lock_hint_kind}:
15062 1.1 mrg
15063 1.1 mrg @table @asis
15064 1.1 mrg @item @code{omp_lock_hint_none}
15065 1.1 mrg @item @code{omp_lock_hint_uncontended}
15066 1.1 mrg @item @code{omp_lock_hint_contended}
15067 1.1 mrg @item @code{omp_lock_hint_nonspeculative}
15068 1.1 mrg @item @code{omp_lock_hint_speculative}
15069 1.1 mrg @end table
15070 1.1 mrg
15071 1.1 mrg And the following two scalar integer named constants are of the
15072 1.1 mrg kind @code{omp_pause_resource_kind}:
15073 1.1 mrg
15074 1.1 mrg @table @asis
15075 1.1 mrg @item @code{omp_pause_soft}
15076 1.1 mrg @item @code{omp_pause_hard}
15077 1.1 mrg @end table
15078 1.1 mrg
15079 1.1 mrg
15080 1.1 mrg @node OpenACC Module OPENACC
15081 1.1 mrg @section OpenACC Module @code{OPENACC}
15082 1.1 mrg @table @asis
15083 1.1 mrg @item @emph{Standard}:
15084 1.1 mrg OpenACC Application Programming Interface v2.0
15085 1.1 mrg @end table
15086 1.1 mrg
15087 1.1 mrg
15088 1.1 mrg The OpenACC Fortran runtime library routines are provided both in a
15089 1.1 mrg form of a Fortran 90 module, named @code{OPENACC}, and in form of a
15090 1.1 mrg Fortran @code{include} file named @file{openacc_lib.h}. The
15091 1.1 mrg procedures provided by @code{OPENACC} can be found in the
15092 1.1 mrg @ref{Top,,Introduction,libgomp,GNU Offloading and Multi Processing
15093 1.1 mrg Runtime Library} manual, the named constants defined in the modules
15094 1.1 mrg are listed below.
15095 1.1 mrg
15096 1.1 mrg For details refer to the actual
15097 1.1 mrg @uref{http://www.openacc.org/,
15098 1.1 mrg OpenACC Application Programming Interface v2.0}.
15099 1.1 mrg
15100 1.1 mrg @code{OPENACC} provides the scalar default-integer
15101 1.1 mrg named constant @code{openacc_version} with a value of the form
15102 1.1 mrg @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
15103 1.1 mrg of the OpenACC version; for OpenACC v2.0 the value is @code{201306}.
15104