1 1.1 mrg @ignore 2 1.1.1.3 mrg Copyright (C) 2005-2022 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.1.3 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{LSHIFT}: LSHIFT, Left shift bits 225 1.1 mrg * @code{LSTAT}: LSTAT, Get file status 226 1.1 mrg * @code{LTIME}: LTIME, Convert time to local time info 227 1.1 mrg * @code{MALLOC}: MALLOC, Dynamic memory allocation function 228 1.1 mrg * @code{MASKL}: MASKL, Left justified mask 229 1.1 mrg * @code{MASKR}: MASKR, Right justified mask 230 1.1 mrg * @code{MATMUL}: MATMUL, matrix multiplication 231 1.1 mrg * @code{MAX}: MAX, Maximum value of an argument list 232 1.1 mrg * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind 233 1.1 mrg * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array 234 1.1 mrg * @code{MAXVAL}: MAXVAL, Maximum value of an array 235 1.1 mrg * @code{MCLOCK}: MCLOCK, Time function 236 1.1 mrg * @code{MCLOCK8}: MCLOCK8, Time function (64-bit) 237 1.1 mrg * @code{MERGE}: MERGE, Merge arrays 238 1.1 mrg * @code{MERGE_BITS}: MERGE_BITS, Merge of bits under mask 239 1.1 mrg * @code{MIN}: MIN, Minimum value of an argument list 240 1.1 mrg * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind 241 1.1 mrg * @code{MINLOC}: MINLOC, Location of the minimum value within an array 242 1.1 mrg * @code{MINVAL}: MINVAL, Minimum value of an array 243 1.1 mrg * @code{MOD}: MOD, Remainder function 244 1.1 mrg * @code{MODULO}: MODULO, Modulo function 245 1.1 mrg * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another 246 1.1 mrg * @code{MVBITS}: MVBITS, Move bits from one integer to another 247 1.1 mrg * @code{NEAREST}: NEAREST, Nearest representable number 248 1.1 mrg * @code{NEW_LINE}: NEW_LINE, New line character 249 1.1 mrg * @code{NINT}: NINT, Nearest whole number 250 1.1 mrg * @code{NORM2}: NORM2, Euclidean vector norm 251 1.1 mrg * @code{NOT}: NOT, Logical negation 252 1.1 mrg * @code{NULL}: NULL, Function that returns an disassociated pointer 253 1.1 mrg * @code{NUM_IMAGES}: NUM_IMAGES, Number of images 254 1.1 mrg * @code{OR}: OR, Bitwise logical OR 255 1.1 mrg * @code{PACK}: PACK, Pack an array into an array of rank one 256 1.1 mrg * @code{PARITY}: PARITY, Reduction with exclusive OR 257 1.1 mrg * @code{PERROR}: PERROR, Print system error message 258 1.1 mrg * @code{POPCNT}: POPCNT, Number of bits set 259 1.1 mrg * @code{POPPAR}: POPPAR, Parity of the number of bits set 260 1.1 mrg * @code{PRECISION}: PRECISION, Decimal precision of a real kind 261 1.1 mrg * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified 262 1.1 mrg * @code{PRODUCT}: PRODUCT, Product of array elements 263 1.1 mrg * @code{RADIX}: RADIX, Base of a data model 264 1.1 mrg * @code{RAN}: RAN, Real pseudo-random number 265 1.1 mrg * @code{RAND}: RAND, Real pseudo-random number 266 1.1 mrg * @code{RANDOM_INIT}: RANDOM_INIT, Initialize pseudo-random number generator 267 1.1 mrg * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number 268 1.1 mrg * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence 269 1.1 mrg * @code{RANGE}: RANGE, Decimal exponent range 270 1.1 mrg * @code{RANK} : RANK, Rank of a data object 271 1.1 mrg * @code{REAL}: REAL, Convert to real type 272 1.1 mrg * @code{RENAME}: RENAME, Rename a file 273 1.1 mrg * @code{REPEAT}: REPEAT, Repeated string concatenation 274 1.1 mrg * @code{RESHAPE}: RESHAPE, Function to reshape an array 275 1.1 mrg * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing 276 1.1 mrg * @code{RSHIFT}: RSHIFT, Right shift bits 277 1.1 mrg * @code{SAME_TYPE_AS}: SAME_TYPE_AS, Query dynamic types for equality 278 1.1 mrg * @code{SCALE}: SCALE, Scale a real value 279 1.1 mrg * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters 280 1.1 mrg * @code{SECNDS}: SECNDS, Time function 281 1.1 mrg * @code{SECOND}: SECOND, CPU time function 282 1.1 mrg * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND, Choose character kind 283 1.1 mrg * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind 284 1.1 mrg * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind 285 1.1 mrg * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model 286 1.1 mrg * @code{SHAPE}: SHAPE, Determine the shape of an array 287 1.1 mrg * @code{SHIFTA}: SHIFTA, Right shift with fill 288 1.1 mrg * @code{SHIFTL}: SHIFTL, Left shift 289 1.1 mrg * @code{SHIFTR}: SHIFTR, Right shift 290 1.1 mrg * @code{SIGN}: SIGN, Sign copying function 291 1.1 mrg * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function) 292 1.1 mrg * @code{SIN}: SIN, Sine function 293 1.1 mrg * @code{SIND}: SIND, Sine function, degrees 294 1.1 mrg * @code{SINH}: SINH, Hyperbolic sine function 295 1.1 mrg * @code{SIZE}: SIZE, Function to determine the size of an array 296 1.1 mrg * @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression 297 1.1 mrg * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds 298 1.1 mrg * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type 299 1.1 mrg * @code{SPREAD}: SPREAD, Add a dimension to an array 300 1.1 mrg * @code{SQRT}: SQRT, Square-root function 301 1.1 mrg * @code{SRAND}: SRAND, Reinitialize the random number generator 302 1.1 mrg * @code{STAT}: STAT, Get file status 303 1.1 mrg * @code{STORAGE_SIZE}: STORAGE_SIZE, Storage size in bits 304 1.1 mrg * @code{SUM}: SUM, Sum of array elements 305 1.1 mrg * @code{SYMLNK}: SYMLNK, Create a symbolic link 306 1.1 mrg * @code{SYSTEM}: SYSTEM, Execute a shell command 307 1.1 mrg * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function 308 1.1 mrg * @code{TAN}: TAN, Tangent function 309 1.1 mrg * @code{TAND}: TAND, Tangent function, degrees 310 1.1 mrg * @code{TANH}: TANH, Hyperbolic tangent function 311 1.1 mrg * @code{THIS_IMAGE}: THIS_IMAGE, Cosubscript index of this image 312 1.1 mrg * @code{TIME}: TIME, Time function 313 1.1 mrg * @code{TIME8}: TIME8, Time function (64-bit) 314 1.1 mrg * @code{TINY}: TINY, Smallest positive number of a real kind 315 1.1 mrg * @code{TRAILZ}: TRAILZ, Number of trailing zero bits of an integer 316 1.1 mrg * @code{TRANSFER}: TRANSFER, Transfer bit patterns 317 1.1 mrg * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two 318 1.1 mrg * @code{TRIM}: TRIM, Remove trailing blank characters of a string 319 1.1 mrg * @code{TTYNAM}: TTYNAM, Get the name of a terminal device. 320 1.1 mrg * @code{UBOUND}: UBOUND, Upper dimension bounds of an array 321 1.1 mrg * @code{UCOBOUND}: UCOBOUND, Upper codimension bounds of an array 322 1.1 mrg * @code{UMASK}: UMASK, Set the file creation mask 323 1.1 mrg * @code{UNLINK}: UNLINK, Remove a file from the file system 324 1.1 mrg * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array 325 1.1 mrg * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters 326 1.1 mrg * @code{XOR}: XOR, Bitwise logical exclusive or 327 1.1 mrg @end menu 328 1.1 mrg 329 1.1 mrg @node Introduction to Intrinsics 330 1.1 mrg @section Introduction to intrinsic procedures 331 1.1 mrg 332 1.1.1.3 mrg The intrinsic procedures provided by GNU Fortran include procedures required 333 1.1.1.3 mrg by the Fortran 95 and later supported standards, and a set of intrinsic 334 1.1.1.3 mrg procedures for backwards compatibility with G77. Any conflict between 335 1.1.1.3 mrg a description here and a description in the Fortran standards is 336 1.1.1.3 mrg unintentional, and the standard(s) should be considered authoritative. 337 1.1 mrg 338 1.1 mrg The enumeration of the @code{KIND} type parameter is processor defined in 339 1.1 mrg the Fortran 95 standard. GNU Fortran defines the default integer type and 340 1.1 mrg default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)}, 341 1.1 mrg respectively. The standard mandates that both data types shall have 342 1.1 mrg another kind, which have more precision. On typical target architectures 343 1.1 mrg supported by @command{gfortran}, this kind type parameter is @code{KIND=8}. 344 1.1 mrg Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent. 345 1.1 mrg In the description of generic intrinsic procedures, the kind type parameter 346 1.1 mrg will be specified by @code{KIND=*}, and in the description of specific 347 1.1 mrg names for an intrinsic procedure the kind type parameter will be explicitly 348 1.1 mrg given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for 349 1.1 mrg brevity the optional @code{KIND=} syntax will be omitted. 350 1.1 mrg 351 1.1 mrg Many of the intrinsic procedures take one or more optional arguments. 352 1.1 mrg This document follows the convention used in the Fortran 95 standard, 353 1.1 mrg and denotes such arguments by square brackets. 354 1.1 mrg 355 1.1.1.3 mrg GNU Fortran offers the @option{-std=} command-line option, 356 1.1 mrg which can be used to restrict the set of intrinsic procedures to a 357 1.1 mrg given standard. By default, @command{gfortran} sets the @option{-std=gnu} 358 1.1 mrg option, and so all intrinsic procedures described here are accepted. There 359 1.1 mrg is one caveat. For a select group of intrinsic procedures, @command{g77} 360 1.1 mrg implemented both a function and a subroutine. Both classes 361 1.1 mrg have been implemented in @command{gfortran} for backwards compatibility 362 1.1 mrg with @command{g77}. It is noted here that these functions and subroutines 363 1.1 mrg cannot be intermixed in a given subprogram. In the descriptions that follow, 364 1.1 mrg the applicable standard for each intrinsic procedure is noted. 365 1.1 mrg 366 1.1 mrg 367 1.1 mrg 368 1.1 mrg @node ABORT 369 1.1 mrg @section @code{ABORT} --- Abort the program 370 1.1 mrg @fnindex ABORT 371 1.1 mrg @cindex program termination, with core dump 372 1.1 mrg @cindex terminate program, with core dump 373 1.1 mrg @cindex core, dump 374 1.1 mrg 375 1.1 mrg @table @asis 376 1.1 mrg @item @emph{Description}: 377 1.1 mrg @code{ABORT} causes immediate termination of the program. On operating 378 1.1 mrg systems that support a core dump, @code{ABORT} will produce a core dump. 379 1.1 mrg It will also print a backtrace, unless @code{-fno-backtrace} is given. 380 1.1 mrg 381 1.1 mrg @item @emph{Standard}: 382 1.1 mrg GNU extension 383 1.1 mrg 384 1.1 mrg @item @emph{Class}: 385 1.1 mrg Subroutine 386 1.1 mrg 387 1.1 mrg @item @emph{Syntax}: 388 1.1 mrg @code{CALL ABORT} 389 1.1 mrg 390 1.1 mrg @item @emph{Return value}: 391 1.1 mrg Does not return. 392 1.1 mrg 393 1.1 mrg @item @emph{Example}: 394 1.1 mrg @smallexample 395 1.1 mrg program test_abort 396 1.1 mrg integer :: i = 1, j = 2 397 1.1 mrg if (i /= j) call abort 398 1.1 mrg end program test_abort 399 1.1 mrg @end smallexample 400 1.1 mrg 401 1.1 mrg @item @emph{See also}: 402 1.1.1.2 mrg @ref{EXIT}, @gol 403 1.1.1.2 mrg @ref{KILL}, @gol 404 1.1.1.2 mrg @ref{BACKTRACE} 405 1.1 mrg @end table 406 1.1 mrg 407 1.1 mrg 408 1.1 mrg 409 1.1 mrg @node ABS 410 1.1 mrg @section @code{ABS} --- Absolute value 411 1.1 mrg @fnindex ABS 412 1.1 mrg @fnindex CABS 413 1.1 mrg @fnindex DABS 414 1.1 mrg @fnindex IABS 415 1.1 mrg @fnindex ZABS 416 1.1 mrg @fnindex CDABS 417 1.1 mrg @fnindex BABS 418 1.1 mrg @fnindex IIABS 419 1.1 mrg @fnindex JIABS 420 1.1 mrg @fnindex KIABS 421 1.1 mrg @cindex absolute value 422 1.1 mrg 423 1.1 mrg @table @asis 424 1.1 mrg @item @emph{Description}: 425 1.1 mrg @code{ABS(A)} computes the absolute value of @code{A}. 426 1.1 mrg 427 1.1 mrg @item @emph{Standard}: 428 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions 429 1.1 mrg 430 1.1 mrg @item @emph{Class}: 431 1.1 mrg Elemental function 432 1.1 mrg 433 1.1 mrg @item @emph{Syntax}: 434 1.1 mrg @code{RESULT = ABS(A)} 435 1.1 mrg 436 1.1 mrg @item @emph{Arguments}: 437 1.1 mrg @multitable @columnfractions .15 .70 438 1.1 mrg @item @var{A} @tab The type of the argument shall be an @code{INTEGER}, 439 1.1 mrg @code{REAL}, or @code{COMPLEX}. 440 1.1 mrg @end multitable 441 1.1 mrg 442 1.1 mrg @item @emph{Return value}: 443 1.1 mrg The return value is of the same type and 444 1.1 mrg kind as the argument except the return value is @code{REAL} for a 445 1.1 mrg @code{COMPLEX} argument. 446 1.1 mrg 447 1.1 mrg @item @emph{Example}: 448 1.1 mrg @smallexample 449 1.1 mrg program test_abs 450 1.1 mrg integer :: i = -1 451 1.1 mrg real :: x = -1.e0 452 1.1 mrg complex :: z = (-1.e0,0.e0) 453 1.1 mrg i = abs(i) 454 1.1 mrg x = abs(x) 455 1.1 mrg x = abs(z) 456 1.1 mrg end program test_abs 457 1.1 mrg @end smallexample 458 1.1 mrg 459 1.1 mrg @item @emph{Specific names}: 460 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 461 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 462 1.1 mrg @item @code{ABS(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later 463 1.1 mrg @item @code{CABS(A)} @tab @code{COMPLEX(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later 464 1.1 mrg @item @code{DABS(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later 465 1.1 mrg @item @code{IABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later 466 1.1 mrg @item @code{BABS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 467 1.1 mrg @item @code{IIABS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 468 1.1 mrg @item @code{JIABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 469 1.1 mrg @item @code{KIABS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 470 1.1.1.2 mrg @item @code{ZABS(A)} @tab @code{COMPLEX(8) A} @tab @code{REAL(8)} @tab GNU extension 471 1.1.1.2 mrg @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{REAL(8)} @tab GNU extension 472 1.1 mrg @end multitable 473 1.1 mrg @end table 474 1.1 mrg 475 1.1 mrg 476 1.1 mrg 477 1.1 mrg @node ACCESS 478 1.1 mrg @section @code{ACCESS} --- Checks file access modes 479 1.1 mrg @fnindex ACCESS 480 1.1 mrg @cindex file system, access mode 481 1.1 mrg 482 1.1 mrg @table @asis 483 1.1 mrg @item @emph{Description}: 484 1.1 mrg @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} 485 1.1 mrg exists, is readable, writable or executable. Except for the 486 1.1 mrg executable check, @code{ACCESS} can be replaced by 487 1.1 mrg Fortran 95's @code{INQUIRE}. 488 1.1 mrg 489 1.1 mrg @item @emph{Standard}: 490 1.1 mrg GNU extension 491 1.1 mrg 492 1.1 mrg @item @emph{Class}: 493 1.1 mrg Inquiry function 494 1.1 mrg 495 1.1 mrg @item @emph{Syntax}: 496 1.1 mrg @code{RESULT = ACCESS(NAME, MODE)} 497 1.1 mrg 498 1.1 mrg @item @emph{Arguments}: 499 1.1 mrg @multitable @columnfractions .15 .70 500 1.1 mrg @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the 501 1.1.1.3 mrg file name. Trailing blank are ignored unless the character @code{achar(0)} 502 1.1 mrg is present, then all characters up to and excluding @code{achar(0)} are 503 1.1 mrg used as file name. 504 1.1 mrg @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the 505 1.1 mrg file access mode, may be any concatenation of @code{"r"} (readable), 506 1.1 mrg @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check 507 1.1 mrg for existence. 508 1.1 mrg @end multitable 509 1.1 mrg 510 1.1 mrg @item @emph{Return value}: 511 1.1 mrg Returns a scalar @code{INTEGER}, which is @code{0} if the file is 512 1.1 mrg accessible in the given mode; otherwise or if an invalid argument 513 1.1 mrg has been given for @code{MODE} the value @code{1} is returned. 514 1.1 mrg 515 1.1 mrg @item @emph{Example}: 516 1.1 mrg @smallexample 517 1.1 mrg program access_test 518 1.1 mrg implicit none 519 1.1 mrg character(len=*), parameter :: file = 'test.dat' 520 1.1 mrg character(len=*), parameter :: file2 = 'test.dat '//achar(0) 521 1.1 mrg if(access(file,' ') == 0) print *, trim(file),' is exists' 522 1.1 mrg if(access(file,'r') == 0) print *, trim(file),' is readable' 523 1.1 mrg if(access(file,'w') == 0) print *, trim(file),' is writable' 524 1.1 mrg if(access(file,'x') == 0) print *, trim(file),' is executable' 525 1.1 mrg if(access(file2,'rwx') == 0) & 526 1.1 mrg print *, trim(file2),' is readable, writable and executable' 527 1.1 mrg end program access_test 528 1.1 mrg @end smallexample 529 1.1 mrg @end table 530 1.1 mrg 531 1.1 mrg 532 1.1 mrg 533 1.1 mrg @node ACHAR 534 1.1 mrg @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 535 1.1 mrg @fnindex ACHAR 536 1.1 mrg @cindex @acronym{ASCII} collating sequence 537 1.1 mrg @cindex collating sequence, @acronym{ASCII} 538 1.1 mrg 539 1.1 mrg @table @asis 540 1.1 mrg @item @emph{Description}: 541 1.1 mrg @code{ACHAR(I)} returns the character located at position @code{I} 542 1.1 mrg in the @acronym{ASCII} collating sequence. 543 1.1 mrg 544 1.1 mrg @item @emph{Standard}: 545 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later 546 1.1 mrg 547 1.1 mrg @item @emph{Class}: 548 1.1 mrg Elemental function 549 1.1 mrg 550 1.1 mrg @item @emph{Syntax}: 551 1.1 mrg @code{RESULT = ACHAR(I [, KIND])} 552 1.1 mrg 553 1.1 mrg @item @emph{Arguments}: 554 1.1 mrg @multitable @columnfractions .15 .70 555 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 556 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 557 1.1 mrg expression indicating the kind parameter of the result. 558 1.1 mrg @end multitable 559 1.1 mrg 560 1.1 mrg @item @emph{Return value}: 561 1.1 mrg The return value is of type @code{CHARACTER} with a length of one. 562 1.1 mrg If the @var{KIND} argument is present, the return value is of the 563 1.1 mrg specified kind and of the default kind otherwise. 564 1.1 mrg 565 1.1 mrg @item @emph{Example}: 566 1.1 mrg @smallexample 567 1.1 mrg program test_achar 568 1.1 mrg character c 569 1.1 mrg c = achar(32) 570 1.1 mrg end program test_achar 571 1.1 mrg @end smallexample 572 1.1 mrg 573 1.1 mrg @item @emph{Note}: 574 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values 575 1.1 mrg and formatted string representations. 576 1.1 mrg 577 1.1 mrg @item @emph{See also}: 578 1.1.1.2 mrg @ref{CHAR}, @gol 579 1.1.1.2 mrg @ref{IACHAR}, @gol 580 1.1.1.2 mrg @ref{ICHAR} 581 1.1 mrg @end table 582 1.1 mrg 583 1.1 mrg 584 1.1 mrg 585 1.1 mrg @node ACOS 586 1.1 mrg @section @code{ACOS} --- Arccosine function 587 1.1 mrg @fnindex ACOS 588 1.1 mrg @fnindex DACOS 589 1.1 mrg @cindex trigonometric function, cosine, inverse 590 1.1 mrg @cindex cosine, inverse 591 1.1 mrg 592 1.1 mrg @table @asis 593 1.1 mrg @item @emph{Description}: 594 1.1 mrg @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}). 595 1.1 mrg 596 1.1 mrg @item @emph{Standard}: 597 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later 598 1.1 mrg 599 1.1 mrg @item @emph{Class}: 600 1.1 mrg Elemental function 601 1.1 mrg 602 1.1 mrg @item @emph{Syntax}: 603 1.1 mrg @code{RESULT = ACOS(X)} 604 1.1 mrg 605 1.1 mrg @item @emph{Arguments}: 606 1.1 mrg @multitable @columnfractions .15 .70 607 1.1 mrg @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is 608 1.1 mrg less than or equal to one - or the type shall be @code{COMPLEX}. 609 1.1 mrg @end multitable 610 1.1 mrg 611 1.1 mrg @item @emph{Return value}: 612 1.1 mrg The return value is of the same type and kind as @var{X}. 613 1.1 mrg The real part of the result is in radians and lies in the range 614 1.1 mrg @math{0 \leq \Re \acos(x) \leq \pi}. 615 1.1 mrg 616 1.1 mrg @item @emph{Example}: 617 1.1 mrg @smallexample 618 1.1 mrg program test_acos 619 1.1 mrg real(8) :: x = 0.866_8 620 1.1 mrg x = acos(x) 621 1.1 mrg end program test_acos 622 1.1 mrg @end smallexample 623 1.1 mrg 624 1.1 mrg @item @emph{Specific names}: 625 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 626 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 627 1.1 mrg @item @code{ACOS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 628 1.1 mrg @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 629 1.1 mrg @end multitable 630 1.1 mrg 631 1.1 mrg @item @emph{See also}: 632 1.1.1.2 mrg Inverse function: @gol 633 1.1.1.2 mrg @ref{COS} @gol 634 1.1.1.2 mrg Degrees function: @gol 635 1.1.1.2 mrg @ref{ACOSD} 636 1.1 mrg @end table 637 1.1 mrg 638 1.1 mrg 639 1.1 mrg 640 1.1 mrg @node ACOSD 641 1.1 mrg @section @code{ACOSD} --- Arccosine function, degrees 642 1.1 mrg @fnindex ACOSD 643 1.1 mrg @fnindex DACOSD 644 1.1 mrg @cindex trigonometric function, cosine, inverse, degrees 645 1.1 mrg @cindex cosine, inverse, degrees 646 1.1 mrg 647 1.1 mrg @table @asis 648 1.1 mrg @item @emph{Description}: 649 1.1 mrg @code{ACOSD(X)} computes the arccosine of @var{X} in degrees (inverse of 650 1.1 mrg @code{COSD(X)}). 651 1.1 mrg 652 1.1 mrg This function is for compatibility only and should be avoided in favor of 653 1.1 mrg standard constructs wherever possible. 654 1.1 mrg 655 1.1 mrg @item @emph{Standard}: 656 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math} 657 1.1 mrg 658 1.1 mrg @item @emph{Class}: 659 1.1 mrg Elemental function 660 1.1 mrg 661 1.1 mrg @item @emph{Syntax}: 662 1.1 mrg @code{RESULT = ACOSD(X)} 663 1.1 mrg 664 1.1 mrg @item @emph{Arguments}: 665 1.1 mrg @multitable @columnfractions .15 .70 666 1.1 mrg @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is 667 1.1 mrg less than or equal to one - or the type shall be @code{COMPLEX}. 668 1.1 mrg @end multitable 669 1.1 mrg 670 1.1 mrg @item @emph{Return value}: 671 1.1 mrg The return value is of the same type and kind as @var{X}. 672 1.1 mrg The real part of the result is in degrees and lies in the range 673 1.1 mrg @math{0 \leq \Re \acos(x) \leq 180}. 674 1.1 mrg 675 1.1 mrg @item @emph{Example}: 676 1.1 mrg @smallexample 677 1.1 mrg program test_acosd 678 1.1 mrg real(8) :: x = 0.866_8 679 1.1 mrg x = acosd(x) 680 1.1 mrg end program test_acosd 681 1.1 mrg @end smallexample 682 1.1 mrg 683 1.1 mrg @item @emph{Specific names}: 684 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 685 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 686 1.1.1.2 mrg @item @code{ACOSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 687 1.1.1.2 mrg @item @code{DACOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 688 1.1 mrg @end multitable 689 1.1 mrg 690 1.1 mrg @item @emph{See also}: 691 1.1.1.2 mrg Inverse function: @gol 692 1.1.1.2 mrg @ref{COSD} @gol 693 1.1.1.2 mrg Radians function: @gol 694 1.1.1.2 mrg @ref{ACOS} @gol 695 1.1 mrg @end table 696 1.1 mrg 697 1.1 mrg 698 1.1 mrg 699 1.1 mrg @node ACOSH 700 1.1 mrg @section @code{ACOSH} --- Inverse hyperbolic cosine function 701 1.1 mrg @fnindex ACOSH 702 1.1 mrg @fnindex DACOSH 703 1.1 mrg @cindex area hyperbolic cosine 704 1.1 mrg @cindex inverse hyperbolic cosine 705 1.1 mrg @cindex hyperbolic function, cosine, inverse 706 1.1 mrg @cindex cosine, hyperbolic, inverse 707 1.1 mrg 708 1.1 mrg @table @asis 709 1.1 mrg @item @emph{Description}: 710 1.1 mrg @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}. 711 1.1 mrg 712 1.1 mrg @item @emph{Standard}: 713 1.1 mrg Fortran 2008 and later 714 1.1 mrg 715 1.1 mrg @item @emph{Class}: 716 1.1 mrg Elemental function 717 1.1 mrg 718 1.1 mrg @item @emph{Syntax}: 719 1.1 mrg @code{RESULT = ACOSH(X)} 720 1.1 mrg 721 1.1 mrg @item @emph{Arguments}: 722 1.1 mrg @multitable @columnfractions .15 .70 723 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 724 1.1 mrg @end multitable 725 1.1 mrg 726 1.1 mrg @item @emph{Return value}: 727 1.1 mrg The return value has the same type and kind as @var{X}. If @var{X} is 728 1.1 mrg complex, the imaginary part of the result is in radians and lies between 729 1.1 mrg @math{ 0 \leq \Im \acosh(x) \leq \pi}. 730 1.1 mrg 731 1.1 mrg @item @emph{Example}: 732 1.1 mrg @smallexample 733 1.1 mrg PROGRAM test_acosh 734 1.1 mrg REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /) 735 1.1 mrg WRITE (*,*) ACOSH(x) 736 1.1 mrg END PROGRAM 737 1.1 mrg @end smallexample 738 1.1 mrg 739 1.1 mrg @item @emph{Specific names}: 740 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 741 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 742 1.1 mrg @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 743 1.1 mrg @end multitable 744 1.1 mrg 745 1.1 mrg @item @emph{See also}: 746 1.1.1.2 mrg Inverse function: @gol 747 1.1.1.2 mrg @ref{COSH} 748 1.1 mrg @end table 749 1.1 mrg 750 1.1 mrg 751 1.1 mrg 752 1.1 mrg @node ADJUSTL 753 1.1 mrg @section @code{ADJUSTL} --- Left adjust a string 754 1.1 mrg @fnindex ADJUSTL 755 1.1 mrg @cindex string, adjust left 756 1.1 mrg @cindex adjust string 757 1.1 mrg 758 1.1 mrg @table @asis 759 1.1 mrg @item @emph{Description}: 760 1.1 mrg @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces. 761 1.1 mrg Spaces are inserted at the end of the string as needed. 762 1.1 mrg 763 1.1 mrg @item @emph{Standard}: 764 1.1 mrg Fortran 90 and later 765 1.1 mrg 766 1.1 mrg @item @emph{Class}: 767 1.1 mrg Elemental function 768 1.1 mrg 769 1.1 mrg @item @emph{Syntax}: 770 1.1 mrg @code{RESULT = ADJUSTL(STRING)} 771 1.1 mrg 772 1.1 mrg @item @emph{Arguments}: 773 1.1 mrg @multitable @columnfractions .15 .70 774 1.1 mrg @item @var{STRING} @tab The type shall be @code{CHARACTER}. 775 1.1 mrg @end multitable 776 1.1 mrg 777 1.1 mrg @item @emph{Return value}: 778 1.1 mrg The return value is of type @code{CHARACTER} and of the same kind as 779 1.1 mrg @var{STRING} where leading spaces are removed and the same number of 780 1.1 mrg spaces are inserted on the end of @var{STRING}. 781 1.1 mrg 782 1.1 mrg @item @emph{Example}: 783 1.1 mrg @smallexample 784 1.1 mrg program test_adjustl 785 1.1 mrg character(len=20) :: str = ' gfortran' 786 1.1 mrg str = adjustl(str) 787 1.1 mrg print *, str 788 1.1 mrg end program test_adjustl 789 1.1 mrg @end smallexample 790 1.1 mrg 791 1.1 mrg @item @emph{See also}: 792 1.1.1.2 mrg @ref{ADJUSTR}, @gol 793 1.1.1.2 mrg @ref{TRIM} 794 1.1 mrg @end table 795 1.1 mrg 796 1.1 mrg 797 1.1 mrg 798 1.1 mrg @node ADJUSTR 799 1.1 mrg @section @code{ADJUSTR} --- Right adjust a string 800 1.1 mrg @fnindex ADJUSTR 801 1.1 mrg @cindex string, adjust right 802 1.1 mrg @cindex adjust string 803 1.1 mrg 804 1.1 mrg @table @asis 805 1.1 mrg @item @emph{Description}: 806 1.1 mrg @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces. 807 1.1 mrg Spaces are inserted at the start of the string as needed. 808 1.1 mrg 809 1.1 mrg @item @emph{Standard}: 810 1.1.1.2 mrg Fortran 90 and later 811 1.1 mrg 812 1.1 mrg @item @emph{Class}: 813 1.1 mrg Elemental function 814 1.1 mrg 815 1.1 mrg @item @emph{Syntax}: 816 1.1 mrg @code{RESULT = ADJUSTR(STRING)} 817 1.1 mrg 818 1.1 mrg @item @emph{Arguments}: 819 1.1 mrg @multitable @columnfractions .15 .70 820 1.1 mrg @item @var{STR} @tab The type shall be @code{CHARACTER}. 821 1.1 mrg @end multitable 822 1.1 mrg 823 1.1 mrg @item @emph{Return value}: 824 1.1 mrg The return value is of type @code{CHARACTER} and of the same kind as 825 1.1 mrg @var{STRING} where trailing spaces are removed and the same number of 826 1.1 mrg spaces are inserted at the start of @var{STRING}. 827 1.1 mrg 828 1.1 mrg @item @emph{Example}: 829 1.1 mrg @smallexample 830 1.1 mrg program test_adjustr 831 1.1 mrg character(len=20) :: str = 'gfortran' 832 1.1 mrg str = adjustr(str) 833 1.1 mrg print *, str 834 1.1 mrg end program test_adjustr 835 1.1 mrg @end smallexample 836 1.1 mrg 837 1.1 mrg @item @emph{See also}: 838 1.1.1.2 mrg @ref{ADJUSTL}, @gol 839 1.1.1.2 mrg @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.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 890 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 891 1.1.1.2 mrg @item @code{AIMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab Fortran 77 and later 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.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 950 1.1.1.3 mrg @headitem 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.1.2 mrg Fortran 90 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.1.2 mrg Fortran 90 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.1.2 mrg Fortran 95 elemental function: @gol 1177 1.1.1.2 mrg @ref{IAND} 1178 1.1 mrg @end table 1179 1.1 mrg 1180 1.1 mrg 1181 1.1 mrg 1182 1.1 mrg @node ANINT 1183 1.1 mrg @section @code{ANINT} --- Nearest whole number 1184 1.1 mrg @fnindex ANINT 1185 1.1 mrg @fnindex DNINT 1186 1.1 mrg @cindex ceiling 1187 1.1 mrg @cindex rounding, ceiling 1188 1.1 mrg 1189 1.1 mrg @table @asis 1190 1.1 mrg @item @emph{Description}: 1191 1.1 mrg @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number. 1192 1.1 mrg 1193 1.1 mrg @item @emph{Standard}: 1194 1.1 mrg Fortran 77 and later 1195 1.1 mrg 1196 1.1 mrg @item @emph{Class}: 1197 1.1 mrg Elemental function 1198 1.1 mrg 1199 1.1 mrg @item @emph{Syntax}: 1200 1.1 mrg @code{RESULT = ANINT(A [, KIND])} 1201 1.1 mrg 1202 1.1 mrg @item @emph{Arguments}: 1203 1.1 mrg @multitable @columnfractions .15 .70 1204 1.1 mrg @item @var{A} @tab The type of the argument shall be @code{REAL}. 1205 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 1206 1.1 mrg expression indicating the kind parameter of the result. 1207 1.1 mrg @end multitable 1208 1.1 mrg 1209 1.1 mrg @item @emph{Return value}: 1210 1.1 mrg The return value is of type real with the kind type parameter of the 1211 1.1 mrg argument if the optional @var{KIND} is absent; otherwise, the kind 1212 1.1 mrg type parameter will be given by @var{KIND}. If @var{A} is greater than 1213 1.1 mrg zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is 1214 1.1 mrg less than or equal to zero then it returns @code{AINT(X-0.5)}. 1215 1.1 mrg 1216 1.1 mrg @item @emph{Example}: 1217 1.1 mrg @smallexample 1218 1.1 mrg program test_anint 1219 1.1 mrg real(4) x4 1220 1.1 mrg real(8) x8 1221 1.1 mrg x4 = 1.234E0_4 1222 1.1 mrg x8 = 4.321_8 1223 1.1 mrg print *, anint(x4), dnint(x8) 1224 1.1 mrg x8 = anint(x4,8) 1225 1.1 mrg end program test_anint 1226 1.1 mrg @end smallexample 1227 1.1 mrg 1228 1.1 mrg @item @emph{Specific names}: 1229 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 1230 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1231 1.1.1.3 mrg @item @code{ANINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later 1232 1.1 mrg @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later 1233 1.1 mrg @end multitable 1234 1.1 mrg @end table 1235 1.1 mrg 1236 1.1 mrg 1237 1.1 mrg 1238 1.1 mrg @node ANY 1239 1.1 mrg @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 1240 1.1 mrg @fnindex ANY 1241 1.1 mrg @cindex array, apply condition 1242 1.1 mrg @cindex array, condition testing 1243 1.1 mrg 1244 1.1 mrg @table @asis 1245 1.1 mrg @item @emph{Description}: 1246 1.1 mrg @code{ANY(MASK [, DIM])} determines if any of the values in the logical array 1247 1.1 mrg @var{MASK} along dimension @var{DIM} are @code{.TRUE.}. 1248 1.1 mrg 1249 1.1 mrg @item @emph{Standard}: 1250 1.1.1.2 mrg Fortran 90 and later 1251 1.1 mrg 1252 1.1 mrg @item @emph{Class}: 1253 1.1 mrg Transformational function 1254 1.1 mrg 1255 1.1 mrg @item @emph{Syntax}: 1256 1.1 mrg @code{RESULT = ANY(MASK [, DIM])} 1257 1.1 mrg 1258 1.1 mrg @item @emph{Arguments}: 1259 1.1 mrg @multitable @columnfractions .15 .70 1260 1.1 mrg @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and 1261 1.1 mrg it shall not be scalar. 1262 1.1 mrg @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer 1263 1.1 mrg with a value that lies between one and the rank of @var{MASK}. 1264 1.1 mrg @end multitable 1265 1.1 mrg 1266 1.1 mrg @item @emph{Return value}: 1267 1.1 mrg @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where 1268 1.1 mrg the kind type parameter is the same as the kind type parameter of 1269 1.1 mrg @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns 1270 1.1 mrg an array with the rank of @var{MASK} minus 1. The shape is determined from 1271 1.1 mrg the shape of @var{MASK} where the @var{DIM} dimension is elided. 1272 1.1 mrg 1273 1.1 mrg @table @asis 1274 1.1 mrg @item (A) 1275 1.1 mrg @code{ANY(MASK)} is true if any element of @var{MASK} is true; 1276 1.1 mrg otherwise, it is false. It also is false if @var{MASK} has zero size. 1277 1.1 mrg @item (B) 1278 1.1 mrg If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent 1279 1.1 mrg to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)} 1280 1.1 mrg is determined by applying @code{ANY} to the array sections. 1281 1.1 mrg @end table 1282 1.1 mrg 1283 1.1 mrg @item @emph{Example}: 1284 1.1 mrg @smallexample 1285 1.1 mrg program test_any 1286 1.1 mrg logical l 1287 1.1 mrg l = any((/.true., .true., .true./)) 1288 1.1 mrg print *, l 1289 1.1 mrg call section 1290 1.1 mrg contains 1291 1.1 mrg subroutine section 1292 1.1 mrg integer a(2,3), b(2,3) 1293 1.1 mrg a = 1 1294 1.1 mrg b = 1 1295 1.1 mrg b(2,2) = 2 1296 1.1 mrg print *, any(a .eq. b, 1) 1297 1.1 mrg print *, any(a .eq. b, 2) 1298 1.1 mrg end subroutine section 1299 1.1 mrg end program test_any 1300 1.1 mrg @end smallexample 1301 1.1 mrg @end table 1302 1.1 mrg 1303 1.1 mrg 1304 1.1 mrg 1305 1.1 mrg @node ASIN 1306 1.1 mrg @section @code{ASIN} --- Arcsine function 1307 1.1 mrg @fnindex ASIN 1308 1.1 mrg @fnindex DASIN 1309 1.1 mrg @cindex trigonometric function, sine, inverse 1310 1.1 mrg @cindex sine, inverse 1311 1.1 mrg 1312 1.1 mrg @table @asis 1313 1.1 mrg @item @emph{Description}: 1314 1.1 mrg @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}). 1315 1.1 mrg 1316 1.1 mrg @item @emph{Standard}: 1317 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later 1318 1.1 mrg 1319 1.1 mrg @item @emph{Class}: 1320 1.1 mrg Elemental function 1321 1.1 mrg 1322 1.1 mrg @item @emph{Syntax}: 1323 1.1 mrg @code{RESULT = ASIN(X)} 1324 1.1 mrg 1325 1.1 mrg @item @emph{Arguments}: 1326 1.1 mrg @multitable @columnfractions .15 .70 1327 1.1 mrg @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is 1328 1.1 mrg less than or equal to one - or be @code{COMPLEX}. 1329 1.1 mrg @end multitable 1330 1.1 mrg 1331 1.1 mrg @item @emph{Return value}: 1332 1.1 mrg The return value is of the same type and kind as @var{X}. 1333 1.1 mrg The real part of the result is in radians and lies in the range 1334 1.1 mrg @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}. 1335 1.1 mrg 1336 1.1 mrg @item @emph{Example}: 1337 1.1 mrg @smallexample 1338 1.1 mrg program test_asin 1339 1.1 mrg real(8) :: x = 0.866_8 1340 1.1 mrg x = asin(x) 1341 1.1 mrg end program test_asin 1342 1.1 mrg @end smallexample 1343 1.1 mrg 1344 1.1 mrg @item @emph{Specific names}: 1345 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 1346 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1347 1.1 mrg @item @code{ASIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 1348 1.1 mrg @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 1349 1.1 mrg @end multitable 1350 1.1 mrg 1351 1.1 mrg @item @emph{See also}: 1352 1.1.1.2 mrg Inverse function: @gol 1353 1.1.1.2 mrg @ref{SIN} @gol 1354 1.1.1.2 mrg Degrees function: @gol 1355 1.1.1.2 mrg @ref{ASIND} 1356 1.1 mrg @end table 1357 1.1 mrg 1358 1.1 mrg 1359 1.1 mrg 1360 1.1 mrg @node ASIND 1361 1.1 mrg @section @code{ASIND} --- Arcsine function, degrees 1362 1.1 mrg @fnindex ASIND 1363 1.1 mrg @fnindex DASIND 1364 1.1 mrg @cindex trigonometric function, sine, inverse, degrees 1365 1.1 mrg @cindex sine, inverse, degrees 1366 1.1 mrg 1367 1.1 mrg @table @asis 1368 1.1 mrg @item @emph{Description}: 1369 1.1 mrg @code{ASIND(X)} computes the arcsine of its @var{X} in degrees (inverse of 1370 1.1 mrg @code{SIND(X)}). 1371 1.1 mrg 1372 1.1 mrg This function is for compatibility only and should be avoided in favor of 1373 1.1 mrg standard constructs wherever possible. 1374 1.1 mrg 1375 1.1 mrg @item @emph{Standard}: 1376 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}. 1377 1.1 mrg 1378 1.1 mrg @item @emph{Class}: 1379 1.1 mrg Elemental function 1380 1.1 mrg 1381 1.1 mrg @item @emph{Syntax}: 1382 1.1 mrg @code{RESULT = ASIND(X)} 1383 1.1 mrg 1384 1.1 mrg @item @emph{Arguments}: 1385 1.1 mrg @multitable @columnfractions .15 .70 1386 1.1 mrg @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is 1387 1.1 mrg less than or equal to one - or be @code{COMPLEX}. 1388 1.1 mrg @end multitable 1389 1.1 mrg 1390 1.1 mrg @item @emph{Return value}: 1391 1.1 mrg The return value is of the same type and kind as @var{X}. 1392 1.1 mrg The real part of the result is in degrees and lies in the range 1393 1.1 mrg @math{-90 \leq \Re \asin(x) \leq 90}. 1394 1.1 mrg 1395 1.1 mrg @item @emph{Example}: 1396 1.1 mrg @smallexample 1397 1.1 mrg program test_asind 1398 1.1 mrg real(8) :: x = 0.866_8 1399 1.1 mrg x = asind(x) 1400 1.1 mrg end program test_asind 1401 1.1 mrg @end smallexample 1402 1.1 mrg 1403 1.1 mrg @item @emph{Specific names}: 1404 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 1405 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1406 1.1.1.2 mrg @item @code{ASIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 1407 1.1.1.2 mrg @item @code{DASIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 1408 1.1 mrg @end multitable 1409 1.1 mrg 1410 1.1 mrg @item @emph{See also}: 1411 1.1.1.2 mrg Inverse function: @gol 1412 1.1.1.2 mrg @ref{SIND} @gol 1413 1.1.1.2 mrg Radians function: @gol 1414 1.1.1.2 mrg @ref{ASIN} 1415 1.1 mrg @end table 1416 1.1 mrg 1417 1.1 mrg 1418 1.1 mrg 1419 1.1 mrg @node ASINH 1420 1.1 mrg @section @code{ASINH} --- Inverse hyperbolic sine function 1421 1.1 mrg @fnindex ASINH 1422 1.1 mrg @fnindex DASINH 1423 1.1 mrg @cindex area hyperbolic sine 1424 1.1 mrg @cindex inverse hyperbolic sine 1425 1.1 mrg @cindex hyperbolic function, sine, inverse 1426 1.1 mrg @cindex sine, hyperbolic, inverse 1427 1.1 mrg 1428 1.1 mrg @table @asis 1429 1.1 mrg @item @emph{Description}: 1430 1.1 mrg @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}. 1431 1.1 mrg 1432 1.1 mrg @item @emph{Standard}: 1433 1.1 mrg Fortran 2008 and later 1434 1.1 mrg 1435 1.1 mrg @item @emph{Class}: 1436 1.1 mrg Elemental function 1437 1.1 mrg 1438 1.1 mrg @item @emph{Syntax}: 1439 1.1 mrg @code{RESULT = ASINH(X)} 1440 1.1 mrg 1441 1.1 mrg @item @emph{Arguments}: 1442 1.1 mrg @multitable @columnfractions .15 .70 1443 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 1444 1.1 mrg @end multitable 1445 1.1 mrg 1446 1.1 mrg @item @emph{Return value}: 1447 1.1 mrg The return value is of the same type and kind as @var{X}. If @var{X} is 1448 1.1 mrg complex, the imaginary part of the result is in radians and lies between 1449 1.1 mrg @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}. 1450 1.1 mrg 1451 1.1 mrg @item @emph{Example}: 1452 1.1 mrg @smallexample 1453 1.1 mrg PROGRAM test_asinh 1454 1.1 mrg REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /) 1455 1.1 mrg WRITE (*,*) ASINH(x) 1456 1.1 mrg END PROGRAM 1457 1.1 mrg @end smallexample 1458 1.1 mrg 1459 1.1 mrg @item @emph{Specific names}: 1460 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 1461 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1462 1.1 mrg @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension. 1463 1.1 mrg @end multitable 1464 1.1 mrg 1465 1.1 mrg @item @emph{See also}: 1466 1.1.1.2 mrg Inverse function: @gol 1467 1.1.1.2 mrg @ref{SINH} 1468 1.1 mrg @end table 1469 1.1 mrg 1470 1.1 mrg 1471 1.1 mrg 1472 1.1 mrg @node ASSOCIATED 1473 1.1 mrg @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 1474 1.1 mrg @fnindex ASSOCIATED 1475 1.1 mrg @cindex pointer, status 1476 1.1 mrg @cindex association status 1477 1.1 mrg 1478 1.1 mrg @table @asis 1479 1.1 mrg @item @emph{Description}: 1480 1.1 mrg @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer 1481 1.1 mrg @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}. 1482 1.1 mrg 1483 1.1 mrg @item @emph{Standard}: 1484 1.1.1.2 mrg Fortran 90 and later 1485 1.1 mrg 1486 1.1 mrg @item @emph{Class}: 1487 1.1 mrg Inquiry function 1488 1.1 mrg 1489 1.1 mrg @item @emph{Syntax}: 1490 1.1 mrg @code{RESULT = ASSOCIATED(POINTER [, TARGET])} 1491 1.1 mrg 1492 1.1 mrg @item @emph{Arguments}: 1493 1.1 mrg @multitable @columnfractions .15 .70 1494 1.1 mrg @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute 1495 1.1 mrg and it can be of any type. 1496 1.1 mrg @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or 1497 1.1 mrg a target. It must have the same type, kind type parameter, and 1498 1.1 mrg array rank as @var{POINTER}. 1499 1.1 mrg @end multitable 1500 1.1 mrg The association status of neither @var{POINTER} nor @var{TARGET} shall be 1501 1.1 mrg undefined. 1502 1.1 mrg 1503 1.1 mrg @item @emph{Return value}: 1504 1.1 mrg @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}. 1505 1.1 mrg There are several cases: 1506 1.1 mrg @table @asis 1507 1.1 mrg @item (A) When the optional @var{TARGET} is not present then 1508 1.1 mrg @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false. 1509 1.1 mrg @item (B) If @var{TARGET} is present and a scalar target, the result is true if 1510 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 1511 1.1 mrg disassociated, the result is false. 1512 1.1 mrg @item (C) If @var{TARGET} is present and an array target, the result is true if 1513 1.1 mrg @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays, 1514 1.1 mrg are arrays whose elements are not zero-sized storage sequences, and 1515 1.1 mrg @var{TARGET} and @var{POINTER} occupy the same storage units in array element 1516 1.1 mrg order. 1517 1.1 mrg As in case(B), the result is false, if @var{POINTER} is disassociated. 1518 1.1 mrg @item (D) If @var{TARGET} is present and an scalar pointer, the result is true 1519 1.1 mrg if @var{TARGET} is associated with @var{POINTER}, the target associated with 1520 1.1 mrg @var{TARGET} are not zero-sized storage sequences and occupy the same storage 1521 1.1 mrg units. 1522 1.1 mrg The result is false, if either @var{TARGET} or @var{POINTER} is disassociated. 1523 1.1 mrg @item (E) If @var{TARGET} is present and an array pointer, the result is true if 1524 1.1 mrg target associated with @var{POINTER} and the target associated with @var{TARGET} 1525 1.1 mrg have the same shape, are not zero-sized arrays, are arrays whose elements are 1526 1.1 mrg not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy 1527 1.1 mrg the same storage units in array element order. 1528 1.1 mrg The result is false, if either @var{TARGET} or @var{POINTER} is disassociated. 1529 1.1 mrg @end table 1530 1.1 mrg 1531 1.1 mrg @item @emph{Example}: 1532 1.1 mrg @smallexample 1533 1.1 mrg program test_associated 1534 1.1 mrg implicit none 1535 1.1 mrg real, target :: tgt(2) = (/1., 2./) 1536 1.1 mrg real, pointer :: ptr(:) 1537 1.1 mrg ptr => tgt 1538 1.1 mrg if (associated(ptr) .eqv. .false.) call abort 1539 1.1 mrg if (associated(ptr,tgt) .eqv. .false.) call abort 1540 1.1 mrg end program test_associated 1541 1.1 mrg @end smallexample 1542 1.1 mrg 1543 1.1 mrg @item @emph{See also}: 1544 1.1 mrg @ref{NULL} 1545 1.1 mrg @end table 1546 1.1 mrg 1547 1.1 mrg 1548 1.1 mrg 1549 1.1 mrg @node ATAN 1550 1.1 mrg @section @code{ATAN} --- Arctangent function 1551 1.1 mrg @fnindex ATAN 1552 1.1 mrg @fnindex DATAN 1553 1.1 mrg @cindex trigonometric function, tangent, inverse 1554 1.1 mrg @cindex tangent, inverse 1555 1.1 mrg 1556 1.1 mrg @table @asis 1557 1.1 mrg @item @emph{Description}: 1558 1.1 mrg @code{ATAN(X)} computes the arctangent of @var{X}. 1559 1.1 mrg 1560 1.1 mrg @item @emph{Standard}: 1561 1.1 mrg Fortran 77 and later, for a complex argument and for two arguments 1562 1.1 mrg Fortran 2008 or later 1563 1.1 mrg 1564 1.1 mrg @item @emph{Class}: 1565 1.1 mrg Elemental function 1566 1.1 mrg 1567 1.1 mrg @item @emph{Syntax}: 1568 1.1 mrg @multitable @columnfractions .80 1569 1.1 mrg @item @code{RESULT = ATAN(X)} 1570 1.1 mrg @item @code{RESULT = ATAN(Y, X)} 1571 1.1 mrg @end multitable 1572 1.1 mrg 1573 1.1 mrg @item @emph{Arguments}: 1574 1.1 mrg @multitable @columnfractions .15 .70 1575 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}; 1576 1.1 mrg if @var{Y} is present, @var{X} shall be REAL. 1577 1.1.1.2 mrg @item @var{Y} @tab The type and kind type parameter shall be the same as @var{X}. 1578 1.1 mrg @end multitable 1579 1.1 mrg 1580 1.1 mrg @item @emph{Return value}: 1581 1.1 mrg The return value is of the same type and kind as @var{X}. 1582 1.1 mrg If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}. 1583 1.1 mrg Otherwise, it the arcus tangent of @var{X}, where the real part of 1584 1.1 mrg the result is in radians and lies in the range 1585 1.1 mrg @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}. 1586 1.1 mrg 1587 1.1 mrg @item @emph{Example}: 1588 1.1 mrg @smallexample 1589 1.1 mrg program test_atan 1590 1.1 mrg real(8) :: x = 2.866_8 1591 1.1 mrg x = atan(x) 1592 1.1 mrg end program test_atan 1593 1.1 mrg @end smallexample 1594 1.1 mrg 1595 1.1 mrg @item @emph{Specific names}: 1596 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 1597 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1598 1.1 mrg @item @code{ATAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 1599 1.1 mrg @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 1600 1.1 mrg @end multitable 1601 1.1 mrg 1602 1.1 mrg @item @emph{See also}: 1603 1.1.1.2 mrg Inverse function: @gol 1604 1.1.1.2 mrg @ref{TAN} @gol 1605 1.1.1.2 mrg Degrees function: @gol 1606 1.1.1.2 mrg @ref{ATAND} 1607 1.1 mrg @end table 1608 1.1 mrg 1609 1.1 mrg 1610 1.1 mrg 1611 1.1 mrg @node ATAND 1612 1.1 mrg @section @code{ATAND} --- Arctangent function, degrees 1613 1.1 mrg @fnindex ATAND 1614 1.1 mrg @fnindex DATAND 1615 1.1 mrg @cindex trigonometric function, tangent, inverse, degrees 1616 1.1 mrg @cindex tangent, inverse, degrees 1617 1.1 mrg 1618 1.1 mrg @table @asis 1619 1.1 mrg @item @emph{Description}: 1620 1.1 mrg @code{ATAND(X)} computes the arctangent of @var{X} in degrees (inverse of 1621 1.1 mrg @ref{TAND}). 1622 1.1 mrg 1623 1.1 mrg This function is for compatibility only and should be avoided in favor of 1624 1.1 mrg standard constructs wherever possible. 1625 1.1 mrg 1626 1.1 mrg @item @emph{Standard}: 1627 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}. 1628 1.1 mrg 1629 1.1 mrg @item @emph{Class}: 1630 1.1 mrg Elemental function 1631 1.1 mrg 1632 1.1 mrg @item @emph{Syntax}: 1633 1.1 mrg @multitable @columnfractions .80 1634 1.1 mrg @item @code{RESULT = ATAND(X)} 1635 1.1 mrg @item @code{RESULT = ATAND(Y, X)} 1636 1.1 mrg @end multitable 1637 1.1 mrg 1638 1.1 mrg @item @emph{Arguments}: 1639 1.1 mrg @multitable @columnfractions .15 .70 1640 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}; 1641 1.1 mrg if @var{Y} is present, @var{X} shall be REAL. 1642 1.1.1.2 mrg @item @var{Y} @tab The type and kind type parameter shall be the same as @var{X}. 1643 1.1 mrg @end multitable 1644 1.1 mrg 1645 1.1 mrg @item @emph{Return value}: 1646 1.1 mrg The return value is of the same type and kind as @var{X}. 1647 1.1 mrg If @var{Y} is present, the result is identical to @code{ATAND2(Y,X)}. 1648 1.1 mrg Otherwise, it is the arcus tangent of @var{X}, where the real part of 1649 1.1 mrg the result is in degrees and lies in the range 1650 1.1 mrg @math{-90 \leq \Re \atand(x) \leq 90}. 1651 1.1 mrg 1652 1.1 mrg @item @emph{Example}: 1653 1.1 mrg @smallexample 1654 1.1 mrg program test_atand 1655 1.1 mrg real(8) :: x = 2.866_8 1656 1.1 mrg x = atand(x) 1657 1.1 mrg end program test_atand 1658 1.1 mrg @end smallexample 1659 1.1 mrg 1660 1.1 mrg @item @emph{Specific names}: 1661 1.1.1.3 mrg @multitable @columnfractions .23 .23 .20 .30 1662 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1663 1.1.1.2 mrg @item @code{ATAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 1664 1.1.1.2 mrg @item @code{DATAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 1665 1.1 mrg @end multitable 1666 1.1 mrg 1667 1.1 mrg @item @emph{See also}: 1668 1.1.1.2 mrg Inverse function: @gol 1669 1.1.1.2 mrg @ref{TAND} @gol 1670 1.1.1.2 mrg Radians function: @gol 1671 1.1.1.2 mrg @ref{ATAN} 1672 1.1 mrg @end table 1673 1.1 mrg 1674 1.1 mrg 1675 1.1 mrg 1676 1.1 mrg @node ATAN2 1677 1.1 mrg @section @code{ATAN2} --- Arctangent function 1678 1.1 mrg @fnindex ATAN2 1679 1.1 mrg @fnindex DATAN2 1680 1.1 mrg @cindex trigonometric function, tangent, inverse 1681 1.1 mrg @cindex tangent, inverse 1682 1.1 mrg 1683 1.1 mrg @table @asis 1684 1.1 mrg @item @emph{Description}: 1685 1.1 mrg @code{ATAN2(Y, X)} computes the principal value of the argument 1686 1.1 mrg function of the complex number @math{X + i Y}. This function can 1687 1.1 mrg be used to transform from Cartesian into polar coordinates and 1688 1.1 mrg allows to determine the angle in the correct quadrant. 1689 1.1 mrg 1690 1.1 mrg @item @emph{Standard}: 1691 1.1 mrg Fortran 77 and later 1692 1.1 mrg 1693 1.1 mrg @item @emph{Class}: 1694 1.1 mrg Elemental function 1695 1.1 mrg 1696 1.1 mrg @item @emph{Syntax}: 1697 1.1 mrg @code{RESULT = ATAN2(Y, X)} 1698 1.1 mrg 1699 1.1 mrg @item @emph{Arguments}: 1700 1.1 mrg @multitable @columnfractions .15 .70 1701 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}. 1702 1.1 mrg @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}. 1703 1.1 mrg If @var{Y} is zero, then @var{X} must be nonzero. 1704 1.1 mrg @end multitable 1705 1.1 mrg 1706 1.1 mrg @item @emph{Return value}: 1707 1.1 mrg The return value has the same type and kind type parameter as @var{Y}. It 1708 1.1 mrg is the principal value of the complex number @math{X + i Y}. If @var{X} 1709 1.1 mrg is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}. 1710 1.1 mrg The sign is positive if @var{Y} is positive. If @var{Y} is zero, then 1711 1.1 mrg the return value is zero if @var{X} is strictly positive, @math{\pi} if 1712 1.1 mrg @var{X} is negative and @var{Y} is positive zero (or the processor does 1713 1.1 mrg not handle signed zeros), and @math{-\pi} if @var{X} is negative and 1714 1.1 mrg @var{Y} is negative zero. Finally, if @var{X} is zero, then the 1715 1.1 mrg magnitude of the result is @math{\pi/2}. 1716 1.1 mrg 1717 1.1 mrg @item @emph{Example}: 1718 1.1 mrg @smallexample 1719 1.1 mrg program test_atan2 1720 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4 1721 1.1 mrg x = atan2(y,x) 1722 1.1 mrg end program test_atan2 1723 1.1 mrg @end smallexample 1724 1.1 mrg 1725 1.1 mrg @item @emph{Specific names}: 1726 1.1.1.3 mrg @multitable @columnfractions .22 .22 .20 .32 1727 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1728 1.1 mrg @item @code{ATAN2(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later 1729 1.1 mrg @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later 1730 1.1 mrg @end multitable 1731 1.1 mrg 1732 1.1 mrg @item @emph{See also}: 1733 1.1.1.2 mrg Alias: @gol 1734 1.1.1.2 mrg @ref{ATAN} @gol 1735 1.1.1.2 mrg Degrees function: @gol 1736 1.1.1.2 mrg @ref{ATAN2D} 1737 1.1 mrg @end table 1738 1.1 mrg 1739 1.1 mrg 1740 1.1 mrg 1741 1.1 mrg @node ATAN2D 1742 1.1 mrg @section @code{ATAN2D} --- Arctangent function, degrees 1743 1.1 mrg @fnindex ATAN2D 1744 1.1 mrg @fnindex DATAN2D 1745 1.1 mrg @cindex trigonometric function, tangent, inverse, degrees 1746 1.1 mrg @cindex tangent, inverse, degrees 1747 1.1 mrg 1748 1.1 mrg @table @asis 1749 1.1 mrg @item @emph{Description}: 1750 1.1 mrg @code{ATAN2D(Y, X)} computes the principal value of the argument 1751 1.1 mrg function of the complex number @math{X + i Y} in degrees. This function can 1752 1.1 mrg be used to transform from Cartesian into polar coordinates and 1753 1.1 mrg allows to determine the angle in the correct quadrant. 1754 1.1 mrg 1755 1.1 mrg This function is for compatibility only and should be avoided in favor of 1756 1.1 mrg standard constructs wherever possible. 1757 1.1 mrg 1758 1.1 mrg @item @emph{Standard}: 1759 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}. 1760 1.1 mrg 1761 1.1 mrg @item @emph{Class}: 1762 1.1 mrg Elemental function 1763 1.1 mrg 1764 1.1 mrg @item @emph{Syntax}: 1765 1.1 mrg @code{RESULT = ATAN2D(Y, X)} 1766 1.1 mrg 1767 1.1 mrg @item @emph{Arguments}: 1768 1.1 mrg @multitable @columnfractions .15 .70 1769 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}. 1770 1.1 mrg @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}. 1771 1.1 mrg If @var{Y} is zero, then @var{X} must be nonzero. 1772 1.1 mrg @end multitable 1773 1.1 mrg 1774 1.1 mrg @item @emph{Return value}: 1775 1.1 mrg The return value has the same type and kind type parameter as @var{Y}. It 1776 1.1 mrg is the principal value of the complex number @math{X + i Y}. If @var{X} 1777 1.1 mrg is nonzero, then it lies in the range @math{-180 \le \atan (x) \leq 180}. 1778 1.1 mrg The sign is positive if @var{Y} is positive. If @var{Y} is zero, then 1779 1.1 mrg the return value is zero if @var{X} is strictly positive, @math{180} if 1780 1.1 mrg @var{X} is negative and @var{Y} is positive zero (or the processor does 1781 1.1 mrg not handle signed zeros), and @math{-180} if @var{X} is negative and 1782 1.1 mrg @var{Y} is negative zero. Finally, if @var{X} is zero, then the 1783 1.1 mrg magnitude of the result is @math{90}. 1784 1.1 mrg 1785 1.1 mrg @item @emph{Example}: 1786 1.1 mrg @smallexample 1787 1.1 mrg program test_atan2d 1788 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4 1789 1.1 mrg x = atan2d(y,x) 1790 1.1 mrg end program test_atan2d 1791 1.1 mrg @end smallexample 1792 1.1 mrg 1793 1.1 mrg @item @emph{Specific names}: 1794 1.1.1.3 mrg @multitable @columnfractions .23 .23 .20 .30 1795 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1796 1.1.1.2 mrg @item @code{ATAN2D(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab GNU extension 1797 1.1.1.2 mrg @item @code{DATAN2D(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab GNU extension 1798 1.1 mrg @end multitable 1799 1.1 mrg 1800 1.1 mrg @item @emph{See also}: 1801 1.1.1.2 mrg Alias: @gol 1802 1.1.1.2 mrg @ref{ATAND} @gol 1803 1.1.1.2 mrg Radians function: @gol 1804 1.1.1.2 mrg @ref{ATAN2} 1805 1.1 mrg @end table 1806 1.1 mrg 1807 1.1 mrg 1808 1.1 mrg 1809 1.1 mrg @node ATANH 1810 1.1 mrg @section @code{ATANH} --- Inverse hyperbolic tangent function 1811 1.1 mrg @fnindex ATANH 1812 1.1 mrg @fnindex DATANH 1813 1.1 mrg @cindex area hyperbolic tangent 1814 1.1 mrg @cindex inverse hyperbolic tangent 1815 1.1 mrg @cindex hyperbolic function, tangent, inverse 1816 1.1 mrg @cindex tangent, hyperbolic, inverse 1817 1.1 mrg 1818 1.1 mrg @table @asis 1819 1.1 mrg @item @emph{Description}: 1820 1.1 mrg @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}. 1821 1.1 mrg 1822 1.1 mrg @item @emph{Standard}: 1823 1.1 mrg Fortran 2008 and later 1824 1.1 mrg 1825 1.1 mrg @item @emph{Class}: 1826 1.1 mrg Elemental function 1827 1.1 mrg 1828 1.1 mrg @item @emph{Syntax}: 1829 1.1 mrg @code{RESULT = ATANH(X)} 1830 1.1 mrg 1831 1.1 mrg @item @emph{Arguments}: 1832 1.1 mrg @multitable @columnfractions .15 .70 1833 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 1834 1.1 mrg @end multitable 1835 1.1 mrg 1836 1.1 mrg @item @emph{Return value}: 1837 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is 1838 1.1 mrg complex, the imaginary part of the result is in radians and lies between 1839 1.1 mrg @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}. 1840 1.1 mrg 1841 1.1 mrg @item @emph{Example}: 1842 1.1 mrg @smallexample 1843 1.1 mrg PROGRAM test_atanh 1844 1.1 mrg REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /) 1845 1.1 mrg WRITE (*,*) ATANH(x) 1846 1.1 mrg END PROGRAM 1847 1.1 mrg @end smallexample 1848 1.1 mrg 1849 1.1 mrg @item @emph{Specific names}: 1850 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 1851 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 1852 1.1 mrg @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 1853 1.1 mrg @end multitable 1854 1.1 mrg 1855 1.1 mrg @item @emph{See also}: 1856 1.1.1.2 mrg Inverse function: @gol 1857 1.1.1.2 mrg @ref{TANH} 1858 1.1 mrg @end table 1859 1.1 mrg 1860 1.1 mrg 1861 1.1 mrg 1862 1.1 mrg @node ATOMIC_ADD 1863 1.1 mrg @section @code{ATOMIC_ADD} --- Atomic ADD operation 1864 1.1 mrg @fnindex ATOMIC_ADD 1865 1.1 mrg @cindex Atomic subroutine, add 1866 1.1 mrg 1867 1.1 mrg @table @asis 1868 1.1 mrg @item @emph{Description}: 1869 1.1.1.3 mrg @code{ATOMIC_ADD(ATOM, VALUE)} atomically adds the value of @var{VALUE} to the 1870 1.1 mrg variable @var{ATOM}. When @var{STAT} is present and the invocation was 1871 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation 1872 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed 1873 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of 1874 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has 1875 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}. 1876 1.1 mrg 1877 1.1 mrg @item @emph{Standard}: 1878 1.1 mrg TS 18508 or later 1879 1.1 mrg 1880 1.1 mrg @item @emph{Class}: 1881 1.1 mrg Atomic subroutine 1882 1.1 mrg 1883 1.1 mrg @item @emph{Syntax}: 1884 1.1 mrg @code{CALL ATOMIC_ADD (ATOM, VALUE [, STAT])} 1885 1.1 mrg 1886 1.1 mrg @item @emph{Arguments}: 1887 1.1 mrg @multitable @columnfractions .15 .70 1888 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer 1889 1.1 mrg type with @code{ATOMIC_INT_KIND} kind. 1890 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 1891 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 1892 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 1893 1.1 mrg @end multitable 1894 1.1 mrg 1895 1.1 mrg @item @emph{Example}: 1896 1.1 mrg @smallexample 1897 1.1 mrg program atomic 1898 1.1 mrg use iso_fortran_env 1899 1.1 mrg integer(atomic_int_kind) :: atom[*] 1900 1.1 mrg call atomic_add (atom[1], this_image()) 1901 1.1 mrg end program atomic 1902 1.1 mrg @end smallexample 1903 1.1 mrg 1904 1.1 mrg @item @emph{See also}: 1905 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 1906 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol 1907 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 1908 1.1.1.2 mrg @ref{ATOMIC_AND}, @gol 1909 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol 1910 1.1.1.2 mrg @ref{ATOMIC_XOR} 1911 1.1 mrg @end table 1912 1.1 mrg 1913 1.1 mrg 1914 1.1 mrg 1915 1.1 mrg 1916 1.1 mrg @node ATOMIC_AND 1917 1.1 mrg @section @code{ATOMIC_AND} --- Atomic bitwise AND operation 1918 1.1 mrg @fnindex ATOMIC_AND 1919 1.1 mrg @cindex Atomic subroutine, AND 1920 1.1 mrg 1921 1.1 mrg @table @asis 1922 1.1 mrg @item @emph{Description}: 1923 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise 1924 1.1 mrg AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present 1925 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present 1926 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular, 1927 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the 1928 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote 1929 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}. 1930 1.1 mrg 1931 1.1 mrg @item @emph{Standard}: 1932 1.1 mrg TS 18508 or later 1933 1.1 mrg 1934 1.1 mrg @item @emph{Class}: 1935 1.1 mrg Atomic subroutine 1936 1.1 mrg 1937 1.1 mrg @item @emph{Syntax}: 1938 1.1 mrg @code{CALL ATOMIC_AND (ATOM, VALUE [, STAT])} 1939 1.1 mrg 1940 1.1 mrg @item @emph{Arguments}: 1941 1.1 mrg @multitable @columnfractions .15 .70 1942 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer 1943 1.1 mrg type with @code{ATOMIC_INT_KIND} kind. 1944 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 1945 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 1946 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 1947 1.1 mrg @end multitable 1948 1.1 mrg 1949 1.1 mrg @item @emph{Example}: 1950 1.1 mrg @smallexample 1951 1.1 mrg program atomic 1952 1.1 mrg use iso_fortran_env 1953 1.1 mrg integer(atomic_int_kind) :: atom[*] 1954 1.1 mrg call atomic_and (atom[1], int(b'10100011101')) 1955 1.1 mrg end program atomic 1956 1.1 mrg @end smallexample 1957 1.1 mrg 1958 1.1 mrg @item @emph{See also}: 1959 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 1960 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol 1961 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 1962 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol 1963 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol 1964 1.1.1.2 mrg @ref{ATOMIC_XOR} 1965 1.1 mrg @end table 1966 1.1 mrg 1967 1.1 mrg 1968 1.1 mrg 1969 1.1 mrg @node ATOMIC_CAS 1970 1.1 mrg @section @code{ATOMIC_CAS} --- Atomic compare and swap 1971 1.1 mrg @fnindex ATOMIC_DEFINE 1972 1.1 mrg @cindex Atomic subroutine, compare and swap 1973 1.1 mrg 1974 1.1 mrg @table @asis 1975 1.1 mrg @item @emph{Description}: 1976 1.1 mrg @code{ATOMIC_CAS} compares the variable @var{ATOM} with the value of 1977 1.1 mrg @var{COMPARE}; if the value is the same, @var{ATOM} is set to the value 1978 1.1 mrg of @var{NEW}. Additionally, @var{OLD} is set to the value of @var{ATOM} 1979 1.1 mrg that was used for the comparison. When @var{STAT} is present and the invocation 1980 1.1 mrg was successful, it is assigned the value 0. If it is present and the invocation 1981 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed 1982 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of 1983 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has 1984 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}. 1985 1.1 mrg 1986 1.1 mrg @item @emph{Standard}: 1987 1.1 mrg TS 18508 or later 1988 1.1 mrg 1989 1.1 mrg @item @emph{Class}: 1990 1.1 mrg Atomic subroutine 1991 1.1 mrg 1992 1.1 mrg @item @emph{Syntax}: 1993 1.1 mrg @code{CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])} 1994 1.1 mrg 1995 1.1 mrg @item @emph{Arguments}: 1996 1.1 mrg @multitable @columnfractions .15 .70 1997 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer 1998 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with 1999 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind. 2000 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. 2001 1.1 mrg @item @var{COMPARE} @tab Scalar variable of the same type and kind as 2002 1.1 mrg @var{ATOM}. 2003 1.1 mrg @item @var{NEW} @tab Scalar variable of the same type as @var{ATOM}. If kind 2004 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2005 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2006 1.1 mrg @end multitable 2007 1.1 mrg 2008 1.1 mrg @item @emph{Example}: 2009 1.1 mrg @smallexample 2010 1.1 mrg program atomic 2011 1.1 mrg use iso_fortran_env 2012 1.1 mrg logical(atomic_logical_kind) :: atom[*], prev 2013 1.1 mrg call atomic_cas (atom[1], prev, .false., .true.)) 2014 1.1 mrg end program atomic 2015 1.1 mrg @end smallexample 2016 1.1 mrg 2017 1.1 mrg @item @emph{See also}: 2018 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 2019 1.1.1.2 mrg @ref{ATOMIC_REF}, @gol 2020 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV} 2021 1.1 mrg @end table 2022 1.1 mrg 2023 1.1 mrg 2024 1.1 mrg 2025 1.1 mrg @node ATOMIC_DEFINE 2026 1.1 mrg @section @code{ATOMIC_DEFINE} --- Setting a variable atomically 2027 1.1 mrg @fnindex ATOMIC_DEFINE 2028 1.1 mrg @cindex Atomic subroutine, define 2029 1.1 mrg 2030 1.1 mrg @table @asis 2031 1.1 mrg @item @emph{Description}: 2032 1.1 mrg @code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value 2033 1.1 mrg @var{VALUE} atomically. When @var{STAT} is present and the invocation was 2034 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation 2035 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed 2036 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of 2037 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has 2038 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}. 2039 1.1 mrg 2040 1.1 mrg @item @emph{Standard}: 2041 1.1 mrg Fortran 2008 and later; with @var{STAT}, TS 18508 or later 2042 1.1 mrg 2043 1.1 mrg @item @emph{Class}: 2044 1.1 mrg Atomic subroutine 2045 1.1 mrg 2046 1.1 mrg @item @emph{Syntax}: 2047 1.1 mrg @code{CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT])} 2048 1.1 mrg 2049 1.1 mrg @item @emph{Arguments}: 2050 1.1 mrg @multitable @columnfractions .15 .70 2051 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer 2052 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with 2053 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind. 2054 1.1 mrg 2055 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 2056 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2057 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2058 1.1 mrg @end multitable 2059 1.1 mrg 2060 1.1 mrg @item @emph{Example}: 2061 1.1 mrg @smallexample 2062 1.1 mrg program atomic 2063 1.1 mrg use iso_fortran_env 2064 1.1 mrg integer(atomic_int_kind) :: atom[*] 2065 1.1 mrg call atomic_define (atom[1], this_image()) 2066 1.1 mrg end program atomic 2067 1.1 mrg @end smallexample 2068 1.1 mrg 2069 1.1 mrg @item @emph{See also}: 2070 1.1.1.2 mrg @ref{ATOMIC_REF}, @gol 2071 1.1.1.2 mrg @ref{ATOMIC_CAS}, @gol 2072 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 2073 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol 2074 1.1.1.2 mrg @ref{ATOMIC_AND}, @gol 2075 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol 2076 1.1.1.2 mrg @ref{ATOMIC_XOR} 2077 1.1 mrg @end table 2078 1.1 mrg 2079 1.1 mrg 2080 1.1 mrg 2081 1.1 mrg @node ATOMIC_FETCH_ADD 2082 1.1 mrg @section @code{ATOMIC_FETCH_ADD} --- Atomic ADD operation with prior fetch 2083 1.1 mrg @fnindex ATOMIC_FETCH_ADD 2084 1.1 mrg @cindex Atomic subroutine, ADD with fetch 2085 1.1 mrg 2086 1.1 mrg @table @asis 2087 1.1 mrg @item @emph{Description}: 2088 1.1 mrg @code{ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)} atomically stores the value of 2089 1.1.1.3 mrg @var{ATOM} in @var{OLD} and adds the value of @var{VALUE} to the 2090 1.1 mrg variable @var{ATOM}. When @var{STAT} is present and the invocation was 2091 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation 2092 1.1 mrg has failed, it is assigned a positive value; in particular, for a coindexed 2093 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of 2094 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has 2095 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}. 2096 1.1 mrg 2097 1.1 mrg @item @emph{Standard}: 2098 1.1 mrg TS 18508 or later 2099 1.1 mrg 2100 1.1 mrg @item @emph{Class}: 2101 1.1 mrg Atomic subroutine 2102 1.1 mrg 2103 1.1 mrg @item @emph{Syntax}: 2104 1.1 mrg @code{CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT])} 2105 1.1 mrg 2106 1.1 mrg @item @emph{Arguments}: 2107 1.1 mrg @multitable @columnfractions .15 .70 2108 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer 2109 1.1 mrg type with @code{ATOMIC_INT_KIND} kind. 2110 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind. 2111 1.1 mrg 2112 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 2113 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2114 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. 2115 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2116 1.1 mrg @end multitable 2117 1.1 mrg 2118 1.1 mrg @item @emph{Example}: 2119 1.1 mrg @smallexample 2120 1.1 mrg program atomic 2121 1.1 mrg use iso_fortran_env 2122 1.1 mrg integer(atomic_int_kind) :: atom[*], old 2123 1.1 mrg call atomic_add (atom[1], this_image(), old) 2124 1.1 mrg end program atomic 2125 1.1 mrg @end smallexample 2126 1.1 mrg 2127 1.1 mrg @item @emph{See also}: 2128 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 2129 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol 2130 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 2131 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol 2132 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}, @gol 2133 1.1.1.2 mrg @ref{ATOMIC_FETCH_XOR} 2134 1.1 mrg @end table 2135 1.1 mrg 2136 1.1 mrg 2137 1.1 mrg 2138 1.1 mrg @node ATOMIC_FETCH_AND 2139 1.1 mrg @section @code{ATOMIC_FETCH_AND} --- Atomic bitwise AND operation with prior fetch 2140 1.1 mrg @fnindex ATOMIC_FETCH_AND 2141 1.1 mrg @cindex Atomic subroutine, AND with fetch 2142 1.1 mrg 2143 1.1 mrg @table @asis 2144 1.1 mrg @item @emph{Description}: 2145 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically stores the value of @var{ATOM} in 2146 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise AND between the values of 2147 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was 2148 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has 2149 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed 2150 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of 2151 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has 2152 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}. 2153 1.1 mrg 2154 1.1 mrg @item @emph{Standard}: 2155 1.1 mrg TS 18508 or later 2156 1.1 mrg 2157 1.1 mrg @item @emph{Class}: 2158 1.1 mrg Atomic subroutine 2159 1.1 mrg 2160 1.1 mrg @item @emph{Syntax}: 2161 1.1 mrg @code{CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])} 2162 1.1 mrg 2163 1.1 mrg @item @emph{Arguments}: 2164 1.1 mrg @multitable @columnfractions .15 .70 2165 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer 2166 1.1 mrg type with @code{ATOMIC_INT_KIND} kind. 2167 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 2168 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2169 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. 2170 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2171 1.1 mrg @end multitable 2172 1.1 mrg 2173 1.1 mrg @item @emph{Example}: 2174 1.1 mrg @smallexample 2175 1.1 mrg program atomic 2176 1.1 mrg use iso_fortran_env 2177 1.1 mrg integer(atomic_int_kind) :: atom[*], old 2178 1.1 mrg call atomic_fetch_and (atom[1], int(b'10100011101'), old) 2179 1.1 mrg end program atomic 2180 1.1 mrg @end smallexample 2181 1.1 mrg 2182 1.1 mrg @item @emph{See also}: 2183 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 2184 1.1.1.2 mrg @ref{ATOMIC_AND}, @gol 2185 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 2186 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol 2187 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}, @gol 2188 1.1.1.2 mrg @ref{ATOMIC_FETCH_XOR} 2189 1.1 mrg @end table 2190 1.1 mrg 2191 1.1 mrg 2192 1.1 mrg 2193 1.1 mrg @node ATOMIC_FETCH_OR 2194 1.1 mrg @section @code{ATOMIC_FETCH_OR} --- Atomic bitwise OR operation with prior fetch 2195 1.1 mrg @fnindex ATOMIC_FETCH_OR 2196 1.1 mrg @cindex Atomic subroutine, OR with fetch 2197 1.1 mrg 2198 1.1 mrg @table @asis 2199 1.1 mrg @item @emph{Description}: 2200 1.1 mrg @code{ATOMIC_OR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in 2201 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise OR between the values of 2202 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was 2203 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has 2204 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed 2205 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of 2206 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has 2207 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}. 2208 1.1 mrg 2209 1.1 mrg @item @emph{Standard}: 2210 1.1 mrg TS 18508 or later 2211 1.1 mrg 2212 1.1 mrg @item @emph{Class}: 2213 1.1 mrg Atomic subroutine 2214 1.1 mrg 2215 1.1 mrg @item @emph{Syntax}: 2216 1.1 mrg @code{CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])} 2217 1.1 mrg 2218 1.1 mrg @item @emph{Arguments}: 2219 1.1 mrg @multitable @columnfractions .15 .70 2220 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer 2221 1.1 mrg type with @code{ATOMIC_INT_KIND} kind. 2222 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 2223 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2224 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. 2225 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2226 1.1 mrg @end multitable 2227 1.1 mrg 2228 1.1 mrg @item @emph{Example}: 2229 1.1 mrg @smallexample 2230 1.1 mrg program atomic 2231 1.1 mrg use iso_fortran_env 2232 1.1 mrg integer(atomic_int_kind) :: atom[*], old 2233 1.1 mrg call atomic_fetch_or (atom[1], int(b'10100011101'), old) 2234 1.1 mrg end program atomic 2235 1.1 mrg @end smallexample 2236 1.1 mrg 2237 1.1 mrg @item @emph{See also}: 2238 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 2239 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol 2240 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 2241 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol 2242 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol 2243 1.1.1.2 mrg @ref{ATOMIC_FETCH_XOR} 2244 1.1 mrg @end table 2245 1.1 mrg 2246 1.1 mrg 2247 1.1 mrg 2248 1.1 mrg @node ATOMIC_FETCH_XOR 2249 1.1 mrg @section @code{ATOMIC_FETCH_XOR} --- Atomic bitwise XOR operation with prior fetch 2250 1.1 mrg @fnindex ATOMIC_FETCH_XOR 2251 1.1 mrg @cindex Atomic subroutine, XOR with fetch 2252 1.1 mrg 2253 1.1 mrg @table @asis 2254 1.1 mrg @item @emph{Description}: 2255 1.1 mrg @code{ATOMIC_XOR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in 2256 1.1 mrg @var{OLD} and defines @var{ATOM} with the bitwise XOR between the values of 2257 1.1 mrg @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was 2258 1.1 mrg successful, it is assigned the value 0. If it is present and the invocation has 2259 1.1 mrg failed, it is assigned a positive value; in particular, for a coindexed 2260 1.1 mrg @var{ATOM}, if the remote image has stopped, it is assigned the value of 2261 1.1 mrg @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has 2262 1.1 mrg failed, the value @code{STAT_FAILED_IMAGE}. 2263 1.1 mrg 2264 1.1 mrg @item @emph{Standard}: 2265 1.1 mrg TS 18508 or later 2266 1.1 mrg 2267 1.1 mrg @item @emph{Class}: 2268 1.1 mrg Atomic subroutine 2269 1.1 mrg 2270 1.1 mrg @item @emph{Syntax}: 2271 1.1 mrg @code{CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])} 2272 1.1 mrg 2273 1.1 mrg @item @emph{Arguments}: 2274 1.1 mrg @multitable @columnfractions .15 .70 2275 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer 2276 1.1 mrg type with @code{ATOMIC_INT_KIND} kind. 2277 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 2278 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2279 1.1 mrg @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}. 2280 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2281 1.1 mrg @end multitable 2282 1.1 mrg 2283 1.1 mrg @item @emph{Example}: 2284 1.1 mrg @smallexample 2285 1.1 mrg program atomic 2286 1.1 mrg use iso_fortran_env 2287 1.1 mrg integer(atomic_int_kind) :: atom[*], old 2288 1.1 mrg call atomic_fetch_xor (atom[1], int(b'10100011101'), old) 2289 1.1 mrg end program atomic 2290 1.1 mrg @end smallexample 2291 1.1 mrg 2292 1.1 mrg @item @emph{See also}: 2293 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 2294 1.1.1.2 mrg @ref{ATOMIC_XOR}, @gol 2295 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 2296 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol 2297 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol 2298 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR} 2299 1.1 mrg @end table 2300 1.1 mrg 2301 1.1 mrg 2302 1.1 mrg 2303 1.1 mrg @node ATOMIC_OR 2304 1.1 mrg @section @code{ATOMIC_OR} --- Atomic bitwise OR operation 2305 1.1 mrg @fnindex ATOMIC_OR 2306 1.1 mrg @cindex Atomic subroutine, OR 2307 1.1 mrg 2308 1.1 mrg @table @asis 2309 1.1 mrg @item @emph{Description}: 2310 1.1 mrg @code{ATOMIC_OR(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise 2311 1.1 mrg AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present 2312 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present 2313 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular, 2314 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the 2315 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote 2316 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}. 2317 1.1 mrg 2318 1.1 mrg @item @emph{Standard}: 2319 1.1 mrg TS 18508 or later 2320 1.1 mrg 2321 1.1 mrg @item @emph{Class}: 2322 1.1 mrg Atomic subroutine 2323 1.1 mrg 2324 1.1 mrg @item @emph{Syntax}: 2325 1.1 mrg @code{CALL ATOMIC_OR (ATOM, VALUE [, STAT])} 2326 1.1 mrg 2327 1.1 mrg @item @emph{Arguments}: 2328 1.1 mrg @multitable @columnfractions .15 .70 2329 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer 2330 1.1 mrg type with @code{ATOMIC_INT_KIND} kind. 2331 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 2332 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2333 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2334 1.1 mrg @end multitable 2335 1.1 mrg 2336 1.1 mrg @item @emph{Example}: 2337 1.1 mrg @smallexample 2338 1.1 mrg program atomic 2339 1.1 mrg use iso_fortran_env 2340 1.1 mrg integer(atomic_int_kind) :: atom[*] 2341 1.1 mrg call atomic_or (atom[1], int(b'10100011101')) 2342 1.1 mrg end program atomic 2343 1.1 mrg @end smallexample 2344 1.1 mrg 2345 1.1 mrg @item @emph{See also}: 2346 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 2347 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}, @gol 2348 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 2349 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol 2350 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol 2351 1.1.1.2 mrg @ref{ATOMIC_XOR} 2352 1.1 mrg @end table 2353 1.1 mrg 2354 1.1 mrg 2355 1.1 mrg 2356 1.1 mrg @node ATOMIC_REF 2357 1.1 mrg @section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically 2358 1.1 mrg @fnindex ATOMIC_REF 2359 1.1 mrg @cindex Atomic subroutine, reference 2360 1.1 mrg 2361 1.1 mrg @table @asis 2362 1.1 mrg @item @emph{Description}: 2363 1.1 mrg @code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the 2364 1.1 mrg variable @var{ATOM} to @var{VALUE}. When @var{STAT} is present and the 2365 1.1 mrg invocation was successful, it is assigned the value 0. If it is present and the 2366 1.1 mrg invocation has failed, it is assigned a positive value; in particular, for a 2367 1.1 mrg coindexed @var{ATOM}, if the remote image has stopped, it is assigned the value 2368 1.1 mrg of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image 2369 1.1 mrg has failed, the value @code{STAT_FAILED_IMAGE}. 2370 1.1 mrg 2371 1.1 mrg 2372 1.1 mrg @item @emph{Standard}: 2373 1.1 mrg Fortran 2008 and later; with @var{STAT}, TS 18508 or later 2374 1.1 mrg 2375 1.1 mrg @item @emph{Class}: 2376 1.1 mrg Atomic subroutine 2377 1.1 mrg 2378 1.1 mrg @item @emph{Syntax}: 2379 1.1 mrg @code{CALL ATOMIC_REF(VALUE, ATOM [, STAT])} 2380 1.1 mrg 2381 1.1 mrg @item @emph{Arguments}: 2382 1.1 mrg @multitable @columnfractions .15 .70 2383 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 2384 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2385 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer 2386 1.1 mrg type with @code{ATOMIC_INT_KIND} kind or logical type with 2387 1.1 mrg @code{ATOMIC_LOGICAL_KIND} kind. 2388 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2389 1.1 mrg @end multitable 2390 1.1 mrg 2391 1.1 mrg @item @emph{Example}: 2392 1.1 mrg @smallexample 2393 1.1 mrg program atomic 2394 1.1 mrg use iso_fortran_env 2395 1.1 mrg logical(atomic_logical_kind) :: atom[*] 2396 1.1 mrg logical :: val 2397 1.1 mrg call atomic_ref (atom, .false.) 2398 1.1 mrg ! ... 2399 1.1 mrg call atomic_ref (atom, val) 2400 1.1 mrg if (val) then 2401 1.1 mrg print *, "Obtained" 2402 1.1 mrg end if 2403 1.1 mrg end program atomic 2404 1.1 mrg @end smallexample 2405 1.1 mrg 2406 1.1 mrg @item @emph{See also}: 2407 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 2408 1.1.1.2 mrg @ref{ATOMIC_CAS}, @gol 2409 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 2410 1.1.1.2 mrg @ref{ATOMIC_FETCH_ADD}, @gol 2411 1.1.1.2 mrg @ref{ATOMIC_FETCH_AND}, @gol 2412 1.1.1.2 mrg @ref{ATOMIC_FETCH_OR}, @gol 2413 1.1 mrg @ref{ATOMIC_FETCH_XOR} 2414 1.1 mrg @end table 2415 1.1 mrg 2416 1.1 mrg 2417 1.1 mrg @node ATOMIC_XOR 2418 1.1 mrg @section @code{ATOMIC_XOR} --- Atomic bitwise OR operation 2419 1.1 mrg @fnindex ATOMIC_XOR 2420 1.1 mrg @cindex Atomic subroutine, XOR 2421 1.1 mrg 2422 1.1 mrg @table @asis 2423 1.1 mrg @item @emph{Description}: 2424 1.1 mrg @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise 2425 1.1 mrg XOR between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present 2426 1.1 mrg and the invocation was successful, it is assigned the value 0. If it is present 2427 1.1 mrg and the invocation has failed, it is assigned a positive value; in particular, 2428 1.1 mrg for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the 2429 1.1 mrg value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote 2430 1.1 mrg image has failed, the value @code{STAT_FAILED_IMAGE}. 2431 1.1 mrg 2432 1.1 mrg @item @emph{Standard}: 2433 1.1 mrg TS 18508 or later 2434 1.1 mrg 2435 1.1 mrg @item @emph{Class}: 2436 1.1 mrg Atomic subroutine 2437 1.1 mrg 2438 1.1 mrg @item @emph{Syntax}: 2439 1.1 mrg @code{CALL ATOMIC_XOR (ATOM, VALUE [, STAT])} 2440 1.1 mrg 2441 1.1 mrg @item @emph{Arguments}: 2442 1.1 mrg @multitable @columnfractions .15 .70 2443 1.1 mrg @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer 2444 1.1 mrg type with @code{ATOMIC_INT_KIND} kind. 2445 1.1 mrg @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind 2446 1.1 mrg is different, the value is converted to the kind of @var{ATOM}. 2447 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 2448 1.1 mrg @end multitable 2449 1.1 mrg 2450 1.1 mrg @item @emph{Example}: 2451 1.1 mrg @smallexample 2452 1.1 mrg program atomic 2453 1.1 mrg use iso_fortran_env 2454 1.1 mrg integer(atomic_int_kind) :: atom[*] 2455 1.1 mrg call atomic_xor (atom[1], int(b'10100011101')) 2456 1.1 mrg end program atomic 2457 1.1 mrg @end smallexample 2458 1.1 mrg 2459 1.1 mrg @item @emph{See also}: 2460 1.1.1.2 mrg @ref{ATOMIC_DEFINE}, @gol 2461 1.1.1.2 mrg @ref{ATOMIC_FETCH_XOR}, @gol 2462 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV}, @gol 2463 1.1.1.2 mrg @ref{ATOMIC_ADD}, @gol 2464 1.1.1.2 mrg @ref{ATOMIC_OR}, @gol 2465 1.1.1.2 mrg @ref{ATOMIC_XOR} 2466 1.1 mrg @end table 2467 1.1 mrg 2468 1.1 mrg 2469 1.1 mrg @node BACKTRACE 2470 1.1 mrg @section @code{BACKTRACE} --- Show a backtrace 2471 1.1 mrg @fnindex BACKTRACE 2472 1.1 mrg @cindex backtrace 2473 1.1 mrg 2474 1.1 mrg @table @asis 2475 1.1 mrg @item @emph{Description}: 2476 1.1 mrg @code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program 2477 1.1 mrg execution continues normally afterwards. The backtrace information is printed 2478 1.1 mrg to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}. 2479 1.1 mrg 2480 1.1 mrg @item @emph{Standard}: 2481 1.1.1.2 mrg GNU extension 2482 1.1 mrg 2483 1.1 mrg @item @emph{Class}: 2484 1.1 mrg Subroutine 2485 1.1 mrg 2486 1.1 mrg @item @emph{Syntax}: 2487 1.1 mrg @code{CALL BACKTRACE} 2488 1.1 mrg 2489 1.1 mrg @item @emph{Arguments}: 2490 1.1 mrg None 2491 1.1 mrg 2492 1.1 mrg @item @emph{See also}: 2493 1.1 mrg @ref{ABORT} 2494 1.1 mrg @end table 2495 1.1 mrg 2496 1.1 mrg 2497 1.1 mrg 2498 1.1 mrg @node BESSEL_J0 2499 1.1 mrg @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0 2500 1.1 mrg @fnindex BESSEL_J0 2501 1.1 mrg @fnindex BESJ0 2502 1.1 mrg @fnindex DBESJ0 2503 1.1 mrg @cindex Bessel function, first kind 2504 1.1 mrg 2505 1.1 mrg @table @asis 2506 1.1 mrg @item @emph{Description}: 2507 1.1 mrg @code{BESSEL_J0(X)} computes the Bessel function of the first kind of 2508 1.1 mrg order 0 of @var{X}. This function is available under the name 2509 1.1 mrg @code{BESJ0} as a GNU extension. 2510 1.1 mrg 2511 1.1 mrg @item @emph{Standard}: 2512 1.1 mrg Fortran 2008 and later 2513 1.1 mrg 2514 1.1 mrg @item @emph{Class}: 2515 1.1 mrg Elemental function 2516 1.1 mrg 2517 1.1 mrg @item @emph{Syntax}: 2518 1.1 mrg @code{RESULT = BESSEL_J0(X)} 2519 1.1 mrg 2520 1.1 mrg @item @emph{Arguments}: 2521 1.1 mrg @multitable @columnfractions .15 .70 2522 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 2523 1.1 mrg @end multitable 2524 1.1 mrg 2525 1.1 mrg @item @emph{Return value}: 2526 1.1 mrg The return value is of type @code{REAL} and lies in the 2527 1.1 mrg range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same 2528 1.1 mrg kind as @var{X}. 2529 1.1 mrg 2530 1.1 mrg @item @emph{Example}: 2531 1.1 mrg @smallexample 2532 1.1 mrg program test_besj0 2533 1.1 mrg real(8) :: x = 0.0_8 2534 1.1 mrg x = bessel_j0(x) 2535 1.1 mrg end program test_besj0 2536 1.1 mrg @end smallexample 2537 1.1 mrg 2538 1.1 mrg @item @emph{Specific names}: 2539 1.1.1.3 mrg @multitable @columnfractions .21 .22 .20 .33 2540 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 2541 1.1 mrg @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 2542 1.1 mrg @end multitable 2543 1.1 mrg @end table 2544 1.1 mrg 2545 1.1 mrg 2546 1.1 mrg 2547 1.1 mrg @node BESSEL_J1 2548 1.1 mrg @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1 2549 1.1 mrg @fnindex BESSEL_J1 2550 1.1 mrg @fnindex BESJ1 2551 1.1 mrg @fnindex DBESJ1 2552 1.1 mrg @cindex Bessel function, first kind 2553 1.1 mrg 2554 1.1 mrg @table @asis 2555 1.1 mrg @item @emph{Description}: 2556 1.1 mrg @code{BESSEL_J1(X)} computes the Bessel function of the first kind of 2557 1.1 mrg order 1 of @var{X}. This function is available under the name 2558 1.1 mrg @code{BESJ1} as a GNU extension. 2559 1.1 mrg 2560 1.1 mrg @item @emph{Standard}: 2561 1.1 mrg Fortran 2008 2562 1.1 mrg 2563 1.1 mrg @item @emph{Class}: 2564 1.1 mrg Elemental function 2565 1.1 mrg 2566 1.1 mrg @item @emph{Syntax}: 2567 1.1 mrg @code{RESULT = BESSEL_J1(X)} 2568 1.1 mrg 2569 1.1 mrg @item @emph{Arguments}: 2570 1.1 mrg @multitable @columnfractions .15 .70 2571 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 2572 1.1 mrg @end multitable 2573 1.1 mrg 2574 1.1 mrg @item @emph{Return value}: 2575 1.1 mrg The return value is of type @code{REAL} and lies in the 2576 1.1 mrg range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same 2577 1.1 mrg kind as @var{X}. 2578 1.1 mrg 2579 1.1 mrg @item @emph{Example}: 2580 1.1 mrg @smallexample 2581 1.1 mrg program test_besj1 2582 1.1 mrg real(8) :: x = 1.0_8 2583 1.1 mrg x = bessel_j1(x) 2584 1.1 mrg end program test_besj1 2585 1.1 mrg @end smallexample 2586 1.1 mrg 2587 1.1 mrg @item @emph{Specific names}: 2588 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 2589 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 2590 1.1 mrg @item @code{DBESJ1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 2591 1.1 mrg @end multitable 2592 1.1 mrg @end table 2593 1.1 mrg 2594 1.1 mrg 2595 1.1 mrg 2596 1.1 mrg @node BESSEL_JN 2597 1.1 mrg @section @code{BESSEL_JN} --- Bessel function of the first kind 2598 1.1 mrg @fnindex BESSEL_JN 2599 1.1 mrg @fnindex BESJN 2600 1.1 mrg @fnindex DBESJN 2601 1.1 mrg @cindex Bessel function, first kind 2602 1.1 mrg 2603 1.1 mrg @table @asis 2604 1.1 mrg @item @emph{Description}: 2605 1.1 mrg @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of 2606 1.1 mrg order @var{N} of @var{X}. This function is available under the name 2607 1.1 mrg @code{BESJN} as a GNU extension. If @var{N} and @var{X} are arrays, 2608 1.1 mrg their ranks and shapes shall conform. 2609 1.1 mrg 2610 1.1 mrg @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions 2611 1.1 mrg of the first kind of the orders @var{N1} to @var{N2}. 2612 1.1 mrg 2613 1.1 mrg @item @emph{Standard}: 2614 1.1 mrg Fortran 2008 and later, negative @var{N} is allowed as GNU extension 2615 1.1 mrg 2616 1.1 mrg @item @emph{Class}: 2617 1.1 mrg Elemental function, except for the transformational function 2618 1.1 mrg @code{BESSEL_JN(N1, N2, X)} 2619 1.1 mrg 2620 1.1 mrg @item @emph{Syntax}: 2621 1.1 mrg @multitable @columnfractions .80 2622 1.1 mrg @item @code{RESULT = BESSEL_JN(N, X)} 2623 1.1 mrg @item @code{RESULT = BESSEL_JN(N1, N2, X)} 2624 1.1 mrg @end multitable 2625 1.1 mrg 2626 1.1 mrg @item @emph{Arguments}: 2627 1.1 mrg @multitable @columnfractions .15 .70 2628 1.1 mrg @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}. 2629 1.1 mrg @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}. 2630 1.1 mrg @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}. 2631 1.1 mrg @item @var{X} @tab Shall be a scalar or an array of type @code{REAL}; 2632 1.1 mrg for @code{BESSEL_JN(N1, N2, X)} it shall be scalar. 2633 1.1 mrg @end multitable 2634 1.1 mrg 2635 1.1 mrg @item @emph{Return value}: 2636 1.1 mrg The return value is a scalar of type @code{REAL}. It has the same 2637 1.1 mrg kind as @var{X}. 2638 1.1 mrg 2639 1.1 mrg @item @emph{Note}: 2640 1.1 mrg The transformational function uses a recurrence algorithm which might, 2641 1.1 mrg for some values of @var{X}, lead to different results than calls to 2642 1.1 mrg the elemental function. 2643 1.1 mrg 2644 1.1 mrg @item @emph{Example}: 2645 1.1 mrg @smallexample 2646 1.1 mrg program test_besjn 2647 1.1 mrg real(8) :: x = 1.0_8 2648 1.1 mrg x = bessel_jn(5,x) 2649 1.1 mrg end program test_besjn 2650 1.1 mrg @end smallexample 2651 1.1 mrg 2652 1.1 mrg @item @emph{Specific names}: 2653 1.1.1.3 mrg @multitable @columnfractions .22 .22 .20 .32 2654 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 2655 1.1 mrg @item @code{DBESJN(N, X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension 2656 1.1 mrg @item @tab @code{REAL(8) X} @tab @tab 2657 1.1 mrg @end multitable 2658 1.1 mrg @end table 2659 1.1 mrg 2660 1.1 mrg 2661 1.1 mrg 2662 1.1 mrg @node BESSEL_Y0 2663 1.1 mrg @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0 2664 1.1 mrg @fnindex BESSEL_Y0 2665 1.1 mrg @fnindex BESY0 2666 1.1 mrg @fnindex DBESY0 2667 1.1 mrg @cindex Bessel function, second kind 2668 1.1 mrg 2669 1.1 mrg @table @asis 2670 1.1 mrg @item @emph{Description}: 2671 1.1 mrg @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of 2672 1.1 mrg order 0 of @var{X}. This function is available under the name 2673 1.1 mrg @code{BESY0} as a GNU extension. 2674 1.1 mrg 2675 1.1 mrg @item @emph{Standard}: 2676 1.1 mrg Fortran 2008 and later 2677 1.1 mrg 2678 1.1 mrg @item @emph{Class}: 2679 1.1 mrg Elemental function 2680 1.1 mrg 2681 1.1 mrg @item @emph{Syntax}: 2682 1.1 mrg @code{RESULT = BESSEL_Y0(X)} 2683 1.1 mrg 2684 1.1 mrg @item @emph{Arguments}: 2685 1.1 mrg @multitable @columnfractions .15 .70 2686 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 2687 1.1 mrg @end multitable 2688 1.1 mrg 2689 1.1 mrg @item @emph{Return value}: 2690 1.1 mrg The return value is of type @code{REAL}. It has the same kind as @var{X}. 2691 1.1 mrg 2692 1.1 mrg @item @emph{Example}: 2693 1.1 mrg @smallexample 2694 1.1 mrg program test_besy0 2695 1.1 mrg real(8) :: x = 0.0_8 2696 1.1 mrg x = bessel_y0(x) 2697 1.1 mrg end program test_besy0 2698 1.1 mrg @end smallexample 2699 1.1 mrg 2700 1.1 mrg @item @emph{Specific names}: 2701 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 2702 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 2703 1.1 mrg @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 2704 1.1 mrg @end multitable 2705 1.1 mrg @end table 2706 1.1 mrg 2707 1.1 mrg 2708 1.1 mrg 2709 1.1 mrg @node BESSEL_Y1 2710 1.1 mrg @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1 2711 1.1 mrg @fnindex BESSEL_Y1 2712 1.1 mrg @fnindex BESY1 2713 1.1 mrg @fnindex DBESY1 2714 1.1 mrg @cindex Bessel function, second kind 2715 1.1 mrg 2716 1.1 mrg @table @asis 2717 1.1 mrg @item @emph{Description}: 2718 1.1 mrg @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of 2719 1.1 mrg order 1 of @var{X}. This function is available under the name 2720 1.1 mrg @code{BESY1} as a GNU extension. 2721 1.1 mrg 2722 1.1 mrg @item @emph{Standard}: 2723 1.1 mrg Fortran 2008 and later 2724 1.1 mrg 2725 1.1 mrg @item @emph{Class}: 2726 1.1 mrg Elemental function 2727 1.1 mrg 2728 1.1 mrg @item @emph{Syntax}: 2729 1.1 mrg @code{RESULT = BESSEL_Y1(X)} 2730 1.1 mrg 2731 1.1 mrg @item @emph{Arguments}: 2732 1.1 mrg @multitable @columnfractions .15 .70 2733 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 2734 1.1 mrg @end multitable 2735 1.1 mrg 2736 1.1 mrg @item @emph{Return value}: 2737 1.1 mrg The return value is of type @code{REAL}. It has the same kind as @var{X}. 2738 1.1 mrg 2739 1.1 mrg @item @emph{Example}: 2740 1.1 mrg @smallexample 2741 1.1 mrg program test_besy1 2742 1.1 mrg real(8) :: x = 1.0_8 2743 1.1 mrg x = bessel_y1(x) 2744 1.1 mrg end program test_besy1 2745 1.1 mrg @end smallexample 2746 1.1 mrg 2747 1.1 mrg @item @emph{Specific names}: 2748 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 2749 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 2750 1.1 mrg @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 2751 1.1 mrg @end multitable 2752 1.1 mrg @end table 2753 1.1 mrg 2754 1.1 mrg 2755 1.1 mrg 2756 1.1 mrg @node BESSEL_YN 2757 1.1 mrg @section @code{BESSEL_YN} --- Bessel function of the second kind 2758 1.1 mrg @fnindex BESSEL_YN 2759 1.1 mrg @fnindex BESYN 2760 1.1 mrg @fnindex DBESYN 2761 1.1 mrg @cindex Bessel function, second kind 2762 1.1 mrg 2763 1.1 mrg @table @asis 2764 1.1 mrg @item @emph{Description}: 2765 1.1 mrg @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of 2766 1.1 mrg order @var{N} of @var{X}. This function is available under the name 2767 1.1 mrg @code{BESYN} as a GNU extension. If @var{N} and @var{X} are arrays, 2768 1.1 mrg their ranks and shapes shall conform. 2769 1.1 mrg 2770 1.1 mrg @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions 2771 1.1 mrg of the first kind of the orders @var{N1} to @var{N2}. 2772 1.1 mrg 2773 1.1 mrg @item @emph{Standard}: 2774 1.1 mrg Fortran 2008 and later, negative @var{N} is allowed as GNU extension 2775 1.1 mrg 2776 1.1 mrg @item @emph{Class}: 2777 1.1 mrg Elemental function, except for the transformational function 2778 1.1 mrg @code{BESSEL_YN(N1, N2, X)} 2779 1.1 mrg 2780 1.1 mrg @item @emph{Syntax}: 2781 1.1 mrg @multitable @columnfractions .80 2782 1.1 mrg @item @code{RESULT = BESSEL_YN(N, X)} 2783 1.1 mrg @item @code{RESULT = BESSEL_YN(N1, N2, X)} 2784 1.1 mrg @end multitable 2785 1.1 mrg 2786 1.1 mrg @item @emph{Arguments}: 2787 1.1 mrg @multitable @columnfractions .15 .70 2788 1.1 mrg @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER} . 2789 1.1 mrg @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}. 2790 1.1 mrg @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}. 2791 1.1 mrg @item @var{X} @tab Shall be a scalar or an array of type @code{REAL}; 2792 1.1 mrg for @code{BESSEL_YN(N1, N2, X)} it shall be scalar. 2793 1.1 mrg @end multitable 2794 1.1 mrg 2795 1.1 mrg @item @emph{Return value}: 2796 1.1 mrg The return value is a scalar of type @code{REAL}. It has the same 2797 1.1 mrg kind as @var{X}. 2798 1.1 mrg 2799 1.1 mrg @item @emph{Note}: 2800 1.1 mrg The transformational function uses a recurrence algorithm which might, 2801 1.1 mrg for some values of @var{X}, lead to different results than calls to 2802 1.1 mrg the elemental function. 2803 1.1 mrg 2804 1.1 mrg @item @emph{Example}: 2805 1.1 mrg @smallexample 2806 1.1 mrg program test_besyn 2807 1.1 mrg real(8) :: x = 1.0_8 2808 1.1 mrg x = bessel_yn(5,x) 2809 1.1 mrg end program test_besyn 2810 1.1 mrg @end smallexample 2811 1.1 mrg 2812 1.1 mrg @item @emph{Specific names}: 2813 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 2814 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 2815 1.1 mrg @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension 2816 1.1.1.3 mrg @item @tab @code{REAL(8) X} @tab @tab 2817 1.1 mrg @end multitable 2818 1.1 mrg @end table 2819 1.1 mrg 2820 1.1 mrg 2821 1.1 mrg 2822 1.1 mrg @node BGE 2823 1.1 mrg @section @code{BGE} --- Bitwise greater than or equal to 2824 1.1 mrg @fnindex BGE 2825 1.1 mrg @cindex bitwise comparison 2826 1.1 mrg 2827 1.1 mrg @table @asis 2828 1.1 mrg @item @emph{Description}: 2829 1.1 mrg Determines whether an integral is a bitwise greater than or equal to 2830 1.1 mrg another. 2831 1.1 mrg 2832 1.1 mrg @item @emph{Standard}: 2833 1.1 mrg Fortran 2008 and later 2834 1.1 mrg 2835 1.1 mrg @item @emph{Class}: 2836 1.1 mrg Elemental function 2837 1.1 mrg 2838 1.1 mrg @item @emph{Syntax}: 2839 1.1 mrg @code{RESULT = BGE(I, J)} 2840 1.1 mrg 2841 1.1 mrg @item @emph{Arguments}: 2842 1.1 mrg @multitable @columnfractions .15 .70 2843 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type. 2844 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind 2845 1.1 mrg as @var{I}. 2846 1.1 mrg @end multitable 2847 1.1 mrg 2848 1.1 mrg @item @emph{Return value}: 2849 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind. 2850 1.1 mrg 2851 1.1 mrg @item @emph{See also}: 2852 1.1.1.2 mrg @ref{BGT}, @gol 2853 1.1.1.2 mrg @ref{BLE}, @gol 2854 1.1.1.2 mrg @ref{BLT} 2855 1.1 mrg @end table 2856 1.1 mrg 2857 1.1 mrg 2858 1.1 mrg 2859 1.1 mrg @node BGT 2860 1.1 mrg @section @code{BGT} --- Bitwise greater than 2861 1.1 mrg @fnindex BGT 2862 1.1 mrg @cindex bitwise comparison 2863 1.1 mrg 2864 1.1 mrg @table @asis 2865 1.1 mrg @item @emph{Description}: 2866 1.1 mrg Determines whether an integral is a bitwise greater than another. 2867 1.1 mrg 2868 1.1 mrg @item @emph{Standard}: 2869 1.1 mrg Fortran 2008 and later 2870 1.1 mrg 2871 1.1 mrg @item @emph{Class}: 2872 1.1 mrg Elemental function 2873 1.1 mrg 2874 1.1 mrg @item @emph{Syntax}: 2875 1.1 mrg @code{RESULT = BGT(I, J)} 2876 1.1 mrg 2877 1.1 mrg @item @emph{Arguments}: 2878 1.1 mrg @multitable @columnfractions .15 .70 2879 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type. 2880 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind 2881 1.1 mrg as @var{I}. 2882 1.1 mrg @end multitable 2883 1.1 mrg 2884 1.1 mrg @item @emph{Return value}: 2885 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind. 2886 1.1 mrg 2887 1.1 mrg @item @emph{See also}: 2888 1.1.1.2 mrg @ref{BGE}, @gol 2889 1.1.1.2 mrg @ref{BLE}, @gol 2890 1.1.1.2 mrg @ref{BLT} 2891 1.1 mrg @end table 2892 1.1 mrg 2893 1.1 mrg 2894 1.1 mrg 2895 1.1 mrg @node BIT_SIZE 2896 1.1 mrg @section @code{BIT_SIZE} --- Bit size inquiry function 2897 1.1 mrg @fnindex BIT_SIZE 2898 1.1 mrg @cindex bits, number of 2899 1.1 mrg @cindex size of a variable, in bits 2900 1.1 mrg 2901 1.1 mrg @table @asis 2902 1.1 mrg @item @emph{Description}: 2903 1.1 mrg @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit) 2904 1.1 mrg represented by the type of @var{I}. The result of @code{BIT_SIZE(I)} is 2905 1.1 mrg independent of the actual value of @var{I}. 2906 1.1 mrg 2907 1.1 mrg @item @emph{Standard}: 2908 1.1.1.2 mrg Fortran 90 and later 2909 1.1 mrg 2910 1.1 mrg @item @emph{Class}: 2911 1.1 mrg Inquiry function 2912 1.1 mrg 2913 1.1 mrg @item @emph{Syntax}: 2914 1.1 mrg @code{RESULT = BIT_SIZE(I)} 2915 1.1 mrg 2916 1.1 mrg @item @emph{Arguments}: 2917 1.1 mrg @multitable @columnfractions .15 .70 2918 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 2919 1.1 mrg @end multitable 2920 1.1 mrg 2921 1.1 mrg @item @emph{Return value}: 2922 1.1 mrg The return value is of type @code{INTEGER} 2923 1.1 mrg 2924 1.1 mrg @item @emph{Example}: 2925 1.1 mrg @smallexample 2926 1.1 mrg program test_bit_size 2927 1.1 mrg integer :: i = 123 2928 1.1 mrg integer :: size 2929 1.1 mrg size = bit_size(i) 2930 1.1 mrg print *, size 2931 1.1 mrg end program test_bit_size 2932 1.1 mrg @end smallexample 2933 1.1 mrg @end table 2934 1.1 mrg 2935 1.1 mrg 2936 1.1 mrg 2937 1.1 mrg @node BLE 2938 1.1 mrg @section @code{BLE} --- Bitwise less than or equal to 2939 1.1 mrg @fnindex BLE 2940 1.1 mrg @cindex bitwise comparison 2941 1.1 mrg 2942 1.1 mrg @table @asis 2943 1.1 mrg @item @emph{Description}: 2944 1.1 mrg Determines whether an integral is a bitwise less than or equal to 2945 1.1 mrg another. 2946 1.1 mrg 2947 1.1 mrg @item @emph{Standard}: 2948 1.1 mrg Fortran 2008 and later 2949 1.1 mrg 2950 1.1 mrg @item @emph{Class}: 2951 1.1 mrg Elemental function 2952 1.1 mrg 2953 1.1 mrg @item @emph{Syntax}: 2954 1.1 mrg @code{RESULT = BLE(I, J)} 2955 1.1 mrg 2956 1.1 mrg @item @emph{Arguments}: 2957 1.1 mrg @multitable @columnfractions .15 .70 2958 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type. 2959 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind 2960 1.1 mrg as @var{I}. 2961 1.1 mrg @end multitable 2962 1.1 mrg 2963 1.1 mrg @item @emph{Return value}: 2964 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind. 2965 1.1 mrg 2966 1.1 mrg @item @emph{See also}: 2967 1.1.1.2 mrg @ref{BGT}, @gol 2968 1.1.1.2 mrg @ref{BGE}, @gol 2969 1.1.1.2 mrg @ref{BLT} 2970 1.1 mrg @end table 2971 1.1 mrg 2972 1.1 mrg 2973 1.1 mrg 2974 1.1 mrg @node BLT 2975 1.1 mrg @section @code{BLT} --- Bitwise less than 2976 1.1 mrg @fnindex BLT 2977 1.1 mrg @cindex bitwise comparison 2978 1.1 mrg 2979 1.1 mrg @table @asis 2980 1.1 mrg @item @emph{Description}: 2981 1.1 mrg Determines whether an integral is a bitwise less than another. 2982 1.1 mrg 2983 1.1 mrg @item @emph{Standard}: 2984 1.1 mrg Fortran 2008 and later 2985 1.1 mrg 2986 1.1 mrg @item @emph{Class}: 2987 1.1 mrg Elemental function 2988 1.1 mrg 2989 1.1 mrg @item @emph{Syntax}: 2990 1.1 mrg @code{RESULT = BLT(I, J)} 2991 1.1 mrg 2992 1.1 mrg @item @emph{Arguments}: 2993 1.1 mrg @multitable @columnfractions .15 .70 2994 1.1 mrg @item @var{I} @tab Shall be of @code{INTEGER} type. 2995 1.1 mrg @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind 2996 1.1 mrg as @var{I}. 2997 1.1 mrg @end multitable 2998 1.1 mrg 2999 1.1 mrg @item @emph{Return value}: 3000 1.1 mrg The return value is of type @code{LOGICAL} and of the default kind. 3001 1.1 mrg 3002 1.1 mrg @item @emph{See also}: 3003 1.1.1.2 mrg @ref{BGE}, @gol 3004 1.1.1.2 mrg @ref{BGT}, @gol 3005 1.1.1.2 mrg @ref{BLE} 3006 1.1 mrg @end table 3007 1.1 mrg 3008 1.1 mrg 3009 1.1 mrg 3010 1.1 mrg @node BTEST 3011 1.1 mrg @section @code{BTEST} --- Bit test function 3012 1.1 mrg @fnindex BTEST 3013 1.1 mrg @fnindex BBTEST 3014 1.1 mrg @fnindex BITEST 3015 1.1 mrg @fnindex BJTEST 3016 1.1 mrg @fnindex BKTEST 3017 1.1 mrg @cindex bits, testing 3018 1.1 mrg 3019 1.1 mrg @table @asis 3020 1.1 mrg @item @emph{Description}: 3021 1.1 mrg @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS} 3022 1.1 mrg in @var{I} is set. The counting of the bits starts at 0. 3023 1.1 mrg 3024 1.1 mrg @item @emph{Standard}: 3025 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions 3026 1.1 mrg 3027 1.1 mrg @item @emph{Class}: 3028 1.1 mrg Elemental function 3029 1.1 mrg 3030 1.1 mrg @item @emph{Syntax}: 3031 1.1 mrg @code{RESULT = BTEST(I, POS)} 3032 1.1 mrg 3033 1.1 mrg @item @emph{Arguments}: 3034 1.1 mrg @multitable @columnfractions .15 .70 3035 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 3036 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}. 3037 1.1 mrg @end multitable 3038 1.1 mrg 3039 1.1 mrg @item @emph{Return value}: 3040 1.1 mrg The return value is of type @code{LOGICAL} 3041 1.1 mrg 3042 1.1 mrg @item @emph{Example}: 3043 1.1 mrg @smallexample 3044 1.1 mrg program test_btest 3045 1.1 mrg integer :: i = 32768 + 1024 + 64 3046 1.1 mrg integer :: pos 3047 1.1 mrg logical :: bool 3048 1.1 mrg do pos=0,16 3049 1.1 mrg bool = btest(i, pos) 3050 1.1 mrg print *, pos, bool 3051 1.1 mrg end do 3052 1.1 mrg end program test_btest 3053 1.1 mrg @end smallexample 3054 1.1 mrg 3055 1.1 mrg @item @emph{Specific names}: 3056 1.1.1.3 mrg @multitable @columnfractions .21 .28 .18 .30 3057 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 3058 1.1.1.2 mrg @item @code{BTEST(I,POS)} @tab @code{INTEGER I,POS} @tab @code{LOGICAL} @tab Fortran 95 and later 3059 1.1 mrg @item @code{BBTEST(I,POS)} @tab @code{INTEGER(1) I,POS} @tab @code{LOGICAL(1)} @tab GNU extension 3060 1.1 mrg @item @code{BITEST(I,POS)} @tab @code{INTEGER(2) I,POS} @tab @code{LOGICAL(2)} @tab GNU extension 3061 1.1 mrg @item @code{BJTEST(I,POS)} @tab @code{INTEGER(4) I,POS} @tab @code{LOGICAL(4)} @tab GNU extension 3062 1.1 mrg @item @code{BKTEST(I,POS)} @tab @code{INTEGER(8) I,POS} @tab @code{LOGICAL(8)} @tab GNU extension 3063 1.1 mrg @end multitable 3064 1.1 mrg @end table 3065 1.1 mrg 3066 1.1 mrg @node C_ASSOCIATED 3067 1.1 mrg @section @code{C_ASSOCIATED} --- Status of a C pointer 3068 1.1 mrg @fnindex C_ASSOCIATED 3069 1.1 mrg @cindex association status, C pointer 3070 1.1 mrg @cindex pointer, C association status 3071 1.1 mrg 3072 1.1 mrg @table @asis 3073 1.1 mrg @item @emph{Description}: 3074 1.1 mrg @code{C_ASSOCIATED(c_ptr_1[, c_ptr_2])} determines the status of the C pointer 3075 1.1 mrg @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}. 3076 1.1 mrg 3077 1.1 mrg @item @emph{Standard}: 3078 1.1 mrg Fortran 2003 and later 3079 1.1 mrg 3080 1.1 mrg @item @emph{Class}: 3081 1.1 mrg Inquiry function 3082 1.1 mrg 3083 1.1 mrg @item @emph{Syntax}: 3084 1.1 mrg @code{RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2])} 3085 1.1 mrg 3086 1.1 mrg @item @emph{Arguments}: 3087 1.1 mrg @multitable @columnfractions .15 .70 3088 1.1 mrg @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}. 3089 1.1 mrg @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}. 3090 1.1 mrg @end multitable 3091 1.1 mrg 3092 1.1 mrg @item @emph{Return value}: 3093 1.1 mrg The return value is of type @code{LOGICAL}; it is @code{.false.} if either 3094 1.1 mrg @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2} 3095 1.1 mrg point to different addresses. 3096 1.1 mrg 3097 1.1 mrg @item @emph{Example}: 3098 1.1 mrg @smallexample 3099 1.1 mrg subroutine association_test(a,b) 3100 1.1 mrg use iso_c_binding, only: c_associated, c_loc, c_ptr 3101 1.1 mrg implicit none 3102 1.1 mrg real, pointer :: a 3103 1.1 mrg type(c_ptr) :: b 3104 1.1 mrg if(c_associated(b, c_loc(a))) & 3105 1.1 mrg stop 'b and a do not point to same target' 3106 1.1 mrg end subroutine association_test 3107 1.1 mrg @end smallexample 3108 1.1 mrg 3109 1.1 mrg @item @emph{See also}: 3110 1.1.1.2 mrg @ref{C_LOC}, @gol 3111 1.1.1.2 mrg @ref{C_FUNLOC} 3112 1.1 mrg @end table 3113 1.1 mrg 3114 1.1 mrg 3115 1.1 mrg @node C_F_POINTER 3116 1.1 mrg @section @code{C_F_POINTER} --- Convert C into Fortran pointer 3117 1.1 mrg @fnindex C_F_POINTER 3118 1.1 mrg @cindex pointer, convert C to Fortran 3119 1.1 mrg 3120 1.1 mrg @table @asis 3121 1.1 mrg @item @emph{Description}: 3122 1.1 mrg @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer 3123 1.1 mrg @var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape. 3124 1.1 mrg 3125 1.1 mrg @item @emph{Standard}: 3126 1.1 mrg Fortran 2003 and later 3127 1.1 mrg 3128 1.1 mrg @item @emph{Class}: 3129 1.1 mrg Subroutine 3130 1.1 mrg 3131 1.1 mrg @item @emph{Syntax}: 3132 1.1 mrg @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])} 3133 1.1 mrg 3134 1.1 mrg @item @emph{Arguments}: 3135 1.1 mrg @multitable @columnfractions .15 .70 3136 1.1 mrg @item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is 3137 1.1 mrg @code{INTENT(IN)}. 3138 1.1 mrg @item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is 3139 1.1 mrg @code{INTENT(OUT)}. 3140 1.1 mrg @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER} 3141 1.1 mrg with @code{INTENT(IN)}. It shall be present 3142 1.1 mrg if and only if @var{fptr} is an array. The size 3143 1.1 mrg must be equal to the rank of @var{fptr}. 3144 1.1 mrg @end multitable 3145 1.1 mrg 3146 1.1 mrg @item @emph{Example}: 3147 1.1 mrg @smallexample 3148 1.1 mrg program main 3149 1.1 mrg use iso_c_binding 3150 1.1 mrg implicit none 3151 1.1 mrg interface 3152 1.1 mrg subroutine my_routine(p) bind(c,name='myC_func') 3153 1.1 mrg import :: c_ptr 3154 1.1 mrg type(c_ptr), intent(out) :: p 3155 1.1 mrg end subroutine 3156 1.1 mrg end interface 3157 1.1 mrg type(c_ptr) :: cptr 3158 1.1 mrg real,pointer :: a(:) 3159 1.1 mrg call my_routine(cptr) 3160 1.1 mrg call c_f_pointer(cptr, a, [12]) 3161 1.1 mrg end program main 3162 1.1 mrg @end smallexample 3163 1.1 mrg 3164 1.1 mrg @item @emph{See also}: 3165 1.1.1.2 mrg @ref{C_LOC}, @gol 3166 1.1.1.2 mrg @ref{C_F_PROCPOINTER} 3167 1.1 mrg @end table 3168 1.1 mrg 3169 1.1 mrg 3170 1.1 mrg @node C_F_PROCPOINTER 3171 1.1 mrg @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer 3172 1.1 mrg @fnindex C_F_PROCPOINTER 3173 1.1 mrg @cindex pointer, C address of pointers 3174 1.1 mrg 3175 1.1 mrg @table @asis 3176 1.1 mrg @item @emph{Description}: 3177 1.1 mrg @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer 3178 1.1 mrg @var{CPTR} to the Fortran procedure pointer @var{FPTR}. 3179 1.1 mrg 3180 1.1 mrg @item @emph{Standard}: 3181 1.1 mrg Fortran 2003 and later 3182 1.1 mrg 3183 1.1 mrg @item @emph{Class}: 3184 1.1 mrg Subroutine 3185 1.1 mrg 3186 1.1 mrg @item @emph{Syntax}: 3187 1.1 mrg @code{CALL C_F_PROCPOINTER(cptr, fptr)} 3188 1.1 mrg 3189 1.1 mrg @item @emph{Arguments}: 3190 1.1 mrg @multitable @columnfractions .15 .70 3191 1.1 mrg @item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is 3192 1.1 mrg @code{INTENT(IN)}. 3193 1.1 mrg @item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is 3194 1.1 mrg @code{INTENT(OUT)}. 3195 1.1 mrg @end multitable 3196 1.1 mrg 3197 1.1 mrg @item @emph{Example}: 3198 1.1 mrg @smallexample 3199 1.1 mrg program main 3200 1.1 mrg use iso_c_binding 3201 1.1 mrg implicit none 3202 1.1 mrg abstract interface 3203 1.1 mrg function func(a) 3204 1.1 mrg import :: c_float 3205 1.1 mrg real(c_float), intent(in) :: a 3206 1.1 mrg real(c_float) :: func 3207 1.1 mrg end function 3208 1.1 mrg end interface 3209 1.1 mrg interface 3210 1.1 mrg function getIterFunc() bind(c,name="getIterFunc") 3211 1.1 mrg import :: c_funptr 3212 1.1 mrg type(c_funptr) :: getIterFunc 3213 1.1 mrg end function 3214 1.1 mrg end interface 3215 1.1 mrg type(c_funptr) :: cfunptr 3216 1.1 mrg procedure(func), pointer :: myFunc 3217 1.1 mrg cfunptr = getIterFunc() 3218 1.1 mrg call c_f_procpointer(cfunptr, myFunc) 3219 1.1 mrg end program main 3220 1.1 mrg @end smallexample 3221 1.1 mrg 3222 1.1 mrg @item @emph{See also}: 3223 1.1.1.2 mrg @ref{C_LOC}, @gol 3224 1.1.1.2 mrg @ref{C_F_POINTER} 3225 1.1 mrg @end table 3226 1.1 mrg 3227 1.1 mrg 3228 1.1 mrg @node C_FUNLOC 3229 1.1 mrg @section @code{C_FUNLOC} --- Obtain the C address of a procedure 3230 1.1 mrg @fnindex C_FUNLOC 3231 1.1 mrg @cindex pointer, C address of procedures 3232 1.1 mrg 3233 1.1 mrg @table @asis 3234 1.1 mrg @item @emph{Description}: 3235 1.1 mrg @code{C_FUNLOC(x)} determines the C address of the argument. 3236 1.1 mrg 3237 1.1 mrg @item @emph{Standard}: 3238 1.1 mrg Fortran 2003 and later 3239 1.1 mrg 3240 1.1 mrg @item @emph{Class}: 3241 1.1 mrg Inquiry function 3242 1.1 mrg 3243 1.1 mrg @item @emph{Syntax}: 3244 1.1 mrg @code{RESULT = C_FUNLOC(x)} 3245 1.1 mrg 3246 1.1 mrg @item @emph{Arguments}: 3247 1.1 mrg @multitable @columnfractions .15 .70 3248 1.1 mrg @item @var{x} @tab Interoperable function or pointer to such function. 3249 1.1 mrg @end multitable 3250 1.1 mrg 3251 1.1 mrg @item @emph{Return value}: 3252 1.1 mrg The return value is of type @code{C_FUNPTR} and contains the C address 3253 1.1 mrg of the argument. 3254 1.1 mrg 3255 1.1 mrg @item @emph{Example}: 3256 1.1 mrg @smallexample 3257 1.1 mrg module x 3258 1.1 mrg use iso_c_binding 3259 1.1 mrg implicit none 3260 1.1 mrg contains 3261 1.1 mrg subroutine sub(a) bind(c) 3262 1.1 mrg real(c_float) :: a 3263 1.1 mrg a = sqrt(a)+5.0 3264 1.1 mrg end subroutine sub 3265 1.1 mrg end module x 3266 1.1 mrg program main 3267 1.1 mrg use iso_c_binding 3268 1.1 mrg use x 3269 1.1 mrg implicit none 3270 1.1 mrg interface 3271 1.1 mrg subroutine my_routine(p) bind(c,name='myC_func') 3272 1.1 mrg import :: c_funptr 3273 1.1 mrg type(c_funptr), intent(in) :: p 3274 1.1 mrg end subroutine 3275 1.1 mrg end interface 3276 1.1 mrg call my_routine(c_funloc(sub)) 3277 1.1 mrg end program main 3278 1.1 mrg @end smallexample 3279 1.1 mrg 3280 1.1 mrg @item @emph{See also}: 3281 1.1.1.2 mrg @ref{C_ASSOCIATED}, @gol 3282 1.1.1.2 mrg @ref{C_LOC}, @gol 3283 1.1.1.2 mrg @ref{C_F_POINTER}, @gol 3284 1.1.1.2 mrg @ref{C_F_PROCPOINTER} 3285 1.1 mrg @end table 3286 1.1 mrg 3287 1.1 mrg 3288 1.1 mrg @node C_LOC 3289 1.1 mrg @section @code{C_LOC} --- Obtain the C address of an object 3290 1.1 mrg @fnindex C_LOC 3291 1.1 mrg @cindex procedure pointer, convert C to Fortran 3292 1.1 mrg 3293 1.1 mrg @table @asis 3294 1.1 mrg @item @emph{Description}: 3295 1.1 mrg @code{C_LOC(X)} determines the C address of the argument. 3296 1.1 mrg 3297 1.1 mrg @item @emph{Standard}: 3298 1.1 mrg Fortran 2003 and later 3299 1.1 mrg 3300 1.1 mrg @item @emph{Class}: 3301 1.1 mrg Inquiry function 3302 1.1 mrg 3303 1.1 mrg @item @emph{Syntax}: 3304 1.1 mrg @code{RESULT = C_LOC(X)} 3305 1.1 mrg 3306 1.1 mrg @item @emph{Arguments}: 3307 1.1 mrg @multitable @columnfractions .10 .75 3308 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. 3309 1.1 mrg 3310 1.1 mrg @end multitable 3311 1.1 mrg 3312 1.1 mrg @item @emph{Return value}: 3313 1.1 mrg The return value is of type @code{C_PTR} and contains the C address 3314 1.1 mrg of the argument. 3315 1.1 mrg 3316 1.1 mrg @item @emph{Example}: 3317 1.1 mrg @smallexample 3318 1.1 mrg subroutine association_test(a,b) 3319 1.1 mrg use iso_c_binding, only: c_associated, c_loc, c_ptr 3320 1.1 mrg implicit none 3321 1.1 mrg real, pointer :: a 3322 1.1 mrg type(c_ptr) :: b 3323 1.1 mrg if(c_associated(b, c_loc(a))) & 3324 1.1 mrg stop 'b and a do not point to same target' 3325 1.1 mrg end subroutine association_test 3326 1.1 mrg @end smallexample 3327 1.1 mrg 3328 1.1 mrg @item @emph{See also}: 3329 1.1.1.2 mrg @ref{C_ASSOCIATED}, @gol 3330 1.1.1.2 mrg @ref{C_FUNLOC}, @gol 3331 1.1.1.2 mrg @ref{C_F_POINTER}, @gol 3332 1.1.1.2 mrg @ref{C_F_PROCPOINTER} 3333 1.1 mrg @end table 3334 1.1 mrg 3335 1.1 mrg 3336 1.1 mrg @node C_SIZEOF 3337 1.1 mrg @section @code{C_SIZEOF} --- Size in bytes of an expression 3338 1.1 mrg @fnindex C_SIZEOF 3339 1.1 mrg @cindex expression size 3340 1.1 mrg @cindex size of an expression 3341 1.1 mrg 3342 1.1 mrg @table @asis 3343 1.1 mrg @item @emph{Description}: 3344 1.1 mrg @code{C_SIZEOF(X)} calculates the number of bytes of storage the 3345 1.1 mrg expression @code{X} occupies. 3346 1.1 mrg 3347 1.1 mrg @item @emph{Standard}: 3348 1.1 mrg Fortran 2008 3349 1.1 mrg 3350 1.1 mrg @item @emph{Class}: 3351 1.1 mrg Inquiry function of the module @code{ISO_C_BINDING} 3352 1.1 mrg 3353 1.1 mrg @item @emph{Syntax}: 3354 1.1 mrg @code{N = C_SIZEOF(X)} 3355 1.1 mrg 3356 1.1 mrg @item @emph{Arguments}: 3357 1.1 mrg @multitable @columnfractions .15 .70 3358 1.1 mrg @item @var{X} @tab The argument shall be an interoperable data entity. 3359 1.1 mrg @end multitable 3360 1.1 mrg 3361 1.1 mrg @item @emph{Return value}: 3362 1.1 mrg The return value is of type integer and of the system-dependent kind 3363 1.1 mrg @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the 3364 1.1 mrg number of bytes occupied by the argument. If the argument has the 3365 1.1 mrg @code{POINTER} attribute, the number of bytes of the storage area pointed 3366 1.1 mrg to is returned. If the argument is of a derived type with @code{POINTER} 3367 1.1 mrg or @code{ALLOCATABLE} components, the return value does not account for 3368 1.1 mrg the sizes of the data pointed to by these components. 3369 1.1 mrg 3370 1.1 mrg @item @emph{Example}: 3371 1.1 mrg @smallexample 3372 1.1 mrg use iso_c_binding 3373 1.1 mrg integer(c_int) :: i 3374 1.1 mrg real(c_float) :: r, s(5) 3375 1.1 mrg print *, (c_sizeof(s)/c_sizeof(r) == 5) 3376 1.1 mrg end 3377 1.1 mrg @end smallexample 3378 1.1.1.2 mrg The example will print @code{T} unless you are using a platform 3379 1.1 mrg where default @code{REAL} variables are unusually padded. 3380 1.1 mrg 3381 1.1 mrg @item @emph{See also}: 3382 1.1.1.2 mrg @ref{SIZEOF}, @gol 3383 1.1.1.2 mrg @ref{STORAGE_SIZE} 3384 1.1 mrg @end table 3385 1.1 mrg 3386 1.1 mrg 3387 1.1 mrg @node CEILING 3388 1.1 mrg @section @code{CEILING} --- Integer ceiling function 3389 1.1 mrg @fnindex CEILING 3390 1.1 mrg @cindex ceiling 3391 1.1 mrg @cindex rounding, ceiling 3392 1.1 mrg 3393 1.1 mrg @table @asis 3394 1.1 mrg @item @emph{Description}: 3395 1.1 mrg @code{CEILING(A)} returns the least integer greater than or equal to @var{A}. 3396 1.1 mrg 3397 1.1 mrg @item @emph{Standard}: 3398 1.1 mrg Fortran 95 and later 3399 1.1 mrg 3400 1.1 mrg @item @emph{Class}: 3401 1.1 mrg Elemental function 3402 1.1 mrg 3403 1.1 mrg @item @emph{Syntax}: 3404 1.1 mrg @code{RESULT = CEILING(A [, KIND])} 3405 1.1 mrg 3406 1.1 mrg @item @emph{Arguments}: 3407 1.1 mrg @multitable @columnfractions .15 .70 3408 1.1 mrg @item @var{A} @tab The type shall be @code{REAL}. 3409 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 3410 1.1 mrg expression indicating the kind parameter of the result. 3411 1.1 mrg @end multitable 3412 1.1 mrg 3413 1.1 mrg @item @emph{Return value}: 3414 1.1 mrg The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present 3415 1.1 mrg and a default-kind @code{INTEGER} otherwise. 3416 1.1 mrg 3417 1.1 mrg @item @emph{Example}: 3418 1.1 mrg @smallexample 3419 1.1 mrg program test_ceiling 3420 1.1 mrg real :: x = 63.29 3421 1.1 mrg real :: y = -63.59 3422 1.1 mrg print *, ceiling(x) ! returns 64 3423 1.1 mrg print *, ceiling(y) ! returns -63 3424 1.1 mrg end program test_ceiling 3425 1.1 mrg @end smallexample 3426 1.1 mrg 3427 1.1 mrg @item @emph{See also}: 3428 1.1.1.2 mrg @ref{FLOOR}, @gol 3429 1.1.1.2 mrg @ref{NINT} 3430 1.1 mrg @end table 3431 1.1 mrg 3432 1.1 mrg 3433 1.1 mrg 3434 1.1 mrg @node CHAR 3435 1.1 mrg @section @code{CHAR} --- Character conversion function 3436 1.1 mrg @fnindex CHAR 3437 1.1 mrg @cindex conversion, to character 3438 1.1 mrg 3439 1.1 mrg @table @asis 3440 1.1 mrg @item @emph{Description}: 3441 1.1 mrg @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}. 3442 1.1 mrg 3443 1.1 mrg @item @emph{Standard}: 3444 1.1 mrg Fortran 77 and later 3445 1.1 mrg 3446 1.1 mrg @item @emph{Class}: 3447 1.1 mrg Elemental function 3448 1.1 mrg 3449 1.1 mrg @item @emph{Syntax}: 3450 1.1 mrg @code{RESULT = CHAR(I [, KIND])} 3451 1.1 mrg 3452 1.1 mrg @item @emph{Arguments}: 3453 1.1 mrg @multitable @columnfractions .15 .70 3454 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 3455 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 3456 1.1 mrg expression indicating the kind parameter of the result. 3457 1.1 mrg @end multitable 3458 1.1 mrg 3459 1.1 mrg @item @emph{Return value}: 3460 1.1 mrg The return value is of type @code{CHARACTER(1)} 3461 1.1 mrg 3462 1.1 mrg @item @emph{Example}: 3463 1.1 mrg @smallexample 3464 1.1 mrg program test_char 3465 1.1 mrg integer :: i = 74 3466 1.1 mrg character(1) :: c 3467 1.1 mrg c = char(i) 3468 1.1 mrg print *, i, c ! returns 'J' 3469 1.1 mrg end program test_char 3470 1.1 mrg @end smallexample 3471 1.1 mrg 3472 1.1 mrg @item @emph{Specific names}: 3473 1.1.1.3 mrg @multitable @columnfractions .19 .19 .25 .33 3474 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 3475 1.1.1.2 mrg @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab Fortran 77 and later 3476 1.1 mrg @end multitable 3477 1.1 mrg 3478 1.1 mrg @item @emph{Note}: 3479 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values 3480 1.1 mrg and formatted string representations. 3481 1.1 mrg 3482 1.1 mrg @item @emph{See also}: 3483 1.1.1.2 mrg @ref{ACHAR}, @gol 3484 1.1.1.2 mrg @ref{IACHAR}, @gol 3485 1.1.1.2 mrg @ref{ICHAR} 3486 1.1 mrg 3487 1.1 mrg @end table 3488 1.1 mrg 3489 1.1 mrg 3490 1.1 mrg 3491 1.1 mrg @node CHDIR 3492 1.1 mrg @section @code{CHDIR} --- Change working directory 3493 1.1 mrg @fnindex CHDIR 3494 1.1 mrg @cindex system, working directory 3495 1.1 mrg 3496 1.1 mrg @table @asis 3497 1.1 mrg @item @emph{Description}: 3498 1.1 mrg Change current working directory to a specified path. 3499 1.1 mrg 3500 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 3501 1.1 mrg only one form can be used in any given program unit. 3502 1.1 mrg 3503 1.1 mrg @item @emph{Standard}: 3504 1.1 mrg GNU extension 3505 1.1 mrg 3506 1.1 mrg @item @emph{Class}: 3507 1.1 mrg Subroutine, function 3508 1.1 mrg 3509 1.1 mrg @item @emph{Syntax}: 3510 1.1 mrg @multitable @columnfractions .80 3511 1.1 mrg @item @code{CALL CHDIR(NAME [, STATUS])} 3512 1.1 mrg @item @code{STATUS = CHDIR(NAME)} 3513 1.1 mrg @end multitable 3514 1.1 mrg 3515 1.1 mrg @item @emph{Arguments}: 3516 1.1 mrg @multitable @columnfractions .15 .70 3517 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER} of default 3518 1.1 mrg kind and shall specify a valid path within the file system. 3519 1.1 mrg @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default 3520 1.1 mrg kind. Returns 0 on success, and a system specific and nonzero error code 3521 1.1 mrg otherwise. 3522 1.1 mrg @end multitable 3523 1.1 mrg 3524 1.1 mrg @item @emph{Example}: 3525 1.1 mrg @smallexample 3526 1.1 mrg PROGRAM test_chdir 3527 1.1 mrg CHARACTER(len=255) :: path 3528 1.1 mrg CALL getcwd(path) 3529 1.1 mrg WRITE(*,*) TRIM(path) 3530 1.1 mrg CALL chdir("/tmp") 3531 1.1 mrg CALL getcwd(path) 3532 1.1 mrg WRITE(*,*) TRIM(path) 3533 1.1 mrg END PROGRAM 3534 1.1 mrg @end smallexample 3535 1.1 mrg 3536 1.1 mrg @item @emph{See also}: 3537 1.1 mrg @ref{GETCWD} 3538 1.1 mrg @end table 3539 1.1 mrg 3540 1.1 mrg 3541 1.1 mrg 3542 1.1 mrg @node CHMOD 3543 1.1 mrg @section @code{CHMOD} --- Change access permissions of files 3544 1.1 mrg @fnindex CHMOD 3545 1.1 mrg @cindex file system, change access mode 3546 1.1 mrg 3547 1.1 mrg @table @asis 3548 1.1 mrg @item @emph{Description}: 3549 1.1 mrg @code{CHMOD} changes the permissions of a file. 3550 1.1 mrg 3551 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 3552 1.1 mrg only one form can be used in any given program unit. 3553 1.1 mrg 3554 1.1 mrg @item @emph{Standard}: 3555 1.1 mrg GNU extension 3556 1.1 mrg 3557 1.1 mrg @item @emph{Class}: 3558 1.1 mrg Subroutine, function 3559 1.1 mrg 3560 1.1 mrg @item @emph{Syntax}: 3561 1.1 mrg @multitable @columnfractions .80 3562 1.1 mrg @item @code{CALL CHMOD(NAME, MODE[, STATUS])} 3563 1.1 mrg @item @code{STATUS = CHMOD(NAME, MODE)} 3564 1.1 mrg @end multitable 3565 1.1 mrg 3566 1.1 mrg @item @emph{Arguments}: 3567 1.1 mrg @multitable @columnfractions .15 .70 3568 1.1 mrg 3569 1.1 mrg @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the 3570 1.1 mrg file name. Trailing blanks are ignored unless the character 3571 1.1 mrg @code{achar(0)} is present, then all characters up to and excluding 3572 1.1 mrg @code{achar(0)} are used as the file name. 3573 1.1 mrg 3574 1.1 mrg @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the 3575 1.1 mrg file permission. @var{MODE} uses the same syntax as the @code{chmod} utility 3576 1.1 mrg as defined by the POSIX standard. The argument shall either be a string of 3577 1.1 mrg a nonnegative octal number or a symbolic mode. 3578 1.1 mrg 3579 1.1 mrg @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is 3580 1.1 mrg @code{0} on success and nonzero otherwise. 3581 1.1 mrg @end multitable 3582 1.1 mrg 3583 1.1 mrg @item @emph{Return value}: 3584 1.1 mrg In either syntax, @var{STATUS} is set to @code{0} on success and nonzero 3585 1.1 mrg otherwise. 3586 1.1 mrg 3587 1.1 mrg @item @emph{Example}: 3588 1.1 mrg @code{CHMOD} as subroutine 3589 1.1 mrg @smallexample 3590 1.1 mrg program chmod_test 3591 1.1 mrg implicit none 3592 1.1 mrg integer :: status 3593 1.1 mrg call chmod('test.dat','u+x',status) 3594 1.1 mrg print *, 'Status: ', status 3595 1.1 mrg end program chmod_test 3596 1.1 mrg @end smallexample 3597 1.1 mrg @code{CHMOD} as function: 3598 1.1 mrg @smallexample 3599 1.1 mrg program chmod_test 3600 1.1 mrg implicit none 3601 1.1 mrg integer :: status 3602 1.1 mrg status = chmod('test.dat','u+x') 3603 1.1 mrg print *, 'Status: ', status 3604 1.1 mrg end program chmod_test 3605 1.1 mrg @end smallexample 3606 1.1 mrg 3607 1.1 mrg @end table 3608 1.1 mrg 3609 1.1 mrg 3610 1.1 mrg 3611 1.1 mrg @node CMPLX 3612 1.1 mrg @section @code{CMPLX} --- Complex conversion function 3613 1.1 mrg @fnindex CMPLX 3614 1.1 mrg @cindex complex numbers, conversion to 3615 1.1 mrg @cindex conversion, to complex 3616 1.1 mrg 3617 1.1 mrg @table @asis 3618 1.1 mrg @item @emph{Description}: 3619 1.1 mrg @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to 3620 1.1 mrg the real component. If @var{Y} is present it is converted to the imaginary 3621 1.1 mrg component. If @var{Y} is not present then the imaginary component is set to 3622 1.1 mrg 0.0. If @var{X} is complex then @var{Y} must not be present. 3623 1.1 mrg 3624 1.1 mrg @item @emph{Standard}: 3625 1.1 mrg Fortran 77 and later 3626 1.1 mrg 3627 1.1 mrg @item @emph{Class}: 3628 1.1 mrg Elemental function 3629 1.1 mrg 3630 1.1 mrg @item @emph{Syntax}: 3631 1.1 mrg @code{RESULT = CMPLX(X [, Y [, KIND]])} 3632 1.1 mrg 3633 1.1 mrg @item @emph{Arguments}: 3634 1.1 mrg @multitable @columnfractions .15 .70 3635 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL}, 3636 1.1 mrg or @code{COMPLEX}. 3637 1.1 mrg @item @var{Y} @tab (Optional; only allowed if @var{X} is not 3638 1.1 mrg @code{COMPLEX}.) May be @code{INTEGER} or @code{REAL}. 3639 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 3640 1.1 mrg expression indicating the kind parameter of the result. 3641 1.1 mrg @end multitable 3642 1.1 mrg 3643 1.1 mrg @item @emph{Return value}: 3644 1.1 mrg The return value is of @code{COMPLEX} type, with a kind equal to 3645 1.1 mrg @var{KIND} if it is specified. If @var{KIND} is not specified, the 3646 1.1 mrg result is of the default @code{COMPLEX} kind, regardless of the kinds of 3647 1.1 mrg @var{X} and @var{Y}. 3648 1.1 mrg 3649 1.1 mrg @item @emph{Example}: 3650 1.1 mrg @smallexample 3651 1.1 mrg program test_cmplx 3652 1.1 mrg integer :: i = 42 3653 1.1 mrg real :: x = 3.14 3654 1.1 mrg complex :: z 3655 1.1 mrg z = cmplx(i, x) 3656 1.1 mrg print *, z, cmplx(x) 3657 1.1 mrg end program test_cmplx 3658 1.1 mrg @end smallexample 3659 1.1 mrg 3660 1.1 mrg @item @emph{See also}: 3661 1.1 mrg @ref{COMPLEX} 3662 1.1 mrg @end table 3663 1.1 mrg 3664 1.1 mrg 3665 1.1 mrg 3666 1.1 mrg @node CO_BROADCAST 3667 1.1 mrg @section @code{CO_BROADCAST} --- Copy a value to all images the current set of images 3668 1.1 mrg @fnindex CO_BROADCAST 3669 1.1 mrg @cindex Collectives, value broadcasting 3670 1.1 mrg 3671 1.1 mrg @table @asis 3672 1.1 mrg @item @emph{Description}: 3673 1.1 mrg @code{CO_BROADCAST} copies the value of argument @var{A} on the image with 3674 1.1 mrg image index @code{SOURCE_IMAGE} to all images in the current team. @var{A} 3675 1.1 mrg becomes defined as if by intrinsic assignment. If the execution was 3676 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the 3677 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present, 3678 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error. 3679 1.1 mrg 3680 1.1 mrg @item @emph{Standard}: 3681 1.1 mrg Technical Specification (TS) 18508 or later 3682 1.1 mrg 3683 1.1 mrg @item @emph{Class}: 3684 1.1 mrg Collective subroutine 3685 1.1 mrg 3686 1.1 mrg @item @emph{Syntax}: 3687 1.1 mrg @code{CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])} 3688 1.1 mrg 3689 1.1 mrg @item @emph{Arguments}: 3690 1.1.1.2 mrg @multitable @columnfractions .20 .65 3691 1.1 mrg @item @var{A} @tab INTENT(INOUT) argument; shall have the same 3692 1.1.1.2 mrg dynamic type and type parameters on all images of the current team. If it 3693 1.1 mrg is an array, it shall have the same shape on all images. 3694 1.1 mrg @item @var{SOURCE_IMAGE} @tab a scalar integer expression. 3695 1.1.1.3 mrg It shall have the same value on all images and refer to an 3696 1.1 mrg image of the current team. 3697 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable 3698 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable 3699 1.1 mrg @end multitable 3700 1.1 mrg 3701 1.1 mrg @item @emph{Example}: 3702 1.1 mrg @smallexample 3703 1.1 mrg program test 3704 1.1 mrg integer :: val(3) 3705 1.1 mrg if (this_image() == 1) then 3706 1.1 mrg val = [1, 5, 3] 3707 1.1 mrg end if 3708 1.1 mrg call co_broadcast (val, source_image=1) 3709 1.1 mrg print *, this_image, ":", val 3710 1.1 mrg end program test 3711 1.1 mrg @end smallexample 3712 1.1 mrg 3713 1.1 mrg @item @emph{See also}: 3714 1.1.1.2 mrg @ref{CO_MAX}, @gol 3715 1.1.1.2 mrg @ref{CO_MIN}, @gol 3716 1.1.1.2 mrg @ref{CO_SUM}, @gol 3717 1.1.1.2 mrg @ref{CO_REDUCE} 3718 1.1 mrg @end table 3719 1.1 mrg 3720 1.1 mrg 3721 1.1 mrg 3722 1.1 mrg @node CO_MAX 3723 1.1 mrg @section @code{CO_MAX} --- Maximal value on the current set of images 3724 1.1 mrg @fnindex CO_MAX 3725 1.1 mrg @cindex Collectives, maximal value 3726 1.1 mrg 3727 1.1 mrg @table @asis 3728 1.1 mrg @item @emph{Description}: 3729 1.1 mrg @code{CO_MAX} determines element-wise the maximal value of @var{A} on all 3730 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the maximum 3731 1.1 mrg values are returned in @var{A} on the specified image only and the value 3732 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is 3733 1.1 mrg not present, the value is returned on all images. If the execution was 3734 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the 3735 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present, 3736 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error. 3737 1.1 mrg 3738 1.1 mrg @item @emph{Standard}: 3739 1.1 mrg Technical Specification (TS) 18508 or later 3740 1.1 mrg 3741 1.1 mrg @item @emph{Class}: 3742 1.1 mrg Collective subroutine 3743 1.1 mrg 3744 1.1 mrg @item @emph{Syntax}: 3745 1.1 mrg @code{CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG])} 3746 1.1 mrg 3747 1.1 mrg @item @emph{Arguments}: 3748 1.1.1.2 mrg @multitable @columnfractions .20 .65 3749 1.1 mrg @item @var{A} @tab shall be an integer, real or character variable, 3750 1.1 mrg which has the same type and type parameters on all images of the team. 3751 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if 3752 1.1.1.3 mrg present, it shall have the same value on all images and refer to an 3753 1.1 mrg image of the current team. 3754 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable 3755 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable 3756 1.1 mrg @end multitable 3757 1.1 mrg 3758 1.1 mrg @item @emph{Example}: 3759 1.1 mrg @smallexample 3760 1.1 mrg program test 3761 1.1 mrg integer :: val 3762 1.1 mrg val = this_image () 3763 1.1 mrg call co_max (val, result_image=1) 3764 1.1 mrg if (this_image() == 1) then 3765 1.1 mrg write(*,*) "Maximal value", val ! prints num_images() 3766 1.1 mrg end if 3767 1.1 mrg end program test 3768 1.1 mrg @end smallexample 3769 1.1 mrg 3770 1.1 mrg @item @emph{See also}: 3771 1.1.1.2 mrg @ref{CO_MIN}, @gol 3772 1.1.1.2 mrg @ref{CO_SUM}, @gol 3773 1.1.1.2 mrg @ref{CO_REDUCE}, @gol 3774 1.1.1.2 mrg @ref{CO_BROADCAST} 3775 1.1 mrg @end table 3776 1.1 mrg 3777 1.1 mrg 3778 1.1 mrg 3779 1.1 mrg @node CO_MIN 3780 1.1 mrg @section @code{CO_MIN} --- Minimal value on the current set of images 3781 1.1 mrg @fnindex CO_MIN 3782 1.1 mrg @cindex Collectives, minimal value 3783 1.1 mrg 3784 1.1 mrg @table @asis 3785 1.1 mrg @item @emph{Description}: 3786 1.1 mrg @code{CO_MIN} determines element-wise the minimal value of @var{A} on all 3787 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the minimal 3788 1.1 mrg values are returned in @var{A} on the specified image only and the value 3789 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is 3790 1.1 mrg not present, the value is returned on all images. If the execution was 3791 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the 3792 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present, 3793 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error. 3794 1.1 mrg 3795 1.1 mrg @item @emph{Standard}: 3796 1.1 mrg Technical Specification (TS) 18508 or later 3797 1.1 mrg 3798 1.1 mrg @item @emph{Class}: 3799 1.1 mrg Collective subroutine 3800 1.1 mrg 3801 1.1 mrg @item @emph{Syntax}: 3802 1.1 mrg @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])} 3803 1.1 mrg 3804 1.1 mrg @item @emph{Arguments}: 3805 1.1.1.2 mrg @multitable @columnfractions .20 .65 3806 1.1 mrg @item @var{A} @tab shall be an integer, real or character variable, 3807 1.1 mrg which has the same type and type parameters on all images of the team. 3808 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if 3809 1.1.1.3 mrg present, it shall have the same value on all images and refer to an 3810 1.1 mrg image of the current team. 3811 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable 3812 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable 3813 1.1 mrg @end multitable 3814 1.1 mrg 3815 1.1 mrg @item @emph{Example}: 3816 1.1 mrg @smallexample 3817 1.1 mrg program test 3818 1.1 mrg integer :: val 3819 1.1 mrg val = this_image () 3820 1.1 mrg call co_min (val, result_image=1) 3821 1.1 mrg if (this_image() == 1) then 3822 1.1 mrg write(*,*) "Minimal value", val ! prints 1 3823 1.1 mrg end if 3824 1.1 mrg end program test 3825 1.1 mrg @end smallexample 3826 1.1 mrg 3827 1.1 mrg @item @emph{See also}: 3828 1.1.1.2 mrg @ref{CO_MAX}, @gol 3829 1.1.1.2 mrg @ref{CO_SUM}, @gol 3830 1.1.1.2 mrg @ref{CO_REDUCE}, @gol 3831 1.1.1.2 mrg @ref{CO_BROADCAST} 3832 1.1 mrg @end table 3833 1.1 mrg 3834 1.1 mrg 3835 1.1 mrg 3836 1.1 mrg @node CO_REDUCE 3837 1.1 mrg @section @code{CO_REDUCE} --- Reduction of values on the current set of images 3838 1.1 mrg @fnindex CO_REDUCE 3839 1.1 mrg @cindex Collectives, generic reduction 3840 1.1 mrg 3841 1.1 mrg @table @asis 3842 1.1 mrg @item @emph{Description}: 3843 1.1 mrg @code{CO_REDUCE} determines element-wise the reduction of the value of @var{A} 3844 1.1.1.3 mrg on all images of the current team. The pure function passed as @var{OPERATION} 3845 1.1 mrg is used to pairwise reduce the values of @var{A} by passing either the value 3846 1.1 mrg of @var{A} of different images or the result values of such a reduction as 3847 1.1 mrg argument. If @var{A} is an array, the deduction is done element wise. If 3848 1.1 mrg @var{RESULT_IMAGE} is present, the result values are returned in @var{A} on 3849 1.1 mrg the specified image only and the value of @var{A} on the other images become 3850 1.1 mrg undefined. If @var{RESULT_IMAGE} is not present, the value is returned on all 3851 1.1 mrg images. If the execution was successful and @var{STAT} is present, it is 3852 1.1 mrg assigned the value zero. If the execution failed, @var{STAT} gets assigned 3853 1.1 mrg a nonzero value and, if present, @var{ERRMSG} gets assigned a value describing 3854 1.1 mrg the occurred error. 3855 1.1 mrg 3856 1.1 mrg @item @emph{Standard}: 3857 1.1 mrg Technical Specification (TS) 18508 or later 3858 1.1 mrg 3859 1.1 mrg @item @emph{Class}: 3860 1.1 mrg Collective subroutine 3861 1.1 mrg 3862 1.1 mrg @item @emph{Syntax}: 3863 1.1.1.3 mrg @code{CALL CO_REDUCE(A, OPERATION, [, RESULT_IMAGE, STAT, ERRMSG])} 3864 1.1 mrg 3865 1.1 mrg @item @emph{Arguments}: 3866 1.1.1.2 mrg @multitable @columnfractions .20 .65 3867 1.1 mrg @item @var{A} @tab is an @code{INTENT(INOUT)} argument and shall be 3868 1.1 mrg nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer, 3869 1.1 mrg it shall be associated. @var{A} shall have the same type and type parameters on 3870 1.1 mrg all images of the team; if it is an array, it shall have the same shape on all 3871 1.1 mrg images. 3872 1.1.1.3 mrg @item @var{OPERATION} @tab pure function with two scalar nonallocatable 3873 1.1 mrg arguments, which shall be nonpolymorphic and have the same type and type 3874 1.1 mrg parameters as @var{A}. The function shall return a nonallocatable scalar of 3875 1.1 mrg the same type and type parameters as @var{A}. The function shall be the same on 3876 1.1 mrg all images and with regards to the arguments mathematically commutative and 3877 1.1.1.3 mrg associative. Note that @var{OPERATION} may not be an elemental function, unless 3878 1.1 mrg it is an intrisic function. 3879 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if 3880 1.1.1.3 mrg present, it shall have the same value on all images and refer to an 3881 1.1 mrg image of the current team. 3882 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable 3883 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable 3884 1.1 mrg @end multitable 3885 1.1 mrg 3886 1.1 mrg @item @emph{Example}: 3887 1.1 mrg @smallexample 3888 1.1 mrg program test 3889 1.1 mrg integer :: val 3890 1.1 mrg val = this_image () 3891 1.1.1.3 mrg call co_reduce (val, result_image=1, operation=myprod) 3892 1.1 mrg if (this_image() == 1) then 3893 1.1 mrg write(*,*) "Product value", val ! prints num_images() factorial 3894 1.1 mrg end if 3895 1.1 mrg contains 3896 1.1 mrg pure function myprod(a, b) 3897 1.1 mrg integer, value :: a, b 3898 1.1 mrg integer :: myprod 3899 1.1 mrg myprod = a * b 3900 1.1 mrg end function myprod 3901 1.1 mrg end program test 3902 1.1 mrg @end smallexample 3903 1.1 mrg 3904 1.1 mrg @item @emph{Note}: 3905 1.1 mrg While the rules permit in principle an intrinsic function, none of the 3906 1.1 mrg intrinsics in the standard fulfill the criteria of having a specific 3907 1.1 mrg function, which takes two arguments of the same type and returning that 3908 1.1 mrg type as result. 3909 1.1 mrg 3910 1.1 mrg @item @emph{See also}: 3911 1.1.1.2 mrg @ref{CO_MIN}, @gol 3912 1.1.1.2 mrg @ref{CO_MAX}, @gol 3913 1.1.1.2 mrg @ref{CO_SUM}, @gol 3914 1.1.1.2 mrg @ref{CO_BROADCAST} 3915 1.1 mrg @end table 3916 1.1 mrg 3917 1.1 mrg 3918 1.1 mrg 3919 1.1 mrg @node CO_SUM 3920 1.1 mrg @section @code{CO_SUM} --- Sum of values on the current set of images 3921 1.1 mrg @fnindex CO_SUM 3922 1.1 mrg @cindex Collectives, sum of values 3923 1.1 mrg 3924 1.1 mrg @table @asis 3925 1.1 mrg @item @emph{Description}: 3926 1.1 mrg @code{CO_SUM} sums up the values of each element of @var{A} on all 3927 1.1 mrg images of the current team. If @var{RESULT_IMAGE} is present, the summed-up 3928 1.1 mrg values are returned in @var{A} on the specified image only and the value 3929 1.1 mrg of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is 3930 1.1 mrg not present, the value is returned on all images. If the execution was 3931 1.1 mrg successful and @var{STAT} is present, it is assigned the value zero. If the 3932 1.1 mrg execution failed, @var{STAT} gets assigned a nonzero value and, if present, 3933 1.1 mrg @var{ERRMSG} gets assigned a value describing the occurred error. 3934 1.1 mrg 3935 1.1 mrg @item @emph{Standard}: 3936 1.1 mrg Technical Specification (TS) 18508 or later 3937 1.1 mrg 3938 1.1 mrg @item @emph{Class}: 3939 1.1 mrg Collective subroutine 3940 1.1 mrg 3941 1.1 mrg @item @emph{Syntax}: 3942 1.1.1.3 mrg @code{CALL CO_SUM(A [, RESULT_IMAGE, STAT, ERRMSG])} 3943 1.1 mrg 3944 1.1 mrg @item @emph{Arguments}: 3945 1.1.1.2 mrg @multitable @columnfractions .20 .65 3946 1.1 mrg @item @var{A} @tab shall be an integer, real or complex variable, 3947 1.1 mrg which has the same type and type parameters on all images of the team. 3948 1.1 mrg @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if 3949 1.1.1.3 mrg present, it shall have the same value on all images and refer to an 3950 1.1 mrg image of the current team. 3951 1.1 mrg @item @var{STAT} @tab (optional) a scalar integer variable 3952 1.1 mrg @item @var{ERRMSG} @tab (optional) a scalar character variable 3953 1.1 mrg @end multitable 3954 1.1 mrg 3955 1.1 mrg @item @emph{Example}: 3956 1.1 mrg @smallexample 3957 1.1 mrg program test 3958 1.1 mrg integer :: val 3959 1.1 mrg val = this_image () 3960 1.1 mrg call co_sum (val, result_image=1) 3961 1.1 mrg if (this_image() == 1) then 3962 1.1.1.2 mrg write(*,*) "The sum is ", val ! prints (n**2 + n)/2, 3963 1.1.1.2 mrg ! with n = num_images() 3964 1.1 mrg end if 3965 1.1 mrg end program test 3966 1.1 mrg @end smallexample 3967 1.1 mrg 3968 1.1 mrg @item @emph{See also}: 3969 1.1.1.2 mrg @ref{CO_MAX}, @gol 3970 1.1.1.2 mrg @ref{CO_MIN}, @gol 3971 1.1.1.2 mrg @ref{CO_REDUCE}, @gol 3972 1.1.1.2 mrg @ref{CO_BROADCAST} 3973 1.1 mrg @end table 3974 1.1 mrg 3975 1.1 mrg 3976 1.1 mrg 3977 1.1 mrg @node COMMAND_ARGUMENT_COUNT 3978 1.1 mrg @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments 3979 1.1 mrg @fnindex COMMAND_ARGUMENT_COUNT 3980 1.1 mrg @cindex command-line arguments 3981 1.1 mrg @cindex command-line arguments, number of 3982 1.1 mrg @cindex arguments, to program 3983 1.1 mrg 3984 1.1 mrg @table @asis 3985 1.1 mrg @item @emph{Description}: 3986 1.1 mrg @code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the 3987 1.1 mrg command line when the containing program was invoked. 3988 1.1 mrg 3989 1.1 mrg @item @emph{Standard}: 3990 1.1 mrg Fortran 2003 and later 3991 1.1 mrg 3992 1.1 mrg @item @emph{Class}: 3993 1.1 mrg Inquiry function 3994 1.1 mrg 3995 1.1 mrg @item @emph{Syntax}: 3996 1.1 mrg @code{RESULT = COMMAND_ARGUMENT_COUNT()} 3997 1.1 mrg 3998 1.1 mrg @item @emph{Arguments}: 3999 1.1 mrg @multitable @columnfractions .15 .70 4000 1.1 mrg @item None 4001 1.1 mrg @end multitable 4002 1.1 mrg 4003 1.1 mrg @item @emph{Return value}: 4004 1.1 mrg The return value is an @code{INTEGER} of default kind. 4005 1.1 mrg 4006 1.1 mrg @item @emph{Example}: 4007 1.1 mrg @smallexample 4008 1.1 mrg program test_command_argument_count 4009 1.1 mrg integer :: count 4010 1.1 mrg count = command_argument_count() 4011 1.1 mrg print *, count 4012 1.1 mrg end program test_command_argument_count 4013 1.1 mrg @end smallexample 4014 1.1 mrg 4015 1.1 mrg @item @emph{See also}: 4016 1.1.1.2 mrg @ref{GET_COMMAND}, @gol 4017 1.1.1.2 mrg @ref{GET_COMMAND_ARGUMENT} 4018 1.1 mrg @end table 4019 1.1 mrg 4020 1.1 mrg 4021 1.1 mrg 4022 1.1 mrg @node COMPILER_OPTIONS 4023 1.1 mrg @section @code{COMPILER_OPTIONS} --- Options passed to the compiler 4024 1.1 mrg @fnindex COMPILER_OPTIONS 4025 1.1 mrg @cindex flags inquiry function 4026 1.1 mrg @cindex options inquiry function 4027 1.1 mrg @cindex compiler flags inquiry function 4028 1.1 mrg 4029 1.1 mrg @table @asis 4030 1.1 mrg @item @emph{Description}: 4031 1.1 mrg @code{COMPILER_OPTIONS} returns a string with the options used for 4032 1.1 mrg compiling. 4033 1.1 mrg 4034 1.1 mrg @item @emph{Standard}: 4035 1.1 mrg Fortran 2008 4036 1.1 mrg 4037 1.1 mrg @item @emph{Class}: 4038 1.1 mrg Inquiry function of the module @code{ISO_FORTRAN_ENV} 4039 1.1 mrg 4040 1.1 mrg @item @emph{Syntax}: 4041 1.1 mrg @code{STR = COMPILER_OPTIONS()} 4042 1.1 mrg 4043 1.1 mrg @item @emph{Arguments}: 4044 1.1.1.2 mrg None 4045 1.1 mrg 4046 1.1 mrg @item @emph{Return value}: 4047 1.1 mrg The return value is a default-kind string with system-dependent length. 4048 1.1 mrg It contains the compiler flags used to compile the file, which called 4049 1.1 mrg the @code{COMPILER_OPTIONS} intrinsic. 4050 1.1 mrg 4051 1.1 mrg @item @emph{Example}: 4052 1.1 mrg @smallexample 4053 1.1 mrg use iso_fortran_env 4054 1.1 mrg print '(4a)', 'This file was compiled by ', & 4055 1.1 mrg compiler_version(), ' using the options ', & 4056 1.1 mrg compiler_options() 4057 1.1 mrg end 4058 1.1 mrg @end smallexample 4059 1.1 mrg 4060 1.1 mrg @item @emph{See also}: 4061 1.1.1.2 mrg @ref{COMPILER_VERSION}, @gol 4062 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV} 4063 1.1 mrg @end table 4064 1.1 mrg 4065 1.1 mrg 4066 1.1 mrg 4067 1.1 mrg @node COMPILER_VERSION 4068 1.1 mrg @section @code{COMPILER_VERSION} --- Compiler version string 4069 1.1 mrg @fnindex COMPILER_VERSION 4070 1.1 mrg @cindex compiler, name and version 4071 1.1 mrg @cindex version of the compiler 4072 1.1 mrg 4073 1.1 mrg @table @asis 4074 1.1 mrg @item @emph{Description}: 4075 1.1 mrg @code{COMPILER_VERSION} returns a string with the name and the 4076 1.1 mrg version of the compiler. 4077 1.1 mrg 4078 1.1 mrg @item @emph{Standard}: 4079 1.1 mrg Fortran 2008 4080 1.1 mrg 4081 1.1 mrg @item @emph{Class}: 4082 1.1 mrg Inquiry function of the module @code{ISO_FORTRAN_ENV} 4083 1.1 mrg 4084 1.1 mrg @item @emph{Syntax}: 4085 1.1 mrg @code{STR = COMPILER_VERSION()} 4086 1.1 mrg 4087 1.1 mrg @item @emph{Arguments}: 4088 1.1.1.2 mrg None 4089 1.1 mrg 4090 1.1 mrg @item @emph{Return value}: 4091 1.1 mrg The return value is a default-kind string with system-dependent length. 4092 1.1 mrg It contains the name of the compiler and its version number. 4093 1.1 mrg 4094 1.1 mrg @item @emph{Example}: 4095 1.1 mrg @smallexample 4096 1.1 mrg use iso_fortran_env 4097 1.1 mrg print '(4a)', 'This file was compiled by ', & 4098 1.1 mrg compiler_version(), ' using the options ', & 4099 1.1 mrg compiler_options() 4100 1.1 mrg end 4101 1.1 mrg @end smallexample 4102 1.1 mrg 4103 1.1 mrg @item @emph{See also}: 4104 1.1.1.2 mrg @ref{COMPILER_OPTIONS}, @gol 4105 1.1.1.2 mrg @ref{ISO_FORTRAN_ENV} 4106 1.1 mrg @end table 4107 1.1 mrg 4108 1.1 mrg 4109 1.1 mrg 4110 1.1 mrg @node COMPLEX 4111 1.1 mrg @section @code{COMPLEX} --- Complex conversion function 4112 1.1 mrg @fnindex COMPLEX 4113 1.1 mrg @cindex complex numbers, conversion to 4114 1.1 mrg @cindex conversion, to complex 4115 1.1 mrg 4116 1.1 mrg @table @asis 4117 1.1 mrg @item @emph{Description}: 4118 1.1 mrg @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted 4119 1.1 mrg to the real component and @var{Y} is converted to the imaginary 4120 1.1 mrg component. 4121 1.1 mrg 4122 1.1 mrg @item @emph{Standard}: 4123 1.1 mrg GNU extension 4124 1.1 mrg 4125 1.1 mrg @item @emph{Class}: 4126 1.1 mrg Elemental function 4127 1.1 mrg 4128 1.1 mrg @item @emph{Syntax}: 4129 1.1 mrg @code{RESULT = COMPLEX(X, Y)} 4130 1.1 mrg 4131 1.1 mrg @item @emph{Arguments}: 4132 1.1 mrg @multitable @columnfractions .15 .70 4133 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}. 4134 1.1 mrg @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}. 4135 1.1 mrg @end multitable 4136 1.1 mrg 4137 1.1 mrg @item @emph{Return value}: 4138 1.1 mrg If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return 4139 1.1 mrg value is of default @code{COMPLEX} type. 4140 1.1 mrg 4141 1.1 mrg If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL} 4142 1.1 mrg type and one is of @code{INTEGER} type, then the return value is of 4143 1.1 mrg @code{COMPLEX} type with a kind equal to that of the @code{REAL} 4144 1.1 mrg argument with the highest precision. 4145 1.1 mrg 4146 1.1 mrg @item @emph{Example}: 4147 1.1 mrg @smallexample 4148 1.1 mrg program test_complex 4149 1.1 mrg integer :: i = 42 4150 1.1 mrg real :: x = 3.14 4151 1.1 mrg print *, complex(i, x) 4152 1.1 mrg end program test_complex 4153 1.1 mrg @end smallexample 4154 1.1 mrg 4155 1.1 mrg @item @emph{See also}: 4156 1.1 mrg @ref{CMPLX} 4157 1.1 mrg @end table 4158 1.1 mrg 4159 1.1 mrg 4160 1.1 mrg 4161 1.1 mrg @node CONJG 4162 1.1 mrg @section @code{CONJG} --- Complex conjugate function 4163 1.1 mrg @fnindex CONJG 4164 1.1 mrg @fnindex DCONJG 4165 1.1 mrg @cindex complex conjugate 4166 1.1 mrg 4167 1.1 mrg @table @asis 4168 1.1 mrg @item @emph{Description}: 4169 1.1 mrg @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)} 4170 1.1 mrg then the result is @code{(x, -y)} 4171 1.1 mrg 4172 1.1 mrg @item @emph{Standard}: 4173 1.1.1.2 mrg Fortran 77 and later, has an overload that is a GNU extension 4174 1.1 mrg 4175 1.1 mrg @item @emph{Class}: 4176 1.1 mrg Elemental function 4177 1.1 mrg 4178 1.1 mrg @item @emph{Syntax}: 4179 1.1 mrg @code{Z = CONJG(Z)} 4180 1.1 mrg 4181 1.1 mrg @item @emph{Arguments}: 4182 1.1 mrg @multitable @columnfractions .15 .70 4183 1.1 mrg @item @var{Z} @tab The type shall be @code{COMPLEX}. 4184 1.1 mrg @end multitable 4185 1.1 mrg 4186 1.1 mrg @item @emph{Return value}: 4187 1.1 mrg The return value is of type @code{COMPLEX}. 4188 1.1 mrg 4189 1.1 mrg @item @emph{Example}: 4190 1.1 mrg @smallexample 4191 1.1 mrg program test_conjg 4192 1.1 mrg complex :: z = (2.0, 3.0) 4193 1.1 mrg complex(8) :: dz = (2.71_8, -3.14_8) 4194 1.1 mrg z= conjg(z) 4195 1.1 mrg print *, z 4196 1.1 mrg dz = dconjg(dz) 4197 1.1 mrg print *, dz 4198 1.1 mrg end program test_conjg 4199 1.1 mrg @end smallexample 4200 1.1 mrg 4201 1.1 mrg @item @emph{Specific names}: 4202 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 4203 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 4204 1.1 mrg @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension 4205 1.1 mrg @end multitable 4206 1.1 mrg @end table 4207 1.1 mrg 4208 1.1 mrg 4209 1.1 mrg 4210 1.1 mrg @node COS 4211 1.1 mrg @section @code{COS} --- Cosine function 4212 1.1 mrg @fnindex COS 4213 1.1 mrg @fnindex DCOS 4214 1.1 mrg @fnindex CCOS 4215 1.1 mrg @fnindex ZCOS 4216 1.1 mrg @fnindex CDCOS 4217 1.1 mrg @cindex trigonometric function, cosine 4218 1.1 mrg @cindex cosine 4219 1.1 mrg 4220 1.1 mrg @table @asis 4221 1.1 mrg @item @emph{Description}: 4222 1.1 mrg @code{COS(X)} computes the cosine of @var{X}. 4223 1.1 mrg 4224 1.1 mrg @item @emph{Standard}: 4225 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions 4226 1.1 mrg 4227 1.1 mrg @item @emph{Class}: 4228 1.1 mrg Elemental function 4229 1.1 mrg 4230 1.1 mrg @item @emph{Syntax}: 4231 1.1 mrg @code{RESULT = COS(X)} 4232 1.1 mrg 4233 1.1 mrg @item @emph{Arguments}: 4234 1.1 mrg @multitable @columnfractions .15 .70 4235 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or 4236 1.1 mrg @code{COMPLEX}. 4237 1.1 mrg @end multitable 4238 1.1 mrg 4239 1.1 mrg @item @emph{Return value}: 4240 1.1 mrg The return value is of the same type and kind as @var{X}. The real part 4241 1.1 mrg of the result is in radians. If @var{X} is of the type @code{REAL}, 4242 1.1 mrg the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}. 4243 1.1 mrg 4244 1.1 mrg @item @emph{Example}: 4245 1.1 mrg @smallexample 4246 1.1 mrg program test_cos 4247 1.1 mrg real :: x = 0.0 4248 1.1 mrg x = cos(x) 4249 1.1 mrg end program test_cos 4250 1.1 mrg @end smallexample 4251 1.1 mrg 4252 1.1 mrg @item @emph{Specific names}: 4253 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 4254 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 4255 1.1 mrg @item @code{COS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 4256 1.1 mrg @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 4257 1.1 mrg @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later 4258 1.1 mrg @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 4259 1.1 mrg @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 4260 1.1 mrg @end multitable 4261 1.1 mrg 4262 1.1 mrg @item @emph{See also}: 4263 1.1.1.2 mrg Inverse function: @gol 4264 1.1.1.2 mrg @ref{ACOS} @gol 4265 1.1.1.2 mrg Degrees function: @gol 4266 1.1.1.2 mrg @ref{COSD} 4267 1.1 mrg @end table 4268 1.1 mrg 4269 1.1 mrg 4270 1.1 mrg 4271 1.1 mrg @node COSD 4272 1.1 mrg @section @code{COSD} --- Cosine function, degrees 4273 1.1 mrg @fnindex COSD 4274 1.1 mrg @fnindex DCOSD 4275 1.1 mrg @fnindex CCOSD 4276 1.1 mrg @fnindex ZCOSD 4277 1.1 mrg @fnindex CDCOSD 4278 1.1 mrg @cindex trigonometric function, cosine, degrees 4279 1.1 mrg @cindex cosine, degrees 4280 1.1 mrg 4281 1.1 mrg @table @asis 4282 1.1 mrg @item @emph{Description}: 4283 1.1 mrg @code{COSD(X)} computes the cosine of @var{X} in degrees. 4284 1.1 mrg 4285 1.1 mrg This function is for compatibility only and should be avoided in favor of 4286 1.1 mrg standard constructs wherever possible. 4287 1.1 mrg 4288 1.1 mrg @item @emph{Standard}: 4289 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}. 4290 1.1 mrg 4291 1.1 mrg @item @emph{Class}: 4292 1.1 mrg Elemental function 4293 1.1 mrg 4294 1.1 mrg @item @emph{Syntax}: 4295 1.1 mrg @code{RESULT = COSD(X)} 4296 1.1 mrg 4297 1.1 mrg @item @emph{Arguments}: 4298 1.1 mrg @multitable @columnfractions .15 .70 4299 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or 4300 1.1 mrg @code{COMPLEX}. 4301 1.1 mrg @end multitable 4302 1.1 mrg 4303 1.1 mrg @item @emph{Return value}: 4304 1.1 mrg The return value is of the same type and kind as @var{X}. The real part 4305 1.1 mrg of the result is in degrees. If @var{X} is of the type @code{REAL}, 4306 1.1 mrg the return value lies in the range @math{ -1 \leq \cosd (x) \leq 1}. 4307 1.1 mrg 4308 1.1 mrg @item @emph{Example}: 4309 1.1 mrg @smallexample 4310 1.1 mrg program test_cosd 4311 1.1 mrg real :: x = 0.0 4312 1.1 mrg x = cosd(x) 4313 1.1 mrg end program test_cosd 4314 1.1 mrg @end smallexample 4315 1.1 mrg 4316 1.1 mrg @item @emph{Specific names}: 4317 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 4318 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 4319 1.1.1.2 mrg @item @code{COSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 4320 1.1.1.2 mrg @item @code{DCOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 4321 1.1.1.2 mrg @item @code{CCOSD(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension 4322 1.1 mrg @item @code{ZCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 4323 1.1 mrg @item @code{CDCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 4324 1.1 mrg @end multitable 4325 1.1 mrg 4326 1.1 mrg @item @emph{See also}: 4327 1.1.1.2 mrg Inverse function: @gol 4328 1.1.1.2 mrg @ref{ACOSD} @gol 4329 1.1.1.2 mrg Radians function: @gol 4330 1.1.1.2 mrg @ref{COS} 4331 1.1 mrg @end table 4332 1.1 mrg 4333 1.1 mrg 4334 1.1 mrg 4335 1.1 mrg @node COSH 4336 1.1 mrg @section @code{COSH} --- Hyperbolic cosine function 4337 1.1 mrg @fnindex COSH 4338 1.1 mrg @fnindex DCOSH 4339 1.1 mrg @cindex hyperbolic cosine 4340 1.1 mrg @cindex hyperbolic function, cosine 4341 1.1 mrg @cindex cosine, hyperbolic 4342 1.1 mrg 4343 1.1 mrg @table @asis 4344 1.1 mrg @item @emph{Description}: 4345 1.1 mrg @code{COSH(X)} computes the hyperbolic cosine of @var{X}. 4346 1.1 mrg 4347 1.1 mrg @item @emph{Standard}: 4348 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later 4349 1.1 mrg 4350 1.1 mrg @item @emph{Class}: 4351 1.1 mrg Elemental function 4352 1.1 mrg 4353 1.1 mrg @item @emph{Syntax}: 4354 1.1 mrg @code{X = COSH(X)} 4355 1.1 mrg 4356 1.1 mrg @item @emph{Arguments}: 4357 1.1 mrg @multitable @columnfractions .15 .70 4358 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 4359 1.1 mrg @end multitable 4360 1.1 mrg 4361 1.1 mrg @item @emph{Return value}: 4362 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is 4363 1.1 mrg complex, the imaginary part of the result is in radians. If @var{X} 4364 1.1 mrg is @code{REAL}, the return value has a lower bound of one, 4365 1.1 mrg @math{\cosh (x) \geq 1}. 4366 1.1 mrg 4367 1.1 mrg @item @emph{Example}: 4368 1.1 mrg @smallexample 4369 1.1 mrg program test_cosh 4370 1.1 mrg real(8) :: x = 1.0_8 4371 1.1 mrg x = cosh(x) 4372 1.1 mrg end program test_cosh 4373 1.1 mrg @end smallexample 4374 1.1 mrg 4375 1.1 mrg @item @emph{Specific names}: 4376 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 4377 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 4378 1.1 mrg @item @code{COSH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 4379 1.1 mrg @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 4380 1.1 mrg @end multitable 4381 1.1 mrg 4382 1.1 mrg @item @emph{See also}: 4383 1.1.1.2 mrg Inverse function: @gol 4384 1.1.1.2 mrg @ref{ACOSH} 4385 1.1 mrg @end table 4386 1.1 mrg 4387 1.1 mrg 4388 1.1 mrg 4389 1.1 mrg @node COTAN 4390 1.1 mrg @section @code{COTAN} --- Cotangent function 4391 1.1 mrg @fnindex COTAN 4392 1.1 mrg @fnindex DCOTAN 4393 1.1 mrg @cindex trigonometric function, cotangent 4394 1.1 mrg @cindex cotangent 4395 1.1 mrg 4396 1.1 mrg @table @asis 4397 1.1 mrg @item @emph{Description}: 4398 1.1 mrg @code{COTAN(X)} computes the cotangent of @var{X}. Equivalent to @code{COS(x)} 4399 1.1 mrg divided by @code{SIN(x)}, or @code{1 / TAN(x)}. 4400 1.1 mrg 4401 1.1 mrg This function is for compatibility only and should be avoided in favor of 4402 1.1 mrg standard constructs wherever possible. 4403 1.1 mrg 4404 1.1 mrg @item @emph{Standard}: 4405 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}. 4406 1.1 mrg 4407 1.1 mrg @item @emph{Class}: 4408 1.1 mrg Elemental function 4409 1.1 mrg 4410 1.1 mrg @item @emph{Syntax}: 4411 1.1 mrg @code{RESULT = COTAN(X)} 4412 1.1 mrg 4413 1.1 mrg @item @emph{Arguments}: 4414 1.1 mrg @multitable @columnfractions .15 .70 4415 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 4416 1.1 mrg @end multitable 4417 1.1 mrg 4418 1.1 mrg @item @emph{Return value}: 4419 1.1 mrg The return value has same type and kind as @var{X}, and its value is in radians. 4420 1.1 mrg 4421 1.1 mrg @item @emph{Example}: 4422 1.1 mrg @smallexample 4423 1.1 mrg program test_cotan 4424 1.1 mrg real(8) :: x = 0.165_8 4425 1.1 mrg x = cotan(x) 4426 1.1 mrg end program test_cotan 4427 1.1 mrg @end smallexample 4428 1.1 mrg 4429 1.1 mrg @item @emph{Specific names}: 4430 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 4431 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 4432 1.1.1.2 mrg @item @code{COTAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 4433 1.1.1.2 mrg @item @code{DCOTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 4434 1.1 mrg @end multitable 4435 1.1 mrg 4436 1.1 mrg @item @emph{See also}: 4437 1.1.1.2 mrg Converse function: @gol 4438 1.1.1.2 mrg @ref{TAN} @gol 4439 1.1.1.2 mrg Degrees function: @gol 4440 1.1.1.2 mrg @ref{COTAND} 4441 1.1 mrg @end table 4442 1.1 mrg 4443 1.1 mrg 4444 1.1 mrg 4445 1.1 mrg @node COTAND 4446 1.1 mrg @section @code{COTAND} --- Cotangent function, degrees 4447 1.1 mrg @fnindex COTAND 4448 1.1 mrg @fnindex DCOTAND 4449 1.1 mrg @cindex trigonometric function, cotangent, degrees 4450 1.1 mrg @cindex cotangent, degrees 4451 1.1 mrg 4452 1.1 mrg @table @asis 4453 1.1 mrg @item @emph{Description}: 4454 1.1 mrg @code{COTAND(X)} computes the cotangent of @var{X} in degrees. Equivalent to 4455 1.1 mrg @code{COSD(x)} divided by @code{SIND(x)}, or @code{1 / TAND(x)}. 4456 1.1 mrg 4457 1.1 mrg @item @emph{Standard}: 4458 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}. 4459 1.1 mrg 4460 1.1 mrg This function is for compatibility only and should be avoided in favor of 4461 1.1 mrg standard constructs wherever possible. 4462 1.1 mrg 4463 1.1 mrg @item @emph{Class}: 4464 1.1 mrg Elemental function 4465 1.1 mrg 4466 1.1 mrg @item @emph{Syntax}: 4467 1.1 mrg @code{RESULT = COTAND(X)} 4468 1.1 mrg 4469 1.1 mrg @item @emph{Arguments}: 4470 1.1 mrg @multitable @columnfractions .15 .70 4471 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 4472 1.1 mrg @end multitable 4473 1.1 mrg 4474 1.1 mrg @item @emph{Return value}: 4475 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees. 4476 1.1 mrg 4477 1.1 mrg @item @emph{Example}: 4478 1.1 mrg @smallexample 4479 1.1 mrg program test_cotand 4480 1.1 mrg real(8) :: x = 0.165_8 4481 1.1 mrg x = cotand(x) 4482 1.1 mrg end program test_cotand 4483 1.1 mrg @end smallexample 4484 1.1 mrg 4485 1.1 mrg @item @emph{Specific names}: 4486 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 4487 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 4488 1.1.1.2 mrg @item @code{COTAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 4489 1.1.1.2 mrg @item @code{DCOTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 4490 1.1 mrg @end multitable 4491 1.1 mrg 4492 1.1 mrg @item @emph{See also}: 4493 1.1.1.2 mrg Converse function: @gol 4494 1.1.1.2 mrg @ref{TAND} @gol 4495 1.1.1.2 mrg Radians function: @gol 4496 1.1.1.2 mrg @ref{COTAN} 4497 1.1 mrg @end table 4498 1.1 mrg 4499 1.1 mrg 4500 1.1 mrg 4501 1.1 mrg @node COUNT 4502 1.1 mrg @section @code{COUNT} --- Count function 4503 1.1 mrg @fnindex COUNT 4504 1.1 mrg @cindex array, conditionally count elements 4505 1.1 mrg @cindex array, element counting 4506 1.1 mrg @cindex array, number of elements 4507 1.1 mrg 4508 1.1 mrg @table @asis 4509 1.1 mrg @item @emph{Description}: 4510 1.1 mrg 4511 1.1 mrg Counts the number of @code{.TRUE.} elements in a logical @var{MASK}, 4512 1.1 mrg or, if the @var{DIM} argument is supplied, counts the number of 4513 1.1 mrg elements along each row of the array in the @var{DIM} direction. 4514 1.1 mrg If the array has zero size, or all of the elements of @var{MASK} are 4515 1.1 mrg @code{.FALSE.}, then the result is @code{0}. 4516 1.1 mrg 4517 1.1 mrg @item @emph{Standard}: 4518 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later 4519 1.1 mrg 4520 1.1 mrg @item @emph{Class}: 4521 1.1 mrg Transformational function 4522 1.1 mrg 4523 1.1 mrg @item @emph{Syntax}: 4524 1.1 mrg @code{RESULT = COUNT(MASK [, DIM, KIND])} 4525 1.1 mrg 4526 1.1 mrg @item @emph{Arguments}: 4527 1.1 mrg @multitable @columnfractions .15 .70 4528 1.1 mrg @item @var{MASK} @tab The type shall be @code{LOGICAL}. 4529 1.1 mrg @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}. 4530 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 4531 1.1 mrg expression indicating the kind parameter of the result. 4532 1.1 mrg @end multitable 4533 1.1 mrg 4534 1.1 mrg @item @emph{Return value}: 4535 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 4536 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 4537 1.1 mrg If @var{DIM} is present, the result is an array with a rank one less 4538 1.1 mrg than the rank of @var{ARRAY}, and a size corresponding to the shape 4539 1.1 mrg of @var{ARRAY} with the @var{DIM} dimension removed. 4540 1.1 mrg 4541 1.1 mrg @item @emph{Example}: 4542 1.1 mrg @smallexample 4543 1.1 mrg program test_count 4544 1.1 mrg integer, dimension(2,3) :: a, b 4545 1.1 mrg logical, dimension(2,3) :: mask 4546 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /)) 4547 1.1 mrg b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /)) 4548 1.1 mrg print '(3i3)', a(1,:) 4549 1.1 mrg print '(3i3)', a(2,:) 4550 1.1 mrg print * 4551 1.1 mrg print '(3i3)', b(1,:) 4552 1.1 mrg print '(3i3)', b(2,:) 4553 1.1 mrg print * 4554 1.1 mrg mask = a.ne.b 4555 1.1 mrg print '(3l3)', mask(1,:) 4556 1.1 mrg print '(3l3)', mask(2,:) 4557 1.1 mrg print * 4558 1.1 mrg print '(3i3)', count(mask) 4559 1.1 mrg print * 4560 1.1 mrg print '(3i3)', count(mask, 1) 4561 1.1 mrg print * 4562 1.1 mrg print '(3i3)', count(mask, 2) 4563 1.1 mrg end program test_count 4564 1.1 mrg @end smallexample 4565 1.1 mrg @end table 4566 1.1 mrg 4567 1.1 mrg 4568 1.1 mrg 4569 1.1 mrg @node CPU_TIME 4570 1.1 mrg @section @code{CPU_TIME} --- CPU elapsed time in seconds 4571 1.1 mrg @fnindex CPU_TIME 4572 1.1 mrg @cindex time, elapsed 4573 1.1 mrg 4574 1.1 mrg @table @asis 4575 1.1 mrg @item @emph{Description}: 4576 1.1 mrg Returns a @code{REAL} value representing the elapsed CPU time in 4577 1.1 mrg seconds. This is useful for testing segments of code to determine 4578 1.1 mrg execution time. 4579 1.1 mrg 4580 1.1 mrg If a time source is available, time will be reported with microsecond 4581 1.1 mrg resolution. If no time source is available, @var{TIME} is set to 4582 1.1 mrg @code{-1.0}. 4583 1.1 mrg 4584 1.1 mrg Note that @var{TIME} may contain a, system dependent, arbitrary offset 4585 1.1 mrg and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute 4586 1.1 mrg value is meaningless, only differences between subsequent calls to 4587 1.1 mrg this subroutine, as shown in the example below, should be used. 4588 1.1 mrg 4589 1.1 mrg 4590 1.1 mrg @item @emph{Standard}: 4591 1.1 mrg Fortran 95 and later 4592 1.1 mrg 4593 1.1 mrg @item @emph{Class}: 4594 1.1 mrg Subroutine 4595 1.1 mrg 4596 1.1 mrg @item @emph{Syntax}: 4597 1.1 mrg @code{CALL CPU_TIME(TIME)} 4598 1.1 mrg 4599 1.1 mrg @item @emph{Arguments}: 4600 1.1 mrg @multitable @columnfractions .15 .70 4601 1.1 mrg @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}. 4602 1.1 mrg @end multitable 4603 1.1 mrg 4604 1.1 mrg @item @emph{Return value}: 4605 1.1 mrg None 4606 1.1 mrg 4607 1.1 mrg @item @emph{Example}: 4608 1.1 mrg @smallexample 4609 1.1 mrg program test_cpu_time 4610 1.1 mrg real :: start, finish 4611 1.1 mrg call cpu_time(start) 4612 1.1 mrg ! put code to test here 4613 1.1 mrg call cpu_time(finish) 4614 1.1 mrg print '("Time = ",f6.3," seconds.")',finish-start 4615 1.1 mrg end program test_cpu_time 4616 1.1 mrg @end smallexample 4617 1.1 mrg 4618 1.1 mrg @item @emph{See also}: 4619 1.1.1.2 mrg @ref{SYSTEM_CLOCK}, @gol 4620 1.1.1.2 mrg @ref{DATE_AND_TIME} 4621 1.1 mrg @end table 4622 1.1 mrg 4623 1.1 mrg 4624 1.1 mrg 4625 1.1 mrg @node CSHIFT 4626 1.1 mrg @section @code{CSHIFT} --- Circular shift elements of an array 4627 1.1 mrg @fnindex CSHIFT 4628 1.1 mrg @cindex array, shift circularly 4629 1.1 mrg @cindex array, permutation 4630 1.1 mrg @cindex array, rotate 4631 1.1 mrg 4632 1.1 mrg @table @asis 4633 1.1 mrg @item @emph{Description}: 4634 1.1 mrg @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of 4635 1.1 mrg @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is 4636 1.1 mrg taken to be @code{1}. @var{DIM} is a scalar of type @code{INTEGER} in the 4637 1.1 mrg range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}. 4638 1.1 mrg If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted 4639 1.1 mrg by @var{SHIFT} places. If rank is greater than one, then all complete rank one 4640 1.1 mrg sections of @var{ARRAY} along the given dimension are shifted. Elements 4641 1.1 mrg shifted out one end of each rank one section are shifted back in the other end. 4642 1.1 mrg 4643 1.1 mrg @item @emph{Standard}: 4644 1.1.1.2 mrg Fortran 90 and later 4645 1.1 mrg 4646 1.1 mrg @item @emph{Class}: 4647 1.1 mrg Transformational function 4648 1.1 mrg 4649 1.1 mrg @item @emph{Syntax}: 4650 1.1 mrg @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])} 4651 1.1 mrg 4652 1.1 mrg @item @emph{Arguments}: 4653 1.1 mrg @multitable @columnfractions .15 .70 4654 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type. 4655 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 4656 1.1 mrg @item @var{DIM} @tab The type shall be @code{INTEGER}. 4657 1.1 mrg @end multitable 4658 1.1 mrg 4659 1.1 mrg @item @emph{Return value}: 4660 1.1 mrg Returns an array of same type and rank as the @var{ARRAY} argument. 4661 1.1 mrg 4662 1.1 mrg @item @emph{Example}: 4663 1.1 mrg @smallexample 4664 1.1 mrg program test_cshift 4665 1.1 mrg integer, dimension(3,3) :: a 4666 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /)) 4667 1.1 mrg print '(3i3)', a(1,:) 4668 1.1 mrg print '(3i3)', a(2,:) 4669 1.1 mrg print '(3i3)', a(3,:) 4670 1.1 mrg a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2) 4671 1.1 mrg print * 4672 1.1 mrg print '(3i3)', a(1,:) 4673 1.1 mrg print '(3i3)', a(2,:) 4674 1.1 mrg print '(3i3)', a(3,:) 4675 1.1 mrg end program test_cshift 4676 1.1 mrg @end smallexample 4677 1.1 mrg @end table 4678 1.1 mrg 4679 1.1 mrg 4680 1.1 mrg 4681 1.1 mrg @node CTIME 4682 1.1 mrg @section @code{CTIME} --- Convert a time into a string 4683 1.1 mrg @fnindex CTIME 4684 1.1 mrg @cindex time, conversion to string 4685 1.1 mrg @cindex conversion, to string 4686 1.1 mrg 4687 1.1 mrg @table @asis 4688 1.1 mrg @item @emph{Description}: 4689 1.1 mrg @code{CTIME} converts a system time value, such as returned by 4690 1.1 mrg @ref{TIME8}, to a string. The output will be of the form @samp{Sat 4691 1.1 mrg Aug 19 18:13:14 1995}. 4692 1.1 mrg 4693 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 4694 1.1 mrg only one form can be used in any given program unit. 4695 1.1 mrg 4696 1.1 mrg @item @emph{Standard}: 4697 1.1 mrg GNU extension 4698 1.1 mrg 4699 1.1 mrg @item @emph{Class}: 4700 1.1 mrg Subroutine, function 4701 1.1 mrg 4702 1.1 mrg @item @emph{Syntax}: 4703 1.1 mrg @multitable @columnfractions .80 4704 1.1 mrg @item @code{CALL CTIME(TIME, RESULT)}. 4705 1.1 mrg @item @code{RESULT = CTIME(TIME)}. 4706 1.1 mrg @end multitable 4707 1.1 mrg 4708 1.1 mrg @item @emph{Arguments}: 4709 1.1 mrg @multitable @columnfractions .15 .70 4710 1.1 mrg @item @var{TIME} @tab The type shall be of type @code{INTEGER}. 4711 1.1 mrg @item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and 4712 1.1 mrg of default kind. It is an @code{INTENT(OUT)} argument. If the length 4713 1.1 mrg of this variable is too short for the time and date string to fit 4714 1.1 mrg completely, it will be blank on procedure return. 4715 1.1 mrg @end multitable 4716 1.1 mrg 4717 1.1 mrg @item @emph{Return value}: 4718 1.1 mrg The converted date and time as a string. 4719 1.1 mrg 4720 1.1 mrg @item @emph{Example}: 4721 1.1 mrg @smallexample 4722 1.1 mrg program test_ctime 4723 1.1 mrg integer(8) :: i 4724 1.1 mrg character(len=30) :: date 4725 1.1 mrg i = time8() 4726 1.1 mrg 4727 1.1 mrg ! Do something, main part of the program 4728 1.1 mrg 4729 1.1 mrg call ctime(i,date) 4730 1.1 mrg print *, 'Program was started on ', date 4731 1.1 mrg end program test_ctime 4732 1.1 mrg @end smallexample 4733 1.1 mrg 4734 1.1 mrg @item @emph{See Also}: 4735 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol 4736 1.1.1.2 mrg @ref{GMTIME}, @gol 4737 1.1.1.2 mrg @ref{LTIME}, @gol 4738 1.1.1.2 mrg @ref{TIME}, @gol 4739 1.1.1.2 mrg @ref{TIME8} 4740 1.1 mrg @end table 4741 1.1 mrg 4742 1.1 mrg 4743 1.1 mrg 4744 1.1 mrg @node DATE_AND_TIME 4745 1.1 mrg @section @code{DATE_AND_TIME} --- Date and time subroutine 4746 1.1 mrg @fnindex DATE_AND_TIME 4747 1.1 mrg @cindex date, current 4748 1.1 mrg @cindex current date 4749 1.1 mrg @cindex time, current 4750 1.1 mrg @cindex current time 4751 1.1 mrg 4752 1.1 mrg @table @asis 4753 1.1 mrg @item @emph{Description}: 4754 1.1 mrg @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and 4755 1.1 mrg time information from the real-time system clock. @var{DATE} is 4756 1.1 mrg @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and 4757 1.1 mrg has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm, 4758 1.1 mrg representing the difference with respect to Coordinated Universal Time (UTC). 4759 1.1 mrg Unavailable time and date parameters return blanks. 4760 1.1 mrg 4761 1.1 mrg @var{VALUES} is @code{INTENT(OUT)} and provides the following: 4762 1.1 mrg 4763 1.1.1.3 mrg @multitable @columnfractions .15 .70 4764 1.1.1.3 mrg @item @code{VALUE(1)}: @tab The year 4765 1.1.1.3 mrg @item @code{VALUE(2)}: @tab The month 4766 1.1.1.3 mrg @item @code{VALUE(3)}: @tab The day of the month 4767 1.1.1.3 mrg @item @code{VALUE(4)}: @tab Time difference with UTC in minutes 4768 1.1.1.3 mrg @item @code{VALUE(5)}: @tab The hour of the day 4769 1.1.1.3 mrg @item @code{VALUE(6)}: @tab The minutes of the hour 4770 1.1.1.3 mrg @item @code{VALUE(7)}: @tab The seconds of the minute 4771 1.1.1.3 mrg @item @code{VALUE(8)}: @tab The milliseconds of the second 4772 1.1 mrg @end multitable 4773 1.1 mrg 4774 1.1 mrg @item @emph{Standard}: 4775 1.1.1.2 mrg Fortran 90 and later 4776 1.1 mrg 4777 1.1 mrg @item @emph{Class}: 4778 1.1 mrg Subroutine 4779 1.1 mrg 4780 1.1 mrg @item @emph{Syntax}: 4781 1.1 mrg @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])} 4782 1.1 mrg 4783 1.1 mrg @item @emph{Arguments}: 4784 1.1 mrg @multitable @columnfractions .15 .70 4785 1.1 mrg @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)} 4786 1.1 mrg or larger, and of default kind. 4787 1.1 mrg @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)} 4788 1.1 mrg or larger, and of default kind. 4789 1.1 mrg @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)} 4790 1.1 mrg or larger, and of default kind. 4791 1.1 mrg @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}. 4792 1.1 mrg @end multitable 4793 1.1 mrg 4794 1.1 mrg @item @emph{Return value}: 4795 1.1 mrg None 4796 1.1 mrg 4797 1.1 mrg @item @emph{Example}: 4798 1.1 mrg @smallexample 4799 1.1 mrg program test_time_and_date 4800 1.1 mrg character(8) :: date 4801 1.1 mrg character(10) :: time 4802 1.1 mrg character(5) :: zone 4803 1.1 mrg integer,dimension(8) :: values 4804 1.1 mrg ! using keyword arguments 4805 1.1 mrg call date_and_time(date,time,zone,values) 4806 1.1 mrg call date_and_time(DATE=date,ZONE=zone) 4807 1.1 mrg call date_and_time(TIME=time) 4808 1.1 mrg call date_and_time(VALUES=values) 4809 1.1 mrg print '(a,2x,a,2x,a)', date, time, zone 4810 1.1 mrg print '(8i5)', values 4811 1.1 mrg end program test_time_and_date 4812 1.1 mrg @end smallexample 4813 1.1 mrg 4814 1.1 mrg @item @emph{See also}: 4815 1.1.1.2 mrg @ref{CPU_TIME}, @gol 4816 1.1.1.2 mrg @ref{SYSTEM_CLOCK} 4817 1.1 mrg @end table 4818 1.1 mrg 4819 1.1 mrg 4820 1.1 mrg 4821 1.1 mrg @node DBLE 4822 1.1 mrg @section @code{DBLE} --- Double conversion function 4823 1.1 mrg @fnindex DBLE 4824 1.1 mrg @cindex conversion, to real 4825 1.1 mrg 4826 1.1 mrg @table @asis 4827 1.1 mrg @item @emph{Description}: 4828 1.1 mrg @code{DBLE(A)} Converts @var{A} to double precision real type. 4829 1.1 mrg 4830 1.1 mrg @item @emph{Standard}: 4831 1.1 mrg Fortran 77 and later 4832 1.1 mrg 4833 1.1 mrg @item @emph{Class}: 4834 1.1 mrg Elemental function 4835 1.1 mrg 4836 1.1 mrg @item @emph{Syntax}: 4837 1.1 mrg @code{RESULT = DBLE(A)} 4838 1.1 mrg 4839 1.1 mrg @item @emph{Arguments}: 4840 1.1 mrg @multitable @columnfractions .15 .70 4841 1.1 mrg @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL}, 4842 1.1 mrg or @code{COMPLEX}. 4843 1.1 mrg @end multitable 4844 1.1 mrg 4845 1.1 mrg @item @emph{Return value}: 4846 1.1 mrg The return value is of type double precision real. 4847 1.1 mrg 4848 1.1 mrg @item @emph{Example}: 4849 1.1 mrg @smallexample 4850 1.1 mrg program test_dble 4851 1.1 mrg real :: x = 2.18 4852 1.1 mrg integer :: i = 5 4853 1.1 mrg complex :: z = (2.3,1.14) 4854 1.1 mrg print *, dble(x), dble(i), dble(z) 4855 1.1 mrg end program test_dble 4856 1.1 mrg @end smallexample 4857 1.1 mrg 4858 1.1 mrg @item @emph{See also}: 4859 1.1 mrg @ref{REAL} 4860 1.1 mrg @end table 4861 1.1 mrg 4862 1.1 mrg 4863 1.1 mrg 4864 1.1 mrg @node DCMPLX 4865 1.1 mrg @section @code{DCMPLX} --- Double complex conversion function 4866 1.1 mrg @fnindex DCMPLX 4867 1.1 mrg @cindex complex numbers, conversion to 4868 1.1 mrg @cindex conversion, to complex 4869 1.1 mrg 4870 1.1 mrg @table @asis 4871 1.1 mrg @item @emph{Description}: 4872 1.1 mrg @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is 4873 1.1 mrg converted to the real component. If @var{Y} is present it is converted to the 4874 1.1 mrg imaginary component. If @var{Y} is not present then the imaginary component is 4875 1.1 mrg set to 0.0. If @var{X} is complex then @var{Y} must not be present. 4876 1.1 mrg 4877 1.1 mrg @item @emph{Standard}: 4878 1.1 mrg GNU extension 4879 1.1 mrg 4880 1.1 mrg @item @emph{Class}: 4881 1.1 mrg Elemental function 4882 1.1 mrg 4883 1.1 mrg @item @emph{Syntax}: 4884 1.1 mrg @code{RESULT = DCMPLX(X [, Y])} 4885 1.1 mrg 4886 1.1 mrg @item @emph{Arguments}: 4887 1.1 mrg @multitable @columnfractions .15 .70 4888 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL}, 4889 1.1 mrg or @code{COMPLEX}. 4890 1.1 mrg @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be 4891 1.1 mrg @code{INTEGER} or @code{REAL}. 4892 1.1 mrg @end multitable 4893 1.1 mrg 4894 1.1 mrg @item @emph{Return value}: 4895 1.1 mrg The return value is of type @code{COMPLEX(8)} 4896 1.1 mrg 4897 1.1 mrg @item @emph{Example}: 4898 1.1 mrg @smallexample 4899 1.1 mrg program test_dcmplx 4900 1.1 mrg integer :: i = 42 4901 1.1 mrg real :: x = 3.14 4902 1.1 mrg complex :: z 4903 1.1 mrg z = cmplx(i, x) 4904 1.1 mrg print *, dcmplx(i) 4905 1.1 mrg print *, dcmplx(x) 4906 1.1 mrg print *, dcmplx(z) 4907 1.1 mrg print *, dcmplx(x,i) 4908 1.1 mrg end program test_dcmplx 4909 1.1 mrg @end smallexample 4910 1.1 mrg @end table 4911 1.1 mrg 4912 1.1 mrg 4913 1.1 mrg @node DIGITS 4914 1.1 mrg @section @code{DIGITS} --- Significant binary digits function 4915 1.1 mrg @fnindex DIGITS 4916 1.1 mrg @cindex model representation, significant digits 4917 1.1 mrg 4918 1.1 mrg @table @asis 4919 1.1 mrg @item @emph{Description}: 4920 1.1 mrg @code{DIGITS(X)} returns the number of significant binary digits of the internal 4921 1.1 mrg model representation of @var{X}. For example, on a system using a 32-bit 4922 1.1 mrg floating point representation, a default real number would likely return 24. 4923 1.1 mrg 4924 1.1 mrg @item @emph{Standard}: 4925 1.1.1.2 mrg Fortran 90 and later 4926 1.1 mrg 4927 1.1 mrg @item @emph{Class}: 4928 1.1 mrg Inquiry function 4929 1.1 mrg 4930 1.1 mrg @item @emph{Syntax}: 4931 1.1 mrg @code{RESULT = DIGITS(X)} 4932 1.1 mrg 4933 1.1 mrg @item @emph{Arguments}: 4934 1.1 mrg @multitable @columnfractions .15 .70 4935 1.1 mrg @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}. 4936 1.1 mrg @end multitable 4937 1.1 mrg 4938 1.1 mrg @item @emph{Return value}: 4939 1.1 mrg The return value is of type @code{INTEGER}. 4940 1.1 mrg 4941 1.1 mrg @item @emph{Example}: 4942 1.1 mrg @smallexample 4943 1.1 mrg program test_digits 4944 1.1 mrg integer :: i = 12345 4945 1.1 mrg real :: x = 3.143 4946 1.1 mrg real(8) :: y = 2.33 4947 1.1 mrg print *, digits(i) 4948 1.1 mrg print *, digits(x) 4949 1.1 mrg print *, digits(y) 4950 1.1 mrg end program test_digits 4951 1.1 mrg @end smallexample 4952 1.1 mrg @end table 4953 1.1 mrg 4954 1.1 mrg 4955 1.1 mrg 4956 1.1 mrg @node DIM 4957 1.1 mrg @section @code{DIM} --- Positive difference 4958 1.1 mrg @fnindex DIM 4959 1.1 mrg @fnindex IDIM 4960 1.1 mrg @fnindex DDIM 4961 1.1 mrg @cindex positive difference 4962 1.1 mrg 4963 1.1 mrg @table @asis 4964 1.1 mrg @item @emph{Description}: 4965 1.1 mrg @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive; 4966 1.1 mrg otherwise returns zero. 4967 1.1 mrg 4968 1.1 mrg @item @emph{Standard}: 4969 1.1 mrg Fortran 77 and later 4970 1.1 mrg 4971 1.1 mrg @item @emph{Class}: 4972 1.1 mrg Elemental function 4973 1.1 mrg 4974 1.1 mrg @item @emph{Syntax}: 4975 1.1 mrg @code{RESULT = DIM(X, Y)} 4976 1.1 mrg 4977 1.1 mrg @item @emph{Arguments}: 4978 1.1 mrg @multitable @columnfractions .15 .70 4979 1.1 mrg @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL} 4980 1.1.1.2 mrg @item @var{Y} @tab The type shall be the same type and kind as @var{X}. (As 4981 1.1.1.2 mrg a GNU extension, arguments of different kinds are permitted.) 4982 1.1 mrg @end multitable 4983 1.1 mrg 4984 1.1 mrg @item @emph{Return value}: 4985 1.1.1.2 mrg The return value is of type @code{INTEGER} or @code{REAL}. (As a GNU 4986 1.1.1.2 mrg extension, kind is the largest kind of the actual arguments.) 4987 1.1 mrg 4988 1.1 mrg @item @emph{Example}: 4989 1.1 mrg @smallexample 4990 1.1 mrg program test_dim 4991 1.1 mrg integer :: i 4992 1.1 mrg real(8) :: x 4993 1.1 mrg i = dim(4, 15) 4994 1.1 mrg x = dim(4.345_8, 2.111_8) 4995 1.1 mrg print *, i 4996 1.1 mrg print *, x 4997 1.1 mrg end program test_dim 4998 1.1 mrg @end smallexample 4999 1.1 mrg 5000 1.1 mrg @item @emph{Specific names}: 5001 1.1.1.3 mrg @multitable @columnfractions .20 .26 .20 .30 5002 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 5003 1.1 mrg @item @code{DIM(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later 5004 1.1 mrg @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later 5005 1.1 mrg @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later 5006 1.1 mrg @end multitable 5007 1.1 mrg @end table 5008 1.1 mrg 5009 1.1 mrg 5010 1.1 mrg 5011 1.1 mrg @node DOT_PRODUCT 5012 1.1 mrg @section @code{DOT_PRODUCT} --- Dot product function 5013 1.1 mrg @fnindex DOT_PRODUCT 5014 1.1 mrg @cindex dot product 5015 1.1 mrg @cindex vector product 5016 1.1 mrg @cindex product, vector 5017 1.1 mrg 5018 1.1 mrg @table @asis 5019 1.1 mrg @item @emph{Description}: 5020 1.1 mrg @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication 5021 1.1 mrg of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be 5022 1.1 mrg either numeric or logical and must be arrays of rank one and of equal size. If 5023 1.1 mrg the vectors are @code{INTEGER} or @code{REAL}, the result is 5024 1.1 mrg @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result 5025 1.1 mrg is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL}, 5026 1.1 mrg the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}. 5027 1.1 mrg 5028 1.1 mrg @item @emph{Standard}: 5029 1.1.1.2 mrg Fortran 90 and later 5030 1.1 mrg 5031 1.1 mrg @item @emph{Class}: 5032 1.1 mrg Transformational function 5033 1.1 mrg 5034 1.1 mrg @item @emph{Syntax}: 5035 1.1 mrg @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)} 5036 1.1 mrg 5037 1.1 mrg @item @emph{Arguments}: 5038 1.1 mrg @multitable @columnfractions .15 .70 5039 1.1 mrg @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1. 5040 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. 5041 1.1 mrg @end multitable 5042 1.1 mrg 5043 1.1 mrg @item @emph{Return value}: 5044 1.1 mrg If the arguments are numeric, the return value is a scalar of numeric type, 5045 1.1 mrg @code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are 5046 1.1 mrg @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}. 5047 1.1 mrg 5048 1.1 mrg @item @emph{Example}: 5049 1.1 mrg @smallexample 5050 1.1 mrg program test_dot_prod 5051 1.1 mrg integer, dimension(3) :: a, b 5052 1.1 mrg a = (/ 1, 2, 3 /) 5053 1.1 mrg b = (/ 4, 5, 6 /) 5054 1.1 mrg print '(3i3)', a 5055 1.1 mrg print * 5056 1.1 mrg print '(3i3)', b 5057 1.1 mrg print * 5058 1.1 mrg print *, dot_product(a,b) 5059 1.1 mrg end program test_dot_prod 5060 1.1 mrg @end smallexample 5061 1.1 mrg @end table 5062 1.1 mrg 5063 1.1 mrg 5064 1.1 mrg 5065 1.1 mrg @node DPROD 5066 1.1 mrg @section @code{DPROD} --- Double product function 5067 1.1 mrg @fnindex DPROD 5068 1.1 mrg @cindex product, double-precision 5069 1.1 mrg 5070 1.1 mrg @table @asis 5071 1.1 mrg @item @emph{Description}: 5072 1.1 mrg @code{DPROD(X,Y)} returns the product @code{X*Y}. 5073 1.1 mrg 5074 1.1 mrg @item @emph{Standard}: 5075 1.1 mrg Fortran 77 and later 5076 1.1 mrg 5077 1.1 mrg @item @emph{Class}: 5078 1.1 mrg Elemental function 5079 1.1 mrg 5080 1.1 mrg @item @emph{Syntax}: 5081 1.1 mrg @code{RESULT = DPROD(X, Y)} 5082 1.1 mrg 5083 1.1 mrg @item @emph{Arguments}: 5084 1.1 mrg @multitable @columnfractions .15 .70 5085 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 5086 1.1 mrg @item @var{Y} @tab The type shall be @code{REAL}. 5087 1.1 mrg @end multitable 5088 1.1 mrg 5089 1.1 mrg @item @emph{Return value}: 5090 1.1 mrg The return value is of type @code{REAL(8)}. 5091 1.1 mrg 5092 1.1 mrg @item @emph{Example}: 5093 1.1 mrg @smallexample 5094 1.1 mrg program test_dprod 5095 1.1 mrg real :: x = 5.2 5096 1.1 mrg real :: y = 2.3 5097 1.1 mrg real(8) :: d 5098 1.1 mrg d = dprod(x,y) 5099 1.1 mrg print *, d 5100 1.1 mrg end program test_dprod 5101 1.1 mrg @end smallexample 5102 1.1 mrg 5103 1.1 mrg @item @emph{Specific names}: 5104 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 5105 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 5106 1.1 mrg @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later 5107 1.1 mrg @end multitable 5108 1.1 mrg 5109 1.1 mrg @end table 5110 1.1 mrg 5111 1.1 mrg 5112 1.1 mrg @node DREAL 5113 1.1 mrg @section @code{DREAL} --- Double real part function 5114 1.1 mrg @fnindex DREAL 5115 1.1 mrg @cindex complex numbers, real part 5116 1.1 mrg 5117 1.1 mrg @table @asis 5118 1.1 mrg @item @emph{Description}: 5119 1.1 mrg @code{DREAL(Z)} returns the real part of complex variable @var{Z}. 5120 1.1 mrg 5121 1.1 mrg @item @emph{Standard}: 5122 1.1 mrg GNU extension 5123 1.1 mrg 5124 1.1 mrg @item @emph{Class}: 5125 1.1 mrg Elemental function 5126 1.1 mrg 5127 1.1 mrg @item @emph{Syntax}: 5128 1.1 mrg @code{RESULT = DREAL(A)} 5129 1.1 mrg 5130 1.1 mrg @item @emph{Arguments}: 5131 1.1 mrg @multitable @columnfractions .15 .70 5132 1.1 mrg @item @var{A} @tab The type shall be @code{COMPLEX(8)}. 5133 1.1 mrg @end multitable 5134 1.1 mrg 5135 1.1 mrg @item @emph{Return value}: 5136 1.1 mrg The return value is of type @code{REAL(8)}. 5137 1.1 mrg 5138 1.1 mrg @item @emph{Example}: 5139 1.1 mrg @smallexample 5140 1.1 mrg program test_dreal 5141 1.1 mrg complex(8) :: z = (1.3_8,7.2_8) 5142 1.1 mrg print *, dreal(z) 5143 1.1 mrg end program test_dreal 5144 1.1 mrg @end smallexample 5145 1.1 mrg 5146 1.1 mrg @item @emph{See also}: 5147 1.1 mrg @ref{AIMAG} 5148 1.1 mrg 5149 1.1 mrg @end table 5150 1.1 mrg 5151 1.1 mrg 5152 1.1 mrg 5153 1.1 mrg @node DSHIFTL 5154 1.1 mrg @section @code{DSHIFTL} --- Combined left shift 5155 1.1 mrg @fnindex DSHIFTL 5156 1.1 mrg @cindex left shift, combined 5157 1.1 mrg @cindex shift, left 5158 1.1 mrg 5159 1.1 mrg @table @asis 5160 1.1 mrg @item @emph{Description}: 5161 1.1 mrg @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The 5162 1.1 mrg rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT} 5163 1.1 mrg bits of @var{J}, and the remaining bits are the rightmost bits of 5164 1.1 mrg @var{I}. 5165 1.1 mrg 5166 1.1 mrg @item @emph{Standard}: 5167 1.1 mrg Fortran 2008 and later 5168 1.1 mrg 5169 1.1 mrg @item @emph{Class}: 5170 1.1 mrg Elemental function 5171 1.1 mrg 5172 1.1 mrg @item @emph{Syntax}: 5173 1.1 mrg @code{RESULT = DSHIFTL(I, J, SHIFT)} 5174 1.1 mrg 5175 1.1 mrg @item @emph{Arguments}: 5176 1.1 mrg @multitable @columnfractions .15 .70 5177 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant. 5178 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant. 5179 1.1 mrg If both @var{I} and @var{J} have integer type, then they shall have 5180 1.1 mrg the same kind type parameter. @var{I} and @var{J} shall not both be 5181 1.1 mrg BOZ constants. 5182 1.1 mrg @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall 5183 1.1 mrg be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT} 5184 1.1 mrg shall be less than or equal to @code{BIT_SIZE(I)}; otherwise, 5185 1.1 mrg @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}. 5186 1.1 mrg @end multitable 5187 1.1 mrg 5188 1.1 mrg @item @emph{Return value}: 5189 1.1 mrg If either @var{I} or @var{J} is a BOZ constant, it is first converted 5190 1.1 mrg as if by the intrinsic function @code{INT} to an integer type with the 5191 1.1 mrg kind type parameter of the other. 5192 1.1 mrg 5193 1.1 mrg @item @emph{See also}: 5194 1.1 mrg @ref{DSHIFTR} 5195 1.1 mrg @end table 5196 1.1 mrg 5197 1.1 mrg 5198 1.1 mrg @node DSHIFTR 5199 1.1 mrg @section @code{DSHIFTR} --- Combined right shift 5200 1.1 mrg @fnindex DSHIFTR 5201 1.1 mrg @cindex right shift, combined 5202 1.1 mrg @cindex shift, right 5203 1.1 mrg 5204 1.1 mrg @table @asis 5205 1.1 mrg @item @emph{Description}: 5206 1.1 mrg @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The 5207 1.1 mrg leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT} 5208 1.1 mrg bits of @var{I}, and the remaining bits are the leftmost bits of 5209 1.1 mrg @var{J}. 5210 1.1 mrg 5211 1.1 mrg @item @emph{Standard}: 5212 1.1 mrg Fortran 2008 and later 5213 1.1 mrg 5214 1.1 mrg @item @emph{Class}: 5215 1.1 mrg Elemental function 5216 1.1 mrg 5217 1.1 mrg @item @emph{Syntax}: 5218 1.1 mrg @code{RESULT = DSHIFTR(I, J, SHIFT)} 5219 1.1 mrg 5220 1.1 mrg @item @emph{Arguments}: 5221 1.1 mrg @multitable @columnfractions .15 .70 5222 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant. 5223 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant. 5224 1.1 mrg If both @var{I} and @var{J} have integer type, then they shall have 5225 1.1 mrg the same kind type parameter. @var{I} and @var{J} shall not both be 5226 1.1 mrg BOZ constants. 5227 1.1 mrg @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall 5228 1.1 mrg be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT} 5229 1.1 mrg shall be less than or equal to @code{BIT_SIZE(I)}; otherwise, 5230 1.1 mrg @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}. 5231 1.1 mrg @end multitable 5232 1.1 mrg 5233 1.1 mrg @item @emph{Return value}: 5234 1.1 mrg If either @var{I} or @var{J} is a BOZ constant, it is first converted 5235 1.1 mrg as if by the intrinsic function @code{INT} to an integer type with the 5236 1.1 mrg kind type parameter of the other. 5237 1.1 mrg 5238 1.1 mrg @item @emph{See also}: 5239 1.1 mrg @ref{DSHIFTL} 5240 1.1 mrg @end table 5241 1.1 mrg 5242 1.1 mrg 5243 1.1 mrg @node DTIME 5244 1.1 mrg @section @code{DTIME} --- Execution time subroutine (or function) 5245 1.1 mrg @fnindex DTIME 5246 1.1 mrg @cindex time, elapsed 5247 1.1 mrg @cindex elapsed time 5248 1.1 mrg 5249 1.1 mrg @table @asis 5250 1.1 mrg @item @emph{Description}: 5251 1.1 mrg @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime 5252 1.1 mrg since the start of the process's execution in @var{TIME}. @var{VALUES} 5253 1.1 mrg returns the user and system components of this time in @code{VALUES(1)} and 5254 1.1 mrg @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + 5255 1.1 mrg VALUES(2)}. 5256 1.1 mrg 5257 1.1 mrg Subsequent invocations of @code{DTIME} return values accumulated since the 5258 1.1 mrg previous invocation. 5259 1.1 mrg 5260 1.1 mrg On some systems, the underlying timings are represented using types with 5261 1.1 mrg sufficiently small limits that overflows (wrap around) are possible, such as 5262 1.1 mrg 32-bit types. Therefore, the values returned by this intrinsic might be, or 5263 1.1 mrg become, negative, or numerically less than previous values, during a single 5264 1.1 mrg run of the compiled program. 5265 1.1 mrg 5266 1.1 mrg Please note, that this implementation is thread safe if used within OpenMP 5267 1.1 mrg directives, i.e., its state will be consistent while called from multiple 5268 1.1 mrg threads. However, if @code{DTIME} is called from multiple threads, the result 5269 1.1 mrg is still the time since the last invocation. This may not give the intended 5270 1.1 mrg results. If possible, use @code{CPU_TIME} instead. 5271 1.1 mrg 5272 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 5273 1.1 mrg only one form can be used in any given program unit. 5274 1.1 mrg 5275 1.1 mrg @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following: 5276 1.1 mrg 5277 1.1.1.3 mrg @multitable @columnfractions .15 .70 5278 1.1.1.3 mrg @item @code{VALUES(1)}: @tab User time in seconds. 5279 1.1.1.3 mrg @item @code{VALUES(2)}: @tab System time in seconds. 5280 1.1.1.3 mrg @item @code{TIME}: @tab Run time since start in seconds. 5281 1.1 mrg @end multitable 5282 1.1 mrg 5283 1.1 mrg @item @emph{Standard}: 5284 1.1 mrg GNU extension 5285 1.1 mrg 5286 1.1 mrg @item @emph{Class}: 5287 1.1 mrg Subroutine, function 5288 1.1 mrg 5289 1.1 mrg @item @emph{Syntax}: 5290 1.1 mrg @multitable @columnfractions .80 5291 1.1 mrg @item @code{CALL DTIME(VALUES, TIME)}. 5292 1.1 mrg @item @code{TIME = DTIME(VALUES)}, (not recommended). 5293 1.1 mrg @end multitable 5294 1.1 mrg 5295 1.1 mrg @item @emph{Arguments}: 5296 1.1 mrg @multitable @columnfractions .15 .70 5297 1.1 mrg @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}. 5298 1.1 mrg @item @var{TIME}@tab The type shall be @code{REAL(4)}. 5299 1.1 mrg @end multitable 5300 1.1 mrg 5301 1.1 mrg @item @emph{Return value}: 5302 1.1 mrg Elapsed time in seconds since the last invocation or since the start of program 5303 1.1 mrg execution if not called before. 5304 1.1 mrg 5305 1.1 mrg @item @emph{Example}: 5306 1.1 mrg @smallexample 5307 1.1 mrg program test_dtime 5308 1.1 mrg integer(8) :: i, j 5309 1.1 mrg real, dimension(2) :: tarray 5310 1.1 mrg real :: result 5311 1.1 mrg call dtime(tarray, result) 5312 1.1 mrg print *, result 5313 1.1 mrg print *, tarray(1) 5314 1.1 mrg print *, tarray(2) 5315 1.1 mrg do i=1,100000000 ! Just a delay 5316 1.1 mrg j = i * i - i 5317 1.1 mrg end do 5318 1.1 mrg call dtime(tarray, result) 5319 1.1 mrg print *, result 5320 1.1 mrg print *, tarray(1) 5321 1.1 mrg print *, tarray(2) 5322 1.1 mrg end program test_dtime 5323 1.1 mrg @end smallexample 5324 1.1 mrg 5325 1.1 mrg @item @emph{See also}: 5326 1.1 mrg @ref{CPU_TIME} 5327 1.1 mrg 5328 1.1 mrg @end table 5329 1.1 mrg 5330 1.1 mrg 5331 1.1 mrg 5332 1.1 mrg @node EOSHIFT 5333 1.1 mrg @section @code{EOSHIFT} --- End-off shift elements of an array 5334 1.1 mrg @fnindex EOSHIFT 5335 1.1 mrg @cindex array, shift 5336 1.1 mrg 5337 1.1 mrg @table @asis 5338 1.1 mrg @item @emph{Description}: 5339 1.1 mrg @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on 5340 1.1 mrg elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is 5341 1.1 mrg omitted it is taken to be @code{1}. @var{DIM} is a scalar of type 5342 1.1 mrg @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the 5343 1.1 mrg rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of 5344 1.1 mrg @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one, 5345 1.1 mrg then all complete rank one sections of @var{ARRAY} along the given dimension are 5346 1.1 mrg shifted. Elements shifted out one end of each rank one section are dropped. If 5347 1.1 mrg @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY} 5348 1.1 mrg is copied back in the other end. If @var{BOUNDARY} is not present then the 5349 1.1 mrg following are copied in depending on the type of @var{ARRAY}. 5350 1.1 mrg 5351 1.1 mrg @multitable @columnfractions .15 .80 5352 1.1 mrg @item @emph{Array Type} @tab @emph{Boundary Value} 5353 1.1 mrg @item Numeric @tab 0 of the type and kind of @var{ARRAY}. 5354 1.1 mrg @item Logical @tab @code{.FALSE.}. 5355 1.1 mrg @item Character(@var{len}) @tab @var{len} blanks. 5356 1.1 mrg @end multitable 5357 1.1 mrg 5358 1.1 mrg @item @emph{Standard}: 5359 1.1.1.2 mrg Fortran 90 and later 5360 1.1 mrg 5361 1.1 mrg @item @emph{Class}: 5362 1.1 mrg Transformational function 5363 1.1 mrg 5364 1.1 mrg @item @emph{Syntax}: 5365 1.1 mrg @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])} 5366 1.1 mrg 5367 1.1 mrg @item @emph{Arguments}: 5368 1.1 mrg @multitable @columnfractions .15 .70 5369 1.1 mrg @item @var{ARRAY} @tab May be any type, not scalar. 5370 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 5371 1.1 mrg @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 5372 1.1 mrg @item @var{DIM} @tab The type shall be @code{INTEGER}. 5373 1.1 mrg @end multitable 5374 1.1 mrg 5375 1.1 mrg @item @emph{Return value}: 5376 1.1 mrg Returns an array of same type and rank as the @var{ARRAY} argument. 5377 1.1 mrg 5378 1.1 mrg @item @emph{Example}: 5379 1.1 mrg @smallexample 5380 1.1 mrg program test_eoshift 5381 1.1 mrg integer, dimension(3,3) :: a 5382 1.1 mrg a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /)) 5383 1.1 mrg print '(3i3)', a(1,:) 5384 1.1 mrg print '(3i3)', a(2,:) 5385 1.1 mrg print '(3i3)', a(3,:) 5386 1.1 mrg a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2) 5387 1.1 mrg print * 5388 1.1 mrg print '(3i3)', a(1,:) 5389 1.1 mrg print '(3i3)', a(2,:) 5390 1.1 mrg print '(3i3)', a(3,:) 5391 1.1 mrg end program test_eoshift 5392 1.1 mrg @end smallexample 5393 1.1 mrg @end table 5394 1.1 mrg 5395 1.1 mrg 5396 1.1 mrg 5397 1.1 mrg @node EPSILON 5398 1.1 mrg @section @code{EPSILON} --- Epsilon function 5399 1.1 mrg @fnindex EPSILON 5400 1.1 mrg @cindex model representation, epsilon 5401 1.1 mrg 5402 1.1 mrg @table @asis 5403 1.1 mrg @item @emph{Description}: 5404 1.1 mrg @code{EPSILON(X)} returns the smallest number @var{E} of the same kind 5405 1.1 mrg as @var{X} such that @math{1 + E > 1}. 5406 1.1 mrg 5407 1.1 mrg @item @emph{Standard}: 5408 1.1.1.2 mrg Fortran 90 and later 5409 1.1 mrg 5410 1.1 mrg @item @emph{Class}: 5411 1.1 mrg Inquiry function 5412 1.1 mrg 5413 1.1 mrg @item @emph{Syntax}: 5414 1.1 mrg @code{RESULT = EPSILON(X)} 5415 1.1 mrg 5416 1.1 mrg @item @emph{Arguments}: 5417 1.1 mrg @multitable @columnfractions .15 .70 5418 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 5419 1.1 mrg @end multitable 5420 1.1 mrg 5421 1.1 mrg @item @emph{Return value}: 5422 1.1 mrg The return value is of same type as the argument. 5423 1.1 mrg 5424 1.1 mrg @item @emph{Example}: 5425 1.1 mrg @smallexample 5426 1.1 mrg program test_epsilon 5427 1.1 mrg real :: x = 3.143 5428 1.1 mrg real(8) :: y = 2.33 5429 1.1 mrg print *, EPSILON(x) 5430 1.1 mrg print *, EPSILON(y) 5431 1.1 mrg end program test_epsilon 5432 1.1 mrg @end smallexample 5433 1.1 mrg @end table 5434 1.1 mrg 5435 1.1 mrg 5436 1.1 mrg 5437 1.1 mrg @node ERF 5438 1.1 mrg @section @code{ERF} --- Error function 5439 1.1 mrg @fnindex ERF 5440 1.1 mrg @cindex error function 5441 1.1 mrg 5442 1.1 mrg @table @asis 5443 1.1 mrg @item @emph{Description}: 5444 1.1 mrg @code{ERF(X)} computes the error function of @var{X}. 5445 1.1 mrg 5446 1.1 mrg @item @emph{Standard}: 5447 1.1 mrg Fortran 2008 and later 5448 1.1 mrg 5449 1.1 mrg @item @emph{Class}: 5450 1.1 mrg Elemental function 5451 1.1 mrg 5452 1.1 mrg @item @emph{Syntax}: 5453 1.1 mrg @code{RESULT = ERF(X)} 5454 1.1 mrg 5455 1.1 mrg @item @emph{Arguments}: 5456 1.1 mrg @multitable @columnfractions .15 .70 5457 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 5458 1.1 mrg @end multitable 5459 1.1 mrg 5460 1.1 mrg @item @emph{Return value}: 5461 1.1 mrg The return value is of type @code{REAL}, of the same kind as 5462 1.1 mrg @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }. 5463 1.1 mrg 5464 1.1 mrg @item @emph{Example}: 5465 1.1 mrg @smallexample 5466 1.1 mrg program test_erf 5467 1.1 mrg real(8) :: x = 0.17_8 5468 1.1 mrg x = erf(x) 5469 1.1 mrg end program test_erf 5470 1.1 mrg @end smallexample 5471 1.1 mrg 5472 1.1 mrg @item @emph{Specific names}: 5473 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 5474 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 5475 1.1 mrg @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 5476 1.1 mrg @end multitable 5477 1.1 mrg @end table 5478 1.1 mrg 5479 1.1 mrg 5480 1.1 mrg 5481 1.1 mrg @node ERFC 5482 1.1 mrg @section @code{ERFC} --- Error function 5483 1.1 mrg @fnindex ERFC 5484 1.1 mrg @cindex error function, complementary 5485 1.1 mrg 5486 1.1 mrg @table @asis 5487 1.1 mrg @item @emph{Description}: 5488 1.1 mrg @code{ERFC(X)} computes the complementary error function of @var{X}. 5489 1.1 mrg 5490 1.1 mrg @item @emph{Standard}: 5491 1.1 mrg Fortran 2008 and later 5492 1.1 mrg 5493 1.1 mrg @item @emph{Class}: 5494 1.1 mrg Elemental function 5495 1.1 mrg 5496 1.1 mrg @item @emph{Syntax}: 5497 1.1 mrg @code{RESULT = ERFC(X)} 5498 1.1 mrg 5499 1.1 mrg @item @emph{Arguments}: 5500 1.1 mrg @multitable @columnfractions .15 .70 5501 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 5502 1.1 mrg @end multitable 5503 1.1 mrg 5504 1.1 mrg @item @emph{Return value}: 5505 1.1 mrg The return value is of type @code{REAL} and of the same kind as @var{X}. 5506 1.1 mrg It lies in the range @math{ 0 \leq erfc (x) \leq 2 }. 5507 1.1 mrg 5508 1.1 mrg @item @emph{Example}: 5509 1.1 mrg @smallexample 5510 1.1 mrg program test_erfc 5511 1.1 mrg real(8) :: x = 0.17_8 5512 1.1 mrg x = erfc(x) 5513 1.1 mrg end program test_erfc 5514 1.1 mrg @end smallexample 5515 1.1 mrg 5516 1.1 mrg @item @emph{Specific names}: 5517 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 5518 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 5519 1.1 mrg @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 5520 1.1 mrg @end multitable 5521 1.1 mrg @end table 5522 1.1 mrg 5523 1.1 mrg 5524 1.1 mrg 5525 1.1 mrg @node ERFC_SCALED 5526 1.1 mrg @section @code{ERFC_SCALED} --- Error function 5527 1.1 mrg @fnindex ERFC_SCALED 5528 1.1 mrg @cindex error function, complementary, exponentially-scaled 5529 1.1 mrg 5530 1.1 mrg @table @asis 5531 1.1 mrg @item @emph{Description}: 5532 1.1 mrg @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary 5533 1.1 mrg error function of @var{X}. 5534 1.1 mrg 5535 1.1 mrg @item @emph{Standard}: 5536 1.1 mrg Fortran 2008 and later 5537 1.1 mrg 5538 1.1 mrg @item @emph{Class}: 5539 1.1 mrg Elemental function 5540 1.1 mrg 5541 1.1 mrg @item @emph{Syntax}: 5542 1.1 mrg @code{RESULT = ERFC_SCALED(X)} 5543 1.1 mrg 5544 1.1 mrg @item @emph{Arguments}: 5545 1.1 mrg @multitable @columnfractions .15 .70 5546 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 5547 1.1 mrg @end multitable 5548 1.1 mrg 5549 1.1 mrg @item @emph{Return value}: 5550 1.1 mrg The return value is of type @code{REAL} and of the same kind as @var{X}. 5551 1.1 mrg 5552 1.1 mrg @item @emph{Example}: 5553 1.1 mrg @smallexample 5554 1.1 mrg program test_erfc_scaled 5555 1.1 mrg real(8) :: x = 0.17_8 5556 1.1 mrg x = erfc_scaled(x) 5557 1.1 mrg end program test_erfc_scaled 5558 1.1 mrg @end smallexample 5559 1.1 mrg @end table 5560 1.1 mrg 5561 1.1 mrg 5562 1.1 mrg 5563 1.1 mrg @node ETIME 5564 1.1 mrg @section @code{ETIME} --- Execution time subroutine (or function) 5565 1.1 mrg @fnindex ETIME 5566 1.1 mrg @cindex time, elapsed 5567 1.1 mrg 5568 1.1 mrg @table @asis 5569 1.1 mrg @item @emph{Description}: 5570 1.1 mrg @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime 5571 1.1 mrg since the start of the process's execution in @var{TIME}. @var{VALUES} 5572 1.1 mrg returns the user and system components of this time in @code{VALUES(1)} and 5573 1.1 mrg @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}. 5574 1.1 mrg 5575 1.1 mrg On some systems, the underlying timings are represented using types with 5576 1.1 mrg sufficiently small limits that overflows (wrap around) are possible, such as 5577 1.1 mrg 32-bit types. Therefore, the values returned by this intrinsic might be, or 5578 1.1 mrg become, negative, or numerically less than previous values, during a single 5579 1.1 mrg run of the compiled program. 5580 1.1 mrg 5581 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 5582 1.1 mrg only one form can be used in any given program unit. 5583 1.1 mrg 5584 1.1 mrg @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following: 5585 1.1 mrg 5586 1.1.1.3 mrg @multitable @columnfractions .15 .70 5587 1.1.1.3 mrg @item @code{VALUES(1)}: @tab User time in seconds. 5588 1.1.1.3 mrg @item @code{VALUES(2)}: @tab System time in seconds. 5589 1.1.1.3 mrg @item @code{TIME}: @tab Run time since start in seconds. 5590 1.1 mrg @end multitable 5591 1.1 mrg 5592 1.1 mrg @item @emph{Standard}: 5593 1.1 mrg GNU extension 5594 1.1 mrg 5595 1.1 mrg @item @emph{Class}: 5596 1.1 mrg Subroutine, function 5597 1.1 mrg 5598 1.1 mrg @item @emph{Syntax}: 5599 1.1 mrg @multitable @columnfractions .80 5600 1.1 mrg @item @code{CALL ETIME(VALUES, TIME)}. 5601 1.1 mrg @item @code{TIME = ETIME(VALUES)}, (not recommended). 5602 1.1 mrg @end multitable 5603 1.1 mrg 5604 1.1 mrg @item @emph{Arguments}: 5605 1.1 mrg @multitable @columnfractions .15 .70 5606 1.1 mrg @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}. 5607 1.1 mrg @item @var{TIME}@tab The type shall be @code{REAL(4)}. 5608 1.1 mrg @end multitable 5609 1.1 mrg 5610 1.1 mrg @item @emph{Return value}: 5611 1.1 mrg Elapsed time in seconds since the start of program execution. 5612 1.1 mrg 5613 1.1 mrg @item @emph{Example}: 5614 1.1 mrg @smallexample 5615 1.1 mrg program test_etime 5616 1.1 mrg integer(8) :: i, j 5617 1.1 mrg real, dimension(2) :: tarray 5618 1.1 mrg real :: result 5619 1.1 mrg call ETIME(tarray, result) 5620 1.1 mrg print *, result 5621 1.1 mrg print *, tarray(1) 5622 1.1 mrg print *, tarray(2) 5623 1.1 mrg do i=1,100000000 ! Just a delay 5624 1.1 mrg j = i * i - i 5625 1.1 mrg end do 5626 1.1 mrg call ETIME(tarray, result) 5627 1.1 mrg print *, result 5628 1.1 mrg print *, tarray(1) 5629 1.1 mrg print *, tarray(2) 5630 1.1 mrg end program test_etime 5631 1.1 mrg @end smallexample 5632 1.1 mrg 5633 1.1 mrg @item @emph{See also}: 5634 1.1 mrg @ref{CPU_TIME} 5635 1.1 mrg 5636 1.1 mrg @end table 5637 1.1 mrg 5638 1.1 mrg 5639 1.1 mrg 5640 1.1 mrg @node EVENT_QUERY 5641 1.1 mrg @section @code{EVENT_QUERY} --- Query whether a coarray event has occurred 5642 1.1 mrg @fnindex EVENT_QUERY 5643 1.1 mrg @cindex Events, EVENT_QUERY 5644 1.1 mrg 5645 1.1 mrg @table @asis 5646 1.1 mrg @item @emph{Description}: 5647 1.1 mrg @code{EVENT_QUERY} assignes the number of events to @var{COUNT} which have been 5648 1.1 mrg posted to the @var{EVENT} variable and not yet been removed by calling 5649 1.1 mrg @code{EVENT WAIT}. When @var{STAT} is present and the invocation was successful, 5650 1.1 mrg it is assigned the value 0. If it is present and the invocation has failed, 5651 1.1 mrg it is assigned a positive value and @var{COUNT} is assigned the value @math{-1}. 5652 1.1 mrg 5653 1.1 mrg @item @emph{Standard}: 5654 1.1 mrg TS 18508 or later 5655 1.1 mrg 5656 1.1 mrg @item @emph{Class}: 5657 1.1 mrg subroutine 5658 1.1 mrg 5659 1.1 mrg @item @emph{Syntax}: 5660 1.1 mrg @code{CALL EVENT_QUERY (EVENT, COUNT [, STAT])} 5661 1.1 mrg 5662 1.1 mrg @item @emph{Arguments}: 5663 1.1 mrg @multitable @columnfractions .15 .70 5664 1.1 mrg @item @var{EVENT} @tab (intent(IN)) Scalar of type @code{EVENT_TYPE}, 5665 1.1 mrg defined in @code{ISO_FORTRAN_ENV}; shall not be coindexed. 5666 1.1 mrg @item @var{COUNT} @tab (intent(out))Scalar integer with at least the 5667 1.1 mrg precision of default integer. 5668 1.1 mrg @item @var{STAT} @tab (optional) Scalar default-kind integer variable. 5669 1.1 mrg @end multitable 5670 1.1 mrg 5671 1.1 mrg @item @emph{Example}: 5672 1.1 mrg @smallexample 5673 1.1 mrg program atomic 5674 1.1 mrg use iso_fortran_env 5675 1.1 mrg implicit none 5676 1.1 mrg type(event_type) :: event_value_has_been_set[*] 5677 1.1 mrg integer :: cnt 5678 1.1 mrg if (this_image() == 1) then 5679 1.1 mrg call event_query (event_value_has_been_set, cnt) 5680 1.1 mrg if (cnt > 0) write(*,*) "Value has been set" 5681 1.1 mrg elseif (this_image() == 2) then 5682 1.1 mrg event post (event_value_has_been_set[1]) 5683 1.1 mrg end if 5684 1.1 mrg end program atomic 5685 1.1 mrg @end smallexample 5686 1.1 mrg 5687 1.1 mrg @end table 5688 1.1 mrg 5689 1.1 mrg 5690 1.1 mrg 5691 1.1 mrg @node EXECUTE_COMMAND_LINE 5692 1.1 mrg @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command 5693 1.1 mrg @fnindex EXECUTE_COMMAND_LINE 5694 1.1 mrg @cindex system, system call 5695 1.1 mrg @cindex command line 5696 1.1 mrg 5697 1.1 mrg @table @asis 5698 1.1 mrg @item @emph{Description}: 5699 1.1 mrg @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or 5700 1.1 mrg asynchronously. 5701 1.1 mrg 5702 1.1 mrg The @code{COMMAND} argument is passed to the shell and executed (The 5703 1.1 mrg shell is @code{sh} on Unix systems, and @code{cmd.exe} on Windows.). 5704 1.1 mrg If @code{WAIT} is present and has the value false, the execution of 5705 1.1 mrg the command is asynchronous if the system supports it; otherwise, the 5706 1.1 mrg command is executed synchronously using the C library's @code{system} 5707 1.1 mrg call. 5708 1.1 mrg 5709 1.1 mrg The three last arguments allow the user to get status information. After 5710 1.1 mrg synchronous execution, @code{EXITSTAT} contains the integer exit code of 5711 1.1 mrg the command, as returned by @code{system}. @code{CMDSTAT} is set to zero 5712 1.1 mrg if the command line was executed (whatever its exit status was). 5713 1.1 mrg @code{CMDMSG} is assigned an error message if an error has occurred. 5714 1.1 mrg 5715 1.1 mrg Note that the @code{system} function need not be thread-safe. It is 5716 1.1 mrg the responsibility of the user to ensure that @code{system} is not 5717 1.1 mrg called concurrently. 5718 1.1 mrg 5719 1.1 mrg For asynchronous execution on supported targets, the POSIX 5720 1.1 mrg @code{posix_spawn} or @code{fork} functions are used. Also, a signal 5721 1.1 mrg handler for the @code{SIGCHLD} signal is installed. 5722 1.1 mrg 5723 1.1 mrg @item @emph{Standard}: 5724 1.1 mrg Fortran 2008 and later 5725 1.1 mrg 5726 1.1 mrg @item @emph{Class}: 5727 1.1 mrg Subroutine 5728 1.1 mrg 5729 1.1 mrg @item @emph{Syntax}: 5730 1.1 mrg @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])} 5731 1.1 mrg 5732 1.1 mrg @item @emph{Arguments}: 5733 1.1 mrg @multitable @columnfractions .15 .70 5734 1.1 mrg @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar. 5735 1.1 mrg @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar. 5736 1.1 mrg @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the 5737 1.1 mrg default kind. 5738 1.1 mrg @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the 5739 1.1 mrg default kind. 5740 1.1 mrg @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the 5741 1.1 mrg default kind. 5742 1.1 mrg @end multitable 5743 1.1 mrg 5744 1.1 mrg @item @emph{Example}: 5745 1.1 mrg @smallexample 5746 1.1 mrg program test_exec 5747 1.1 mrg integer :: i 5748 1.1 mrg 5749 1.1 mrg call execute_command_line ("external_prog.exe", exitstat=i) 5750 1.1 mrg print *, "Exit status of external_prog.exe was ", i 5751 1.1 mrg 5752 1.1 mrg call execute_command_line ("reindex_files.exe", wait=.false.) 5753 1.1 mrg print *, "Now reindexing files in the background" 5754 1.1 mrg 5755 1.1 mrg end program test_exec 5756 1.1 mrg @end smallexample 5757 1.1 mrg 5758 1.1 mrg 5759 1.1 mrg @item @emph{Note}: 5760 1.1 mrg 5761 1.1 mrg Because this intrinsic is implemented in terms of the @code{system} 5762 1.1 mrg function call, its behavior with respect to signaling is processor 5763 1.1 mrg dependent. In particular, on POSIX-compliant systems, the SIGINT and 5764 1.1 mrg SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As 5765 1.1 mrg such, if the parent process is terminated, the child process might not be 5766 1.1 mrg terminated alongside. 5767 1.1 mrg 5768 1.1 mrg 5769 1.1 mrg @item @emph{See also}: 5770 1.1 mrg @ref{SYSTEM} 5771 1.1 mrg @end table 5772 1.1 mrg 5773 1.1 mrg 5774 1.1 mrg 5775 1.1 mrg @node EXIT 5776 1.1 mrg @section @code{EXIT} --- Exit the program with status. 5777 1.1 mrg @fnindex EXIT 5778 1.1 mrg @cindex program termination 5779 1.1 mrg @cindex terminate program 5780 1.1 mrg 5781 1.1 mrg @table @asis 5782 1.1 mrg @item @emph{Description}: 5783 1.1 mrg @code{EXIT} causes immediate termination of the program with status. If status 5784 1.1 mrg is omitted it returns the canonical @emph{success} for the system. All Fortran 5785 1.1 mrg I/O units are closed. 5786 1.1 mrg 5787 1.1 mrg @item @emph{Standard}: 5788 1.1 mrg GNU extension 5789 1.1 mrg 5790 1.1 mrg @item @emph{Class}: 5791 1.1 mrg Subroutine 5792 1.1 mrg 5793 1.1 mrg @item @emph{Syntax}: 5794 1.1 mrg @code{CALL EXIT([STATUS])} 5795 1.1 mrg 5796 1.1 mrg @item @emph{Arguments}: 5797 1.1 mrg @multitable @columnfractions .15 .70 5798 1.1 mrg @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind. 5799 1.1 mrg @end multitable 5800 1.1 mrg 5801 1.1 mrg @item @emph{Return value}: 5802 1.1 mrg @code{STATUS} is passed to the parent process on exit. 5803 1.1 mrg 5804 1.1 mrg @item @emph{Example}: 5805 1.1 mrg @smallexample 5806 1.1 mrg program test_exit 5807 1.1 mrg integer :: STATUS = 0 5808 1.1 mrg print *, 'This program is going to exit.' 5809 1.1 mrg call EXIT(STATUS) 5810 1.1 mrg end program test_exit 5811 1.1 mrg @end smallexample 5812 1.1 mrg 5813 1.1 mrg @item @emph{See also}: 5814 1.1.1.2 mrg @ref{ABORT}, @gol 5815 1.1.1.2 mrg @ref{KILL} 5816 1.1 mrg @end table 5817 1.1 mrg 5818 1.1 mrg 5819 1.1 mrg 5820 1.1 mrg @node EXP 5821 1.1 mrg @section @code{EXP} --- Exponential function 5822 1.1 mrg @fnindex EXP 5823 1.1 mrg @fnindex DEXP 5824 1.1 mrg @fnindex CEXP 5825 1.1 mrg @fnindex ZEXP 5826 1.1 mrg @fnindex CDEXP 5827 1.1 mrg @cindex exponential function 5828 1.1 mrg @cindex logarithm function, inverse 5829 1.1 mrg 5830 1.1 mrg @table @asis 5831 1.1 mrg @item @emph{Description}: 5832 1.1 mrg @code{EXP(X)} computes the base @math{e} exponential of @var{X}. 5833 1.1 mrg 5834 1.1 mrg @item @emph{Standard}: 5835 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions 5836 1.1 mrg 5837 1.1 mrg @item @emph{Class}: 5838 1.1 mrg Elemental function 5839 1.1 mrg 5840 1.1 mrg @item @emph{Syntax}: 5841 1.1 mrg @code{RESULT = EXP(X)} 5842 1.1 mrg 5843 1.1 mrg @item @emph{Arguments}: 5844 1.1 mrg @multitable @columnfractions .15 .70 5845 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or 5846 1.1 mrg @code{COMPLEX}. 5847 1.1 mrg @end multitable 5848 1.1 mrg 5849 1.1 mrg @item @emph{Return value}: 5850 1.1 mrg The return value has same type and kind as @var{X}. 5851 1.1 mrg 5852 1.1 mrg @item @emph{Example}: 5853 1.1 mrg @smallexample 5854 1.1 mrg program test_exp 5855 1.1 mrg real :: x = 1.0 5856 1.1 mrg x = exp(x) 5857 1.1 mrg end program test_exp 5858 1.1 mrg @end smallexample 5859 1.1 mrg 5860 1.1 mrg @item @emph{Specific names}: 5861 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 5862 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 5863 1.1 mrg @item @code{EXP(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 5864 1.1 mrg @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 5865 1.1 mrg @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later 5866 1.1 mrg @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 5867 1.1 mrg @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 5868 1.1 mrg @end multitable 5869 1.1 mrg @end table 5870 1.1 mrg 5871 1.1 mrg 5872 1.1 mrg 5873 1.1 mrg @node EXPONENT 5874 1.1 mrg @section @code{EXPONENT} --- Exponent function 5875 1.1 mrg @fnindex EXPONENT 5876 1.1 mrg @cindex real number, exponent 5877 1.1 mrg @cindex floating point, exponent 5878 1.1 mrg 5879 1.1 mrg @table @asis 5880 1.1 mrg @item @emph{Description}: 5881 1.1 mrg @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X} 5882 1.1 mrg is zero the value returned is zero. 5883 1.1 mrg 5884 1.1 mrg @item @emph{Standard}: 5885 1.1.1.2 mrg Fortran 90 and later 5886 1.1 mrg 5887 1.1 mrg @item @emph{Class}: 5888 1.1 mrg Elemental function 5889 1.1 mrg 5890 1.1 mrg @item @emph{Syntax}: 5891 1.1 mrg @code{RESULT = EXPONENT(X)} 5892 1.1 mrg 5893 1.1 mrg @item @emph{Arguments}: 5894 1.1 mrg @multitable @columnfractions .15 .70 5895 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 5896 1.1 mrg @end multitable 5897 1.1 mrg 5898 1.1 mrg @item @emph{Return value}: 5899 1.1 mrg The return value is of type default @code{INTEGER}. 5900 1.1 mrg 5901 1.1 mrg @item @emph{Example}: 5902 1.1 mrg @smallexample 5903 1.1 mrg program test_exponent 5904 1.1 mrg real :: x = 1.0 5905 1.1 mrg integer :: i 5906 1.1 mrg i = exponent(x) 5907 1.1 mrg print *, i 5908 1.1 mrg print *, exponent(0.0) 5909 1.1 mrg end program test_exponent 5910 1.1 mrg @end smallexample 5911 1.1 mrg @end table 5912 1.1 mrg 5913 1.1 mrg 5914 1.1 mrg 5915 1.1 mrg @node EXTENDS_TYPE_OF 5916 1.1 mrg @section @code{EXTENDS_TYPE_OF} --- Query dynamic type for extension 5917 1.1 mrg @fnindex EXTENDS_TYPE_OF 5918 1.1 mrg 5919 1.1 mrg @table @asis 5920 1.1 mrg @item @emph{Description}: 5921 1.1 mrg Query dynamic type for extension. 5922 1.1 mrg 5923 1.1 mrg @item @emph{Standard}: 5924 1.1 mrg Fortran 2003 and later 5925 1.1 mrg 5926 1.1 mrg @item @emph{Class}: 5927 1.1 mrg Inquiry function 5928 1.1 mrg 5929 1.1 mrg @item @emph{Syntax}: 5930 1.1 mrg @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)} 5931 1.1 mrg 5932 1.1 mrg @item @emph{Arguments}: 5933 1.1 mrg @multitable @columnfractions .15 .70 5934 1.1 mrg @item @var{A} @tab Shall be an object of extensible declared type or 5935 1.1 mrg unlimited polymorphic. 5936 1.1 mrg @item @var{MOLD} @tab Shall be an object of extensible declared type or 5937 1.1 mrg unlimited polymorphic. 5938 1.1 mrg @end multitable 5939 1.1 mrg 5940 1.1 mrg @item @emph{Return value}: 5941 1.1 mrg The return value is a scalar of type default logical. It is true if and only if 5942 1.1 mrg the dynamic type of A is an extension type of the dynamic type of MOLD. 5943 1.1 mrg 5944 1.1 mrg 5945 1.1 mrg @item @emph{See also}: 5946 1.1 mrg @ref{SAME_TYPE_AS} 5947 1.1 mrg @end table 5948 1.1 mrg 5949 1.1 mrg 5950 1.1 mrg 5951 1.1 mrg @node FDATE 5952 1.1 mrg @section @code{FDATE} --- Get the current time as a string 5953 1.1 mrg @fnindex FDATE 5954 1.1 mrg @cindex time, current 5955 1.1 mrg @cindex current time 5956 1.1 mrg @cindex date, current 5957 1.1 mrg @cindex current date 5958 1.1 mrg 5959 1.1 mrg @table @asis 5960 1.1 mrg @item @emph{Description}: 5961 1.1 mrg @code{FDATE(DATE)} returns the current date (using the same format as 5962 1.1 mrg @ref{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE, 5963 1.1 mrg TIME())}. 5964 1.1 mrg 5965 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 5966 1.1 mrg only one form can be used in any given program unit. 5967 1.1 mrg 5968 1.1 mrg @item @emph{Standard}: 5969 1.1 mrg GNU extension 5970 1.1 mrg 5971 1.1 mrg @item @emph{Class}: 5972 1.1 mrg Subroutine, function 5973 1.1 mrg 5974 1.1 mrg @item @emph{Syntax}: 5975 1.1 mrg @multitable @columnfractions .80 5976 1.1 mrg @item @code{CALL FDATE(DATE)}. 5977 1.1 mrg @item @code{DATE = FDATE()}. 5978 1.1 mrg @end multitable 5979 1.1 mrg 5980 1.1 mrg @item @emph{Arguments}: 5981 1.1 mrg @multitable @columnfractions .15 .70 5982 1.1 mrg @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the 5983 1.1 mrg default kind. It is an @code{INTENT(OUT)} argument. If the length of 5984 1.1 mrg this variable is too short for the date and time string to fit 5985 1.1 mrg completely, it will be blank on procedure return. 5986 1.1 mrg @end multitable 5987 1.1 mrg 5988 1.1 mrg @item @emph{Return value}: 5989 1.1 mrg The current date and time as a string. 5990 1.1 mrg 5991 1.1 mrg @item @emph{Example}: 5992 1.1 mrg @smallexample 5993 1.1 mrg program test_fdate 5994 1.1 mrg integer(8) :: i, j 5995 1.1 mrg character(len=30) :: date 5996 1.1 mrg call fdate(date) 5997 1.1 mrg print *, 'Program started on ', date 5998 1.1 mrg do i = 1, 100000000 ! Just a delay 5999 1.1 mrg j = i * i - i 6000 1.1 mrg end do 6001 1.1 mrg call fdate(date) 6002 1.1 mrg print *, 'Program ended on ', date 6003 1.1 mrg end program test_fdate 6004 1.1 mrg @end smallexample 6005 1.1 mrg 6006 1.1 mrg @item @emph{See also}: 6007 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol 6008 1.1.1.2 mrg @ref{CTIME} 6009 1.1 mrg @end table 6010 1.1 mrg 6011 1.1 mrg 6012 1.1 mrg @node FGET 6013 1.1 mrg @section @code{FGET} --- Read a single character in stream mode from stdin 6014 1.1 mrg @fnindex FGET 6015 1.1 mrg @cindex read character, stream mode 6016 1.1 mrg @cindex stream mode, read character 6017 1.1 mrg @cindex file operation, read character 6018 1.1 mrg 6019 1.1 mrg @table @asis 6020 1.1 mrg @item @emph{Description}: 6021 1.1 mrg Read a single character in stream mode from stdin by bypassing normal 6022 1.1 mrg formatted output. Stream I/O should not be mixed with normal record-oriented 6023 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable. 6024 1.1 mrg 6025 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 6026 1.1 mrg only one form can be used in any given program unit. 6027 1.1 mrg 6028 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with 6029 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility. 6030 1.1 mrg Programmers should consider the use of new stream IO feature in new code 6031 1.1 mrg for future portability. See also @ref{Fortran 2003 status}. 6032 1.1 mrg 6033 1.1 mrg @item @emph{Standard}: 6034 1.1 mrg GNU extension 6035 1.1 mrg 6036 1.1 mrg @item @emph{Class}: 6037 1.1 mrg Subroutine, function 6038 1.1 mrg 6039 1.1 mrg @item @emph{Syntax}: 6040 1.1 mrg @multitable @columnfractions .80 6041 1.1 mrg @item @code{CALL FGET(C [, STATUS])} 6042 1.1 mrg @item @code{STATUS = FGET(C)} 6043 1.1 mrg @end multitable 6044 1.1 mrg 6045 1.1 mrg @item @emph{Arguments}: 6046 1.1 mrg @multitable @columnfractions .15 .70 6047 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default 6048 1.1 mrg kind. 6049 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. 6050 1.1 mrg Returns 0 on success, -1 on end-of-file, and a system specific positive 6051 1.1 mrg error code otherwise. 6052 1.1 mrg @end multitable 6053 1.1 mrg 6054 1.1 mrg @item @emph{Example}: 6055 1.1 mrg @smallexample 6056 1.1 mrg PROGRAM test_fget 6057 1.1 mrg INTEGER, PARAMETER :: strlen = 100 6058 1.1 mrg INTEGER :: status, i = 1 6059 1.1 mrg CHARACTER(len=strlen) :: str = "" 6060 1.1 mrg 6061 1.1 mrg WRITE (*,*) 'Enter text:' 6062 1.1 mrg DO 6063 1.1 mrg CALL fget(str(i:i), status) 6064 1.1 mrg if (status /= 0 .OR. i > strlen) exit 6065 1.1 mrg i = i + 1 6066 1.1 mrg END DO 6067 1.1 mrg WRITE (*,*) TRIM(str) 6068 1.1 mrg END PROGRAM 6069 1.1 mrg @end smallexample 6070 1.1 mrg 6071 1.1 mrg @item @emph{See also}: 6072 1.1.1.2 mrg @ref{FGETC}, @gol 6073 1.1.1.2 mrg @ref{FPUT}, @gol 6074 1.1.1.2 mrg @ref{FPUTC} 6075 1.1 mrg @end table 6076 1.1 mrg 6077 1.1 mrg 6078 1.1 mrg 6079 1.1 mrg @node FGETC 6080 1.1 mrg @section @code{FGETC} --- Read a single character in stream mode 6081 1.1 mrg @fnindex FGETC 6082 1.1 mrg @cindex read character, stream mode 6083 1.1 mrg @cindex stream mode, read character 6084 1.1 mrg @cindex file operation, read character 6085 1.1 mrg 6086 1.1 mrg @table @asis 6087 1.1 mrg @item @emph{Description}: 6088 1.1 mrg Read a single character in stream mode by bypassing normal formatted output. 6089 1.1 mrg Stream I/O should not be mixed with normal record-oriented (formatted or 6090 1.1 mrg unformatted) I/O on the same unit; the results are unpredictable. 6091 1.1 mrg 6092 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 6093 1.1 mrg only one form can be used in any given program unit. 6094 1.1 mrg 6095 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility 6096 1.1 mrg with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility. 6097 1.1 mrg Programmers should consider the use of new stream IO feature in new code 6098 1.1 mrg for future portability. See also @ref{Fortran 2003 status}. 6099 1.1 mrg 6100 1.1 mrg @item @emph{Standard}: 6101 1.1 mrg GNU extension 6102 1.1 mrg 6103 1.1 mrg @item @emph{Class}: 6104 1.1 mrg Subroutine, function 6105 1.1 mrg 6106 1.1 mrg @item @emph{Syntax}: 6107 1.1 mrg @multitable @columnfractions .80 6108 1.1 mrg @item @code{CALL FGETC(UNIT, C [, STATUS])} 6109 1.1 mrg @item @code{STATUS = FGETC(UNIT, C)} 6110 1.1 mrg @end multitable 6111 1.1 mrg 6112 1.1 mrg @item @emph{Arguments}: 6113 1.1 mrg @multitable @columnfractions .15 .70 6114 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}. 6115 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default 6116 1.1 mrg kind. 6117 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. 6118 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive 6119 1.1 mrg error code otherwise. 6120 1.1 mrg @end multitable 6121 1.1 mrg 6122 1.1 mrg @item @emph{Example}: 6123 1.1 mrg @smallexample 6124 1.1 mrg PROGRAM test_fgetc 6125 1.1 mrg INTEGER :: fd = 42, status 6126 1.1 mrg CHARACTER :: c 6127 1.1 mrg 6128 1.1 mrg OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD") 6129 1.1 mrg DO 6130 1.1 mrg CALL fgetc(fd, c, status) 6131 1.1 mrg IF (status /= 0) EXIT 6132 1.1 mrg call fput(c) 6133 1.1 mrg END DO 6134 1.1 mrg CLOSE(UNIT=fd) 6135 1.1 mrg END PROGRAM 6136 1.1 mrg @end smallexample 6137 1.1 mrg 6138 1.1 mrg @item @emph{See also}: 6139 1.1.1.2 mrg @ref{FGET}, @gol 6140 1.1.1.2 mrg @ref{FPUT}, @gol 6141 1.1.1.2 mrg @ref{FPUTC} 6142 1.1 mrg @end table 6143 1.1 mrg 6144 1.1 mrg @node FINDLOC 6145 1.1 mrg @section @code{FINDLOC} --- Search an array for a value 6146 1.1 mrg @fnindex FINDLOC 6147 1.1 mrg @cindex findloc 6148 1.1 mrg 6149 1.1 mrg @table @asis 6150 1.1 mrg @item @emph{Description}: 6151 1.1 mrg Determines the location of the element in the array with the value 6152 1.1 mrg given in the @var{VALUE} argument, or, if the @var{DIM} argument is 6153 1.1.1.2 mrg supplied, determines the locations of the elements equal to the 6154 1.1.1.2 mrg @var{VALUE} argument element along each 6155 1.1 mrg row of the array in the @var{DIM} direction. If @var{MASK} is 6156 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are 6157 1.1 mrg considered. If more than one element in the array has the value 6158 1.1 mrg @var{VALUE}, the location returned is that of the first such element 6159 1.1 mrg in array element order if the @var{BACK} is not present or if it is 6160 1.1 mrg @code{.FALSE.}. If @var{BACK} is true, the location returned is that 6161 1.1 mrg of the last such element. If the array has zero size, or all of the 6162 1.1 mrg elements of @var{MASK} are @code{.FALSE.}, then the result is an array 6163 1.1 mrg of zeroes. Similarly, if @var{DIM} is supplied and all of the 6164 1.1 mrg elements of @var{MASK} along a given row are zero, the result value 6165 1.1 mrg for that row is zero. 6166 1.1 mrg 6167 1.1 mrg @item @emph{Standard}: 6168 1.1 mrg Fortran 2008 and later. 6169 1.1 mrg 6170 1.1 mrg @item @emph{Class}: 6171 1.1 mrg Transformational function 6172 1.1 mrg 6173 1.1 mrg @item @emph{Syntax}: 6174 1.1 mrg @multitable @columnfractions .80 6175 1.1 mrg @item @code{RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND] [,BACK])} 6176 1.1 mrg @item @code{RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND] [,BACK])} 6177 1.1 mrg @end multitable 6178 1.1 mrg 6179 1.1 mrg @item @emph{Arguments}: 6180 1.1 mrg @multitable @columnfractions .15 .70 6181 1.1 mrg @item @var{ARRAY} @tab Shall be an array of intrinsic type. 6182 1.1 mrg @item @var{VALUE} @tab A scalar of intrinsic type which is in type 6183 1.1 mrg conformance with @var{ARRAY}. 6184 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type 6185 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY}, 6186 1.1 mrg inclusive. It may not be an optional dummy argument. 6187 1.1.1.3 mrg @item @var{MASK} @tab (Optional) Shall be of type @code{LOGICAL}, 6188 1.1.1.3 mrg and conformable with @var{ARRAY}. 6189 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 6190 1.1 mrg expression indicating the kind parameter of the result. 6191 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}. 6192 1.1 mrg @end multitable 6193 1.1 mrg 6194 1.1 mrg @item @emph{Return value}: 6195 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length 6196 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result 6197 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a 6198 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM} 6199 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank 6200 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND} 6201 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it 6202 1.1 mrg is of default kind. 6203 1.1 mrg 6204 1.1 mrg @item @emph{See also}: 6205 1.1.1.2 mrg @ref{MAXLOC}, @gol 6206 1.1.1.2 mrg @ref{MINLOC} 6207 1.1 mrg 6208 1.1 mrg @end table 6209 1.1 mrg 6210 1.1 mrg @node FLOOR 6211 1.1 mrg @section @code{FLOOR} --- Integer floor function 6212 1.1 mrg @fnindex FLOOR 6213 1.1 mrg @cindex floor 6214 1.1 mrg @cindex rounding, floor 6215 1.1 mrg 6216 1.1 mrg @table @asis 6217 1.1 mrg @item @emph{Description}: 6218 1.1 mrg @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}. 6219 1.1 mrg 6220 1.1 mrg @item @emph{Standard}: 6221 1.1 mrg Fortran 95 and later 6222 1.1 mrg 6223 1.1 mrg @item @emph{Class}: 6224 1.1 mrg Elemental function 6225 1.1 mrg 6226 1.1 mrg @item @emph{Syntax}: 6227 1.1 mrg @code{RESULT = FLOOR(A [, KIND])} 6228 1.1 mrg 6229 1.1 mrg @item @emph{Arguments}: 6230 1.1 mrg @multitable @columnfractions .15 .70 6231 1.1 mrg @item @var{A} @tab The type shall be @code{REAL}. 6232 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 6233 1.1 mrg expression indicating the kind parameter of the result. 6234 1.1 mrg @end multitable 6235 1.1 mrg 6236 1.1 mrg @item @emph{Return value}: 6237 1.1 mrg The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present 6238 1.1 mrg and of default-kind @code{INTEGER} otherwise. 6239 1.1 mrg 6240 1.1 mrg @item @emph{Example}: 6241 1.1 mrg @smallexample 6242 1.1 mrg program test_floor 6243 1.1 mrg real :: x = 63.29 6244 1.1 mrg real :: y = -63.59 6245 1.1 mrg print *, floor(x) ! returns 63 6246 1.1 mrg print *, floor(y) ! returns -64 6247 1.1 mrg end program test_floor 6248 1.1 mrg @end smallexample 6249 1.1 mrg 6250 1.1 mrg @item @emph{See also}: 6251 1.1.1.2 mrg @ref{CEILING}, @gol 6252 1.1.1.2 mrg @ref{NINT} 6253 1.1 mrg @end table 6254 1.1 mrg 6255 1.1 mrg 6256 1.1 mrg 6257 1.1 mrg @node FLUSH 6258 1.1 mrg @section @code{FLUSH} --- Flush I/O unit(s) 6259 1.1 mrg @fnindex FLUSH 6260 1.1 mrg @cindex file operation, flush 6261 1.1 mrg 6262 1.1 mrg @table @asis 6263 1.1 mrg @item @emph{Description}: 6264 1.1 mrg Flushes Fortran unit(s) currently open for output. Without the optional 6265 1.1 mrg argument, all units are flushed, otherwise just the unit specified. 6266 1.1 mrg 6267 1.1 mrg @item @emph{Standard}: 6268 1.1 mrg GNU extension 6269 1.1 mrg 6270 1.1 mrg @item @emph{Class}: 6271 1.1 mrg Subroutine 6272 1.1 mrg 6273 1.1 mrg @item @emph{Syntax}: 6274 1.1 mrg @code{CALL FLUSH(UNIT)} 6275 1.1 mrg 6276 1.1 mrg @item @emph{Arguments}: 6277 1.1 mrg @multitable @columnfractions .15 .70 6278 1.1 mrg @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}. 6279 1.1 mrg @end multitable 6280 1.1 mrg 6281 1.1 mrg @item @emph{Note}: 6282 1.1 mrg Beginning with the Fortran 2003 standard, there is a @code{FLUSH} 6283 1.1 mrg statement that should be preferred over the @code{FLUSH} intrinsic. 6284 1.1 mrg 6285 1.1 mrg The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement 6286 1.1 mrg have identical effect: they flush the runtime library's I/O buffer so 6287 1.1 mrg that the data becomes visible to other processes. This does not guarantee 6288 1.1 mrg that the data is committed to disk. 6289 1.1 mrg 6290 1.1 mrg On POSIX systems, you can request that all data is transferred to the 6291 1.1 mrg storage device by calling the @code{fsync} function, with the POSIX file 6292 1.1 mrg descriptor of the I/O unit as argument (retrieved with GNU intrinsic 6293 1.1 mrg @code{FNUM}). The following example shows how: 6294 1.1 mrg 6295 1.1 mrg @smallexample 6296 1.1 mrg ! Declare the interface for POSIX fsync function 6297 1.1 mrg interface 6298 1.1 mrg function fsync (fd) bind(c,name="fsync") 6299 1.1 mrg use iso_c_binding, only: c_int 6300 1.1 mrg integer(c_int), value :: fd 6301 1.1 mrg integer(c_int) :: fsync 6302 1.1 mrg end function fsync 6303 1.1 mrg end interface 6304 1.1 mrg 6305 1.1 mrg ! Variable declaration 6306 1.1 mrg integer :: ret 6307 1.1 mrg 6308 1.1 mrg ! Opening unit 10 6309 1.1 mrg open (10,file="foo") 6310 1.1 mrg 6311 1.1 mrg ! ... 6312 1.1 mrg ! Perform I/O on unit 10 6313 1.1 mrg ! ... 6314 1.1 mrg 6315 1.1 mrg ! Flush and sync 6316 1.1 mrg flush(10) 6317 1.1 mrg ret = fsync(fnum(10)) 6318 1.1 mrg 6319 1.1 mrg ! Handle possible error 6320 1.1 mrg if (ret /= 0) stop "Error calling FSYNC" 6321 1.1 mrg @end smallexample 6322 1.1 mrg 6323 1.1 mrg @end table 6324 1.1 mrg 6325 1.1 mrg 6326 1.1 mrg 6327 1.1 mrg @node FNUM 6328 1.1 mrg @section @code{FNUM} --- File number function 6329 1.1 mrg @fnindex FNUM 6330 1.1 mrg @cindex file operation, file number 6331 1.1 mrg 6332 1.1 mrg @table @asis 6333 1.1 mrg @item @emph{Description}: 6334 1.1 mrg @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the 6335 1.1 mrg open Fortran I/O unit @code{UNIT}. 6336 1.1 mrg 6337 1.1 mrg @item @emph{Standard}: 6338 1.1 mrg GNU extension 6339 1.1 mrg 6340 1.1 mrg @item @emph{Class}: 6341 1.1 mrg Function 6342 1.1 mrg 6343 1.1 mrg @item @emph{Syntax}: 6344 1.1 mrg @code{RESULT = FNUM(UNIT)} 6345 1.1 mrg 6346 1.1 mrg @item @emph{Arguments}: 6347 1.1 mrg @multitable @columnfractions .15 .70 6348 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}. 6349 1.1 mrg @end multitable 6350 1.1 mrg 6351 1.1 mrg @item @emph{Return value}: 6352 1.1 mrg The return value is of type @code{INTEGER} 6353 1.1 mrg 6354 1.1 mrg @item @emph{Example}: 6355 1.1 mrg @smallexample 6356 1.1 mrg program test_fnum 6357 1.1 mrg integer :: i 6358 1.1 mrg open (unit=10, status = "scratch") 6359 1.1 mrg i = fnum(10) 6360 1.1 mrg print *, i 6361 1.1 mrg close (10) 6362 1.1 mrg end program test_fnum 6363 1.1 mrg @end smallexample 6364 1.1 mrg @end table 6365 1.1 mrg 6366 1.1 mrg 6367 1.1 mrg 6368 1.1 mrg @node FPUT 6369 1.1 mrg @section @code{FPUT} --- Write a single character in stream mode to stdout 6370 1.1 mrg @fnindex FPUT 6371 1.1 mrg @cindex write character, stream mode 6372 1.1 mrg @cindex stream mode, write character 6373 1.1 mrg @cindex file operation, write character 6374 1.1 mrg 6375 1.1 mrg @table @asis 6376 1.1 mrg @item @emph{Description}: 6377 1.1 mrg Write a single character in stream mode to stdout by bypassing normal 6378 1.1 mrg formatted output. Stream I/O should not be mixed with normal record-oriented 6379 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable. 6380 1.1 mrg 6381 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 6382 1.1 mrg only one form can be used in any given program unit. 6383 1.1 mrg 6384 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with 6385 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility. 6386 1.1 mrg Programmers should consider the use of new stream IO feature in new code 6387 1.1 mrg for future portability. See also @ref{Fortran 2003 status}. 6388 1.1 mrg 6389 1.1 mrg @item @emph{Standard}: 6390 1.1 mrg GNU extension 6391 1.1 mrg 6392 1.1 mrg @item @emph{Class}: 6393 1.1 mrg Subroutine, function 6394 1.1 mrg 6395 1.1 mrg @item @emph{Syntax}: 6396 1.1 mrg @multitable @columnfractions .80 6397 1.1 mrg @item @code{CALL FPUT(C [, STATUS])} 6398 1.1 mrg @item @code{STATUS = FPUT(C)} 6399 1.1 mrg @end multitable 6400 1.1 mrg 6401 1.1 mrg @item @emph{Arguments}: 6402 1.1 mrg @multitable @columnfractions .15 .70 6403 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default 6404 1.1 mrg kind. 6405 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. 6406 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive 6407 1.1 mrg error code otherwise. 6408 1.1 mrg @end multitable 6409 1.1 mrg 6410 1.1 mrg @item @emph{Example}: 6411 1.1 mrg @smallexample 6412 1.1 mrg PROGRAM test_fput 6413 1.1 mrg CHARACTER(len=10) :: str = "gfortran" 6414 1.1 mrg INTEGER :: i 6415 1.1 mrg DO i = 1, len_trim(str) 6416 1.1 mrg CALL fput(str(i:i)) 6417 1.1 mrg END DO 6418 1.1 mrg END PROGRAM 6419 1.1 mrg @end smallexample 6420 1.1 mrg 6421 1.1 mrg @item @emph{See also}: 6422 1.1.1.2 mrg @ref{FPUTC}, @gol 6423 1.1.1.2 mrg @ref{FGET}, @gol 6424 1.1.1.2 mrg @ref{FGETC} 6425 1.1 mrg @end table 6426 1.1 mrg 6427 1.1 mrg 6428 1.1 mrg 6429 1.1 mrg @node FPUTC 6430 1.1 mrg @section @code{FPUTC} --- Write a single character in stream mode 6431 1.1 mrg @fnindex FPUTC 6432 1.1 mrg @cindex write character, stream mode 6433 1.1 mrg @cindex stream mode, write character 6434 1.1 mrg @cindex file operation, write character 6435 1.1 mrg 6436 1.1 mrg @table @asis 6437 1.1 mrg @item @emph{Description}: 6438 1.1 mrg Write a single character in stream mode by bypassing normal formatted 6439 1.1 mrg output. Stream I/O should not be mixed with normal record-oriented 6440 1.1 mrg (formatted or unformatted) I/O on the same unit; the results are unpredictable. 6441 1.1 mrg 6442 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 6443 1.1 mrg only one form can be used in any given program unit. 6444 1.1 mrg 6445 1.1 mrg Note that the @code{FGET} intrinsic is provided for backwards compatibility with 6446 1.1 mrg @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility. 6447 1.1 mrg Programmers should consider the use of new stream IO feature in new code 6448 1.1 mrg for future portability. See also @ref{Fortran 2003 status}. 6449 1.1 mrg 6450 1.1 mrg @item @emph{Standard}: 6451 1.1 mrg GNU extension 6452 1.1 mrg 6453 1.1 mrg @item @emph{Class}: 6454 1.1 mrg Subroutine, function 6455 1.1 mrg 6456 1.1 mrg @item @emph{Syntax}: 6457 1.1 mrg @multitable @columnfractions .80 6458 1.1 mrg @item @code{CALL FPUTC(UNIT, C [, STATUS])} 6459 1.1 mrg @item @code{STATUS = FPUTC(UNIT, C)} 6460 1.1 mrg @end multitable 6461 1.1 mrg 6462 1.1 mrg @item @emph{Arguments}: 6463 1.1 mrg @multitable @columnfractions .15 .70 6464 1.1 mrg @item @var{UNIT} @tab The type shall be @code{INTEGER}. 6465 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default 6466 1.1 mrg kind. 6467 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. 6468 1.1 mrg Returns 0 on success, -1 on end-of-file and a system specific positive 6469 1.1 mrg error code otherwise. 6470 1.1 mrg @end multitable 6471 1.1 mrg 6472 1.1 mrg @item @emph{Example}: 6473 1.1 mrg @smallexample 6474 1.1 mrg PROGRAM test_fputc 6475 1.1 mrg CHARACTER(len=10) :: str = "gfortran" 6476 1.1 mrg INTEGER :: fd = 42, i 6477 1.1 mrg 6478 1.1 mrg OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW") 6479 1.1 mrg DO i = 1, len_trim(str) 6480 1.1 mrg CALL fputc(fd, str(i:i)) 6481 1.1 mrg END DO 6482 1.1 mrg CLOSE(fd) 6483 1.1 mrg END PROGRAM 6484 1.1 mrg @end smallexample 6485 1.1 mrg 6486 1.1 mrg @item @emph{See also}: 6487 1.1.1.2 mrg @ref{FPUT}, @gol 6488 1.1.1.2 mrg @ref{FGET}, @gol 6489 1.1.1.2 mrg @ref{FGETC} 6490 1.1 mrg @end table 6491 1.1 mrg 6492 1.1 mrg 6493 1.1 mrg 6494 1.1 mrg @node FRACTION 6495 1.1 mrg @section @code{FRACTION} --- Fractional part of the model representation 6496 1.1 mrg @fnindex FRACTION 6497 1.1 mrg @cindex real number, fraction 6498 1.1 mrg @cindex floating point, fraction 6499 1.1 mrg 6500 1.1 mrg @table @asis 6501 1.1 mrg @item @emph{Description}: 6502 1.1 mrg @code{FRACTION(X)} returns the fractional part of the model 6503 1.1 mrg representation of @code{X}. 6504 1.1 mrg 6505 1.1 mrg @item @emph{Standard}: 6506 1.1.1.2 mrg Fortran 90 and later 6507 1.1 mrg 6508 1.1 mrg @item @emph{Class}: 6509 1.1 mrg Elemental function 6510 1.1 mrg 6511 1.1 mrg @item @emph{Syntax}: 6512 1.1 mrg @code{Y = FRACTION(X)} 6513 1.1 mrg 6514 1.1 mrg @item @emph{Arguments}: 6515 1.1 mrg @multitable @columnfractions .15 .70 6516 1.1 mrg @item @var{X} @tab The type of the argument shall be a @code{REAL}. 6517 1.1 mrg @end multitable 6518 1.1 mrg 6519 1.1 mrg @item @emph{Return value}: 6520 1.1 mrg The return value is of the same type and kind as the argument. 6521 1.1 mrg The fractional part of the model representation of @code{X} is returned; 6522 1.1 mrg it is @code{X * RADIX(X)**(-EXPONENT(X))}. 6523 1.1 mrg 6524 1.1 mrg @item @emph{Example}: 6525 1.1 mrg @smallexample 6526 1.1 mrg program test_fraction 6527 1.1 mrg real :: x 6528 1.1 mrg x = 178.1387e-4 6529 1.1 mrg print *, fraction(x), x * radix(x)**(-exponent(x)) 6530 1.1 mrg end program test_fraction 6531 1.1 mrg @end smallexample 6532 1.1 mrg 6533 1.1 mrg @end table 6534 1.1 mrg 6535 1.1 mrg 6536 1.1 mrg 6537 1.1 mrg @node FREE 6538 1.1 mrg @section @code{FREE} --- Frees memory 6539 1.1 mrg @fnindex FREE 6540 1.1 mrg @cindex pointer, cray 6541 1.1 mrg 6542 1.1 mrg @table @asis 6543 1.1 mrg @item @emph{Description}: 6544 1.1 mrg Frees memory previously allocated by @code{MALLOC}. The @code{FREE} 6545 1.1 mrg intrinsic is an extension intended to be used with Cray pointers, and is 6546 1.1 mrg provided in GNU Fortran to allow user to compile legacy code. For 6547 1.1 mrg new code using Fortran 95 pointers, the memory de-allocation intrinsic is 6548 1.1 mrg @code{DEALLOCATE}. 6549 1.1 mrg 6550 1.1 mrg @item @emph{Standard}: 6551 1.1 mrg GNU extension 6552 1.1 mrg 6553 1.1 mrg @item @emph{Class}: 6554 1.1 mrg Subroutine 6555 1.1 mrg 6556 1.1 mrg @item @emph{Syntax}: 6557 1.1 mrg @code{CALL FREE(PTR)} 6558 1.1 mrg 6559 1.1 mrg @item @emph{Arguments}: 6560 1.1 mrg @multitable @columnfractions .15 .70 6561 1.1 mrg @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the 6562 1.1 mrg location of the memory that should be de-allocated. 6563 1.1 mrg @end multitable 6564 1.1 mrg 6565 1.1 mrg @item @emph{Return value}: 6566 1.1 mrg None 6567 1.1 mrg 6568 1.1 mrg @item @emph{Example}: 6569 1.1 mrg See @code{MALLOC} for an example. 6570 1.1 mrg 6571 1.1 mrg @item @emph{See also}: 6572 1.1 mrg @ref{MALLOC} 6573 1.1 mrg @end table 6574 1.1 mrg 6575 1.1 mrg 6576 1.1 mrg 6577 1.1 mrg @node FSEEK 6578 1.1 mrg @section @code{FSEEK} --- Low level file positioning subroutine 6579 1.1 mrg @fnindex FSEEK 6580 1.1 mrg @cindex file operation, seek 6581 1.1 mrg @cindex file operation, position 6582 1.1 mrg 6583 1.1 mrg @table @asis 6584 1.1 mrg @item @emph{Description}: 6585 1.1 mrg Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} 6586 1.1 mrg is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET}, 6587 1.1 mrg if set to 1, @var{OFFSET} is taken to be relative to the current position 6588 1.1 mrg @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}. 6589 1.1 mrg On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek 6590 1.1 mrg fails silently. 6591 1.1 mrg 6592 1.1 mrg This intrinsic routine is not fully backwards compatible with @command{g77}. 6593 1.1 mrg In @command{g77}, the @code{FSEEK} takes a statement label instead of a 6594 1.1 mrg @var{STATUS} variable. If FSEEK is used in old code, change 6595 1.1 mrg @smallexample 6596 1.1 mrg CALL FSEEK(UNIT, OFFSET, WHENCE, *label) 6597 1.1 mrg @end smallexample 6598 1.1 mrg to 6599 1.1 mrg @smallexample 6600 1.1 mrg INTEGER :: status 6601 1.1 mrg CALL FSEEK(UNIT, OFFSET, WHENCE, status) 6602 1.1 mrg IF (status /= 0) GOTO label 6603 1.1 mrg @end smallexample 6604 1.1 mrg 6605 1.1 mrg Please note that GNU Fortran provides the Fortran 2003 Stream facility. 6606 1.1 mrg Programmers should consider the use of new stream IO feature in new code 6607 1.1 mrg for future portability. See also @ref{Fortran 2003 status}. 6608 1.1 mrg 6609 1.1 mrg @item @emph{Standard}: 6610 1.1 mrg GNU extension 6611 1.1 mrg 6612 1.1 mrg @item @emph{Class}: 6613 1.1 mrg Subroutine 6614 1.1 mrg 6615 1.1 mrg @item @emph{Syntax}: 6616 1.1 mrg @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])} 6617 1.1 mrg 6618 1.1 mrg @item @emph{Arguments}: 6619 1.1 mrg @multitable @columnfractions .15 .70 6620 1.1 mrg @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}. 6621 1.1 mrg @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}. 6622 1.1 mrg @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}. 6623 1.1 mrg Its value shall be either 0, 1 or 2. 6624 1.1 mrg @item @var{STATUS} @tab (Optional) shall be a scalar of type 6625 1.1 mrg @code{INTEGER(4)}. 6626 1.1 mrg @end multitable 6627 1.1 mrg 6628 1.1 mrg @item @emph{Example}: 6629 1.1 mrg @smallexample 6630 1.1 mrg PROGRAM test_fseek 6631 1.1 mrg INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2 6632 1.1 mrg INTEGER :: fd, offset, ierr 6633 1.1 mrg 6634 1.1 mrg ierr = 0 6635 1.1 mrg offset = 5 6636 1.1 mrg fd = 10 6637 1.1 mrg 6638 1.1 mrg OPEN(UNIT=fd, FILE="fseek.test") 6639 1.1 mrg CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET 6640 1.1 mrg print *, FTELL(fd), ierr 6641 1.1 mrg 6642 1.1 mrg CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end 6643 1.1 mrg print *, FTELL(fd), ierr 6644 1.1 mrg 6645 1.1 mrg CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning 6646 1.1 mrg print *, FTELL(fd), ierr 6647 1.1 mrg 6648 1.1 mrg CLOSE(UNIT=fd) 6649 1.1 mrg END PROGRAM 6650 1.1 mrg @end smallexample 6651 1.1 mrg 6652 1.1 mrg @item @emph{See also}: 6653 1.1 mrg @ref{FTELL} 6654 1.1 mrg @end table 6655 1.1 mrg 6656 1.1 mrg 6657 1.1 mrg 6658 1.1 mrg @node FSTAT 6659 1.1 mrg @section @code{FSTAT} --- Get file status 6660 1.1 mrg @fnindex FSTAT 6661 1.1 mrg @cindex file system, file status 6662 1.1 mrg 6663 1.1 mrg @table @asis 6664 1.1 mrg @item @emph{Description}: 6665 1.1 mrg @code{FSTAT} is identical to @ref{STAT}, except that information about an 6666 1.1 mrg already opened file is obtained. 6667 1.1 mrg 6668 1.1 mrg The elements in @code{VALUES} are the same as described by @ref{STAT}. 6669 1.1 mrg 6670 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 6671 1.1 mrg only one form can be used in any given program unit. 6672 1.1 mrg 6673 1.1 mrg @item @emph{Standard}: 6674 1.1 mrg GNU extension 6675 1.1 mrg 6676 1.1 mrg @item @emph{Class}: 6677 1.1 mrg Subroutine, function 6678 1.1 mrg 6679 1.1 mrg @item @emph{Syntax}: 6680 1.1 mrg @multitable @columnfractions .80 6681 1.1 mrg @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])} 6682 1.1 mrg @item @code{STATUS = FSTAT(UNIT, VALUES)} 6683 1.1 mrg @end multitable 6684 1.1 mrg 6685 1.1 mrg @item @emph{Arguments}: 6686 1.1 mrg @multitable @columnfractions .15 .70 6687 1.1 mrg @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}. 6688 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}. 6689 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 6690 1.1 mrg on success and a system specific error code otherwise. 6691 1.1 mrg @end multitable 6692 1.1 mrg 6693 1.1 mrg @item @emph{Example}: 6694 1.1 mrg See @ref{STAT} for an example. 6695 1.1 mrg 6696 1.1 mrg @item @emph{See also}: 6697 1.1.1.2 mrg To stat a link: @gol 6698 1.1.1.2 mrg @ref{LSTAT} @gol 6699 1.1.1.2 mrg To stat a file: @gol 6700 1.1.1.2 mrg @ref{STAT} 6701 1.1 mrg @end table 6702 1.1 mrg 6703 1.1 mrg 6704 1.1 mrg 6705 1.1 mrg @node FTELL 6706 1.1 mrg @section @code{FTELL} --- Current stream position 6707 1.1 mrg @fnindex FTELL 6708 1.1 mrg @cindex file operation, position 6709 1.1 mrg 6710 1.1 mrg @table @asis 6711 1.1 mrg @item @emph{Description}: 6712 1.1 mrg Retrieves the current position within an open file. 6713 1.1 mrg 6714 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 6715 1.1 mrg only one form can be used in any given program unit. 6716 1.1 mrg 6717 1.1 mrg @item @emph{Standard}: 6718 1.1 mrg GNU extension 6719 1.1 mrg 6720 1.1 mrg @item @emph{Class}: 6721 1.1 mrg Subroutine, function 6722 1.1 mrg 6723 1.1 mrg @item @emph{Syntax}: 6724 1.1 mrg @multitable @columnfractions .80 6725 1.1 mrg @item @code{CALL FTELL(UNIT, OFFSET)} 6726 1.1 mrg @item @code{OFFSET = FTELL(UNIT)} 6727 1.1 mrg @end multitable 6728 1.1 mrg 6729 1.1 mrg @item @emph{Arguments}: 6730 1.1 mrg @multitable @columnfractions .15 .70 6731 1.1 mrg @item @var{OFFSET} @tab Shall of type @code{INTEGER}. 6732 1.1 mrg @item @var{UNIT} @tab Shall of type @code{INTEGER}. 6733 1.1 mrg @end multitable 6734 1.1 mrg 6735 1.1 mrg @item @emph{Return value}: 6736 1.1 mrg In either syntax, @var{OFFSET} is set to the current offset of unit 6737 1.1 mrg number @var{UNIT}, or to @math{-1} if the unit is not currently open. 6738 1.1 mrg 6739 1.1 mrg @item @emph{Example}: 6740 1.1 mrg @smallexample 6741 1.1 mrg PROGRAM test_ftell 6742 1.1 mrg INTEGER :: i 6743 1.1 mrg OPEN(10, FILE="temp.dat") 6744 1.1 mrg CALL ftell(10,i) 6745 1.1 mrg WRITE(*,*) i 6746 1.1 mrg END PROGRAM 6747 1.1 mrg @end smallexample 6748 1.1 mrg 6749 1.1 mrg @item @emph{See also}: 6750 1.1 mrg @ref{FSEEK} 6751 1.1 mrg @end table 6752 1.1 mrg 6753 1.1 mrg 6754 1.1 mrg 6755 1.1 mrg @node GAMMA 6756 1.1 mrg @section @code{GAMMA} --- Gamma function 6757 1.1 mrg @fnindex GAMMA 6758 1.1 mrg @fnindex DGAMMA 6759 1.1 mrg @cindex Gamma function 6760 1.1 mrg @cindex Factorial function 6761 1.1 mrg 6762 1.1 mrg @table @asis 6763 1.1 mrg @item @emph{Description}: 6764 1.1 mrg @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive, 6765 1.1 mrg integer values of @var{X} the Gamma function simplifies to the factorial 6766 1.1 mrg function @math{\Gamma(x)=(x-1)!}. 6767 1.1 mrg 6768 1.1 mrg @tex 6769 1.1 mrg $$ 6770 1.1 mrg \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t 6771 1.1 mrg $$ 6772 1.1 mrg @end tex 6773 1.1 mrg 6774 1.1 mrg @item @emph{Standard}: 6775 1.1 mrg Fortran 2008 and later 6776 1.1 mrg 6777 1.1 mrg @item @emph{Class}: 6778 1.1 mrg Elemental function 6779 1.1 mrg 6780 1.1 mrg @item @emph{Syntax}: 6781 1.1 mrg @code{X = GAMMA(X)} 6782 1.1 mrg 6783 1.1 mrg @item @emph{Arguments}: 6784 1.1 mrg @multitable @columnfractions .15 .70 6785 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} and neither zero 6786 1.1 mrg nor a negative integer. 6787 1.1 mrg @end multitable 6788 1.1 mrg 6789 1.1 mrg @item @emph{Return value}: 6790 1.1 mrg The return value is of type @code{REAL} of the same kind as @var{X}. 6791 1.1 mrg 6792 1.1 mrg @item @emph{Example}: 6793 1.1 mrg @smallexample 6794 1.1 mrg program test_gamma 6795 1.1 mrg real :: x = 1.0 6796 1.1 mrg x = gamma(x) ! returns 1.0 6797 1.1 mrg end program test_gamma 6798 1.1 mrg @end smallexample 6799 1.1 mrg 6800 1.1 mrg @item @emph{Specific names}: 6801 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 6802 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 6803 1.1.1.2 mrg @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 6804 1.1 mrg @end multitable 6805 1.1 mrg 6806 1.1 mrg @item @emph{See also}: 6807 1.1.1.2 mrg Logarithm of the Gamma function: @gol 6808 1.1.1.2 mrg @ref{LOG_GAMMA} 6809 1.1 mrg @end table 6810 1.1 mrg 6811 1.1 mrg 6812 1.1 mrg 6813 1.1 mrg @node GERROR 6814 1.1 mrg @section @code{GERROR} --- Get last system error message 6815 1.1 mrg @fnindex GERROR 6816 1.1 mrg @cindex system, error handling 6817 1.1 mrg 6818 1.1 mrg @table @asis 6819 1.1 mrg @item @emph{Description}: 6820 1.1 mrg Returns the system error message corresponding to the last system error. 6821 1.1 mrg This resembles the functionality of @code{strerror(3)} in C. 6822 1.1 mrg 6823 1.1 mrg @item @emph{Standard}: 6824 1.1 mrg GNU extension 6825 1.1 mrg 6826 1.1 mrg @item @emph{Class}: 6827 1.1 mrg Subroutine 6828 1.1 mrg 6829 1.1 mrg @item @emph{Syntax}: 6830 1.1 mrg @code{CALL GERROR(RESULT)} 6831 1.1 mrg 6832 1.1 mrg @item @emph{Arguments}: 6833 1.1 mrg @multitable @columnfractions .15 .70 6834 1.1.1.3 mrg @item @var{RESULT} @tab Shall be of type @code{CHARACTER} and of default kind. 6835 1.1 mrg @end multitable 6836 1.1 mrg 6837 1.1 mrg @item @emph{Example}: 6838 1.1 mrg @smallexample 6839 1.1 mrg PROGRAM test_gerror 6840 1.1 mrg CHARACTER(len=100) :: msg 6841 1.1 mrg CALL gerror(msg) 6842 1.1 mrg WRITE(*,*) msg 6843 1.1 mrg END PROGRAM 6844 1.1 mrg @end smallexample 6845 1.1 mrg 6846 1.1 mrg @item @emph{See also}: 6847 1.1.1.2 mrg @ref{IERRNO}, @gol 6848 1.1.1.2 mrg @ref{PERROR} 6849 1.1 mrg @end table 6850 1.1 mrg 6851 1.1 mrg 6852 1.1 mrg 6853 1.1 mrg @node GETARG 6854 1.1 mrg @section @code{GETARG} --- Get command line arguments 6855 1.1 mrg @fnindex GETARG 6856 1.1 mrg @cindex command-line arguments 6857 1.1 mrg @cindex arguments, to program 6858 1.1 mrg 6859 1.1 mrg @table @asis 6860 1.1 mrg @item @emph{Description}: 6861 1.1 mrg Retrieve the @var{POS}-th argument that was passed on the 6862 1.1 mrg command line when the containing program was invoked. 6863 1.1 mrg 6864 1.1 mrg This intrinsic routine is provided for backwards compatibility with 6865 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of 6866 1.1 mrg the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 6867 1.1 mrg standard. 6868 1.1 mrg 6869 1.1 mrg @item @emph{Standard}: 6870 1.1 mrg GNU extension 6871 1.1 mrg 6872 1.1 mrg @item @emph{Class}: 6873 1.1 mrg Subroutine 6874 1.1 mrg 6875 1.1 mrg @item @emph{Syntax}: 6876 1.1 mrg @code{CALL GETARG(POS, VALUE)} 6877 1.1 mrg 6878 1.1 mrg @item @emph{Arguments}: 6879 1.1 mrg @multitable @columnfractions .15 .70 6880 1.1 mrg @item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than 6881 1.1 mrg the default integer kind; @math{@var{POS} \geq 0} 6882 1.1 mrg @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default 6883 1.1 mrg kind. 6884 1.1 mrg @end multitable 6885 1.1 mrg 6886 1.1 mrg @item @emph{Return value}: 6887 1.1 mrg After @code{GETARG} returns, the @var{VALUE} argument holds the 6888 1.1 mrg @var{POS}th command line argument. If @var{VALUE} cannot hold the 6889 1.1 mrg argument, it is truncated to fit the length of @var{VALUE}. If there are 6890 1.1 mrg less than @var{POS} arguments specified at the command line, @var{VALUE} 6891 1.1 mrg will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set 6892 1.1 mrg to the name of the program (on systems that support this feature). 6893 1.1 mrg 6894 1.1 mrg @item @emph{Example}: 6895 1.1 mrg @smallexample 6896 1.1 mrg PROGRAM test_getarg 6897 1.1 mrg INTEGER :: i 6898 1.1 mrg CHARACTER(len=32) :: arg 6899 1.1 mrg 6900 1.1 mrg DO i = 1, iargc() 6901 1.1 mrg CALL getarg(i, arg) 6902 1.1 mrg WRITE (*,*) arg 6903 1.1 mrg END DO 6904 1.1 mrg END PROGRAM 6905 1.1 mrg @end smallexample 6906 1.1 mrg 6907 1.1 mrg @item @emph{See also}: 6908 1.1.1.2 mrg GNU Fortran 77 compatibility function: @gol 6909 1.1.1.2 mrg @ref{IARGC} @gol 6910 1.1.1.2 mrg Fortran 2003 functions and subroutines: @gol 6911 1.1.1.2 mrg @ref{GET_COMMAND}, @gol 6912 1.1.1.2 mrg @ref{GET_COMMAND_ARGUMENT}, @gol 6913 1.1.1.2 mrg @ref{COMMAND_ARGUMENT_COUNT} 6914 1.1 mrg @end table 6915 1.1 mrg 6916 1.1 mrg 6917 1.1 mrg 6918 1.1 mrg @node GET_COMMAND 6919 1.1 mrg @section @code{GET_COMMAND} --- Get the entire command line 6920 1.1 mrg @fnindex GET_COMMAND 6921 1.1 mrg @cindex command-line arguments 6922 1.1 mrg @cindex arguments, to program 6923 1.1 mrg 6924 1.1 mrg @table @asis 6925 1.1 mrg @item @emph{Description}: 6926 1.1 mrg Retrieve the entire command line that was used to invoke the program. 6927 1.1 mrg 6928 1.1 mrg @item @emph{Standard}: 6929 1.1 mrg Fortran 2003 and later 6930 1.1 mrg 6931 1.1 mrg @item @emph{Class}: 6932 1.1 mrg Subroutine 6933 1.1 mrg 6934 1.1 mrg @item @emph{Syntax}: 6935 1.1 mrg @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])} 6936 1.1 mrg 6937 1.1 mrg @item @emph{Arguments}: 6938 1.1 mrg @multitable @columnfractions .15 .70 6939 1.1 mrg @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and 6940 1.1 mrg of default kind. 6941 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of 6942 1.1 mrg default kind. 6943 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of 6944 1.1 mrg default kind. 6945 1.1 mrg @end multitable 6946 1.1 mrg 6947 1.1 mrg @item @emph{Return value}: 6948 1.1 mrg If @var{COMMAND} is present, stores the entire command line that was used 6949 1.1 mrg to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is 6950 1.1 mrg assigned the length of the command line. If @var{STATUS} is present, it 6951 1.1 mrg is assigned 0 upon success of the command, -1 if @var{COMMAND} is too 6952 1.1 mrg short to store the command line, or a positive value in case of an error. 6953 1.1 mrg 6954 1.1 mrg @item @emph{Example}: 6955 1.1 mrg @smallexample 6956 1.1 mrg PROGRAM test_get_command 6957 1.1 mrg CHARACTER(len=255) :: cmd 6958 1.1 mrg CALL get_command(cmd) 6959 1.1 mrg WRITE (*,*) TRIM(cmd) 6960 1.1 mrg END PROGRAM 6961 1.1 mrg @end smallexample 6962 1.1 mrg 6963 1.1 mrg @item @emph{See also}: 6964 1.1.1.2 mrg @ref{GET_COMMAND_ARGUMENT}, @gol 6965 1.1.1.2 mrg @ref{COMMAND_ARGUMENT_COUNT} 6966 1.1 mrg @end table 6967 1.1 mrg 6968 1.1 mrg 6969 1.1 mrg 6970 1.1 mrg @node GET_COMMAND_ARGUMENT 6971 1.1 mrg @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments 6972 1.1 mrg @fnindex GET_COMMAND_ARGUMENT 6973 1.1 mrg @cindex command-line arguments 6974 1.1 mrg @cindex arguments, to program 6975 1.1 mrg 6976 1.1 mrg @table @asis 6977 1.1 mrg @item @emph{Description}: 6978 1.1 mrg Retrieve the @var{NUMBER}-th argument that was passed on the 6979 1.1 mrg command line when the containing program was invoked. 6980 1.1 mrg 6981 1.1 mrg @item @emph{Standard}: 6982 1.1 mrg Fortran 2003 and later 6983 1.1 mrg 6984 1.1 mrg @item @emph{Class}: 6985 1.1 mrg Subroutine 6986 1.1 mrg 6987 1.1 mrg @item @emph{Syntax}: 6988 1.1 mrg @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])} 6989 1.1 mrg 6990 1.1 mrg @item @emph{Arguments}: 6991 1.1 mrg @multitable @columnfractions .15 .70 6992 1.1 mrg @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of 6993 1.1 mrg default kind, @math{@var{NUMBER} \geq 0} 6994 1.1 mrg @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER} 6995 1.1 mrg and of default kind. 6996 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER} 6997 1.1 mrg and of default kind. 6998 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER} 6999 1.1 mrg and of default kind. 7000 1.1 mrg @end multitable 7001 1.1 mrg 7002 1.1 mrg @item @emph{Return value}: 7003 1.1 mrg After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the 7004 1.1 mrg @var{NUMBER}-th command line argument. If @var{VALUE} cannot hold the argument, it is 7005 1.1 mrg truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER} 7006 1.1 mrg arguments specified at the command line, @var{VALUE} will be filled with blanks. 7007 1.1 mrg If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on 7008 1.1 mrg systems that support this feature). The @var{LENGTH} argument contains the 7009 1.1 mrg length of the @var{NUMBER}-th command line argument. If the argument retrieval 7010 1.1 mrg fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated 7011 1.1 mrg command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is 7012 1.1 mrg zero. 7013 1.1 mrg 7014 1.1 mrg @item @emph{Example}: 7015 1.1 mrg @smallexample 7016 1.1 mrg PROGRAM test_get_command_argument 7017 1.1 mrg INTEGER :: i 7018 1.1 mrg CHARACTER(len=32) :: arg 7019 1.1 mrg 7020 1.1 mrg i = 0 7021 1.1 mrg DO 7022 1.1 mrg CALL get_command_argument(i, arg) 7023 1.1 mrg IF (LEN_TRIM(arg) == 0) EXIT 7024 1.1 mrg 7025 1.1 mrg WRITE (*,*) TRIM(arg) 7026 1.1 mrg i = i+1 7027 1.1 mrg END DO 7028 1.1 mrg END PROGRAM 7029 1.1 mrg @end smallexample 7030 1.1 mrg 7031 1.1 mrg @item @emph{See also}: 7032 1.1.1.2 mrg @ref{GET_COMMAND}, @gol 7033 1.1.1.2 mrg @ref{COMMAND_ARGUMENT_COUNT} 7034 1.1 mrg @end table 7035 1.1 mrg 7036 1.1 mrg 7037 1.1 mrg 7038 1.1 mrg @node GETCWD 7039 1.1 mrg @section @code{GETCWD} --- Get current working directory 7040 1.1 mrg @fnindex GETCWD 7041 1.1 mrg @cindex system, working directory 7042 1.1 mrg 7043 1.1 mrg @table @asis 7044 1.1 mrg @item @emph{Description}: 7045 1.1 mrg Get current working directory. 7046 1.1 mrg 7047 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 7048 1.1 mrg only one form can be used in any given program unit. 7049 1.1 mrg 7050 1.1 mrg @item @emph{Standard}: 7051 1.1 mrg GNU extension 7052 1.1 mrg 7053 1.1 mrg @item @emph{Class}: 7054 1.1 mrg Subroutine, function 7055 1.1 mrg 7056 1.1 mrg @item @emph{Syntax}: 7057 1.1 mrg @multitable @columnfractions .80 7058 1.1 mrg @item @code{CALL GETCWD(C [, STATUS])} 7059 1.1 mrg @item @code{STATUS = GETCWD(C)} 7060 1.1 mrg @end multitable 7061 1.1 mrg 7062 1.1 mrg @item @emph{Arguments}: 7063 1.1 mrg @multitable @columnfractions .15 .70 7064 1.1 mrg @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind. 7065 1.1 mrg @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 7066 1.1 mrg a system specific and nonzero error code otherwise. 7067 1.1 mrg @end multitable 7068 1.1 mrg 7069 1.1 mrg @item @emph{Example}: 7070 1.1 mrg @smallexample 7071 1.1 mrg PROGRAM test_getcwd 7072 1.1 mrg CHARACTER(len=255) :: cwd 7073 1.1 mrg CALL getcwd(cwd) 7074 1.1 mrg WRITE(*,*) TRIM(cwd) 7075 1.1 mrg END PROGRAM 7076 1.1 mrg @end smallexample 7077 1.1 mrg 7078 1.1 mrg @item @emph{See also}: 7079 1.1 mrg @ref{CHDIR} 7080 1.1 mrg @end table 7081 1.1 mrg 7082 1.1 mrg 7083 1.1 mrg 7084 1.1 mrg @node GETENV 7085 1.1 mrg @section @code{GETENV} --- Get an environmental variable 7086 1.1 mrg @fnindex GETENV 7087 1.1 mrg @cindex environment variable 7088 1.1 mrg 7089 1.1 mrg @table @asis 7090 1.1 mrg @item @emph{Description}: 7091 1.1 mrg Get the @var{VALUE} of the environmental variable @var{NAME}. 7092 1.1 mrg 7093 1.1 mrg This intrinsic routine is provided for backwards compatibility with 7094 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of 7095 1.1 mrg the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran 7096 1.1 mrg 2003 standard. 7097 1.1 mrg 7098 1.1 mrg Note that @code{GETENV} need not be thread-safe. It is the 7099 1.1 mrg responsibility of the user to ensure that the environment is not being 7100 1.1 mrg updated concurrently with a call to the @code{GETENV} intrinsic. 7101 1.1 mrg 7102 1.1 mrg @item @emph{Standard}: 7103 1.1 mrg GNU extension 7104 1.1 mrg 7105 1.1 mrg @item @emph{Class}: 7106 1.1 mrg Subroutine 7107 1.1 mrg 7108 1.1 mrg @item @emph{Syntax}: 7109 1.1 mrg @code{CALL GETENV(NAME, VALUE)} 7110 1.1 mrg 7111 1.1 mrg @item @emph{Arguments}: 7112 1.1 mrg @multitable @columnfractions .15 .70 7113 1.1 mrg @item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind. 7114 1.1 mrg @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind. 7115 1.1 mrg @end multitable 7116 1.1 mrg 7117 1.1 mrg @item @emph{Return value}: 7118 1.1 mrg Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 7119 1.1 mrg not large enough to hold the data, it is truncated. If @var{NAME} 7120 1.1 mrg is not set, @var{VALUE} will be filled with blanks. 7121 1.1 mrg 7122 1.1 mrg @item @emph{Example}: 7123 1.1 mrg @smallexample 7124 1.1 mrg PROGRAM test_getenv 7125 1.1 mrg CHARACTER(len=255) :: homedir 7126 1.1 mrg CALL getenv("HOME", homedir) 7127 1.1 mrg WRITE (*,*) TRIM(homedir) 7128 1.1 mrg END PROGRAM 7129 1.1 mrg @end smallexample 7130 1.1 mrg 7131 1.1 mrg @item @emph{See also}: 7132 1.1 mrg @ref{GET_ENVIRONMENT_VARIABLE} 7133 1.1 mrg @end table 7134 1.1 mrg 7135 1.1 mrg 7136 1.1 mrg 7137 1.1 mrg @node GET_ENVIRONMENT_VARIABLE 7138 1.1 mrg @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable 7139 1.1 mrg @fnindex GET_ENVIRONMENT_VARIABLE 7140 1.1 mrg @cindex environment variable 7141 1.1 mrg 7142 1.1 mrg @table @asis 7143 1.1 mrg @item @emph{Description}: 7144 1.1 mrg Get the @var{VALUE} of the environmental variable @var{NAME}. 7145 1.1 mrg 7146 1.1 mrg Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It 7147 1.1 mrg is the responsibility of the user to ensure that the environment is 7148 1.1 mrg not being updated concurrently with a call to the 7149 1.1 mrg @code{GET_ENVIRONMENT_VARIABLE} intrinsic. 7150 1.1 mrg 7151 1.1 mrg @item @emph{Standard}: 7152 1.1 mrg Fortran 2003 and later 7153 1.1 mrg 7154 1.1 mrg @item @emph{Class}: 7155 1.1 mrg Subroutine 7156 1.1 mrg 7157 1.1 mrg @item @emph{Syntax}: 7158 1.1 mrg @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)} 7159 1.1 mrg 7160 1.1 mrg @item @emph{Arguments}: 7161 1.1 mrg @multitable @columnfractions .15 .70 7162 1.1 mrg @item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER} 7163 1.1 mrg and of default kind. 7164 1.1 mrg @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER} 7165 1.1 mrg and of default kind. 7166 1.1 mrg @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER} 7167 1.1 mrg and of default kind. 7168 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER} 7169 1.1 mrg and of default kind. 7170 1.1 mrg @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL} 7171 1.1 mrg and of default kind. 7172 1.1 mrg @end multitable 7173 1.1 mrg 7174 1.1 mrg @item @emph{Return value}: 7175 1.1 mrg Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 7176 1.1 mrg not large enough to hold the data, it is truncated. If @var{NAME} 7177 1.1 mrg is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH} 7178 1.1 mrg contains the length needed for storing the environment variable @var{NAME} 7179 1.1 mrg or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present 7180 1.1 mrg but too short for the environment variable; it is 1 if the environment 7181 1.1 mrg variable does not exist and 2 if the processor does not support environment 7182 1.1 mrg variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is 7183 1.1 mrg present with the value @code{.FALSE.}, the trailing blanks in @var{NAME} 7184 1.1 mrg are significant; otherwise they are not part of the environment variable 7185 1.1 mrg name. 7186 1.1 mrg 7187 1.1 mrg @item @emph{Example}: 7188 1.1 mrg @smallexample 7189 1.1 mrg PROGRAM test_getenv 7190 1.1 mrg CHARACTER(len=255) :: homedir 7191 1.1 mrg CALL get_environment_variable("HOME", homedir) 7192 1.1 mrg WRITE (*,*) TRIM(homedir) 7193 1.1 mrg END PROGRAM 7194 1.1 mrg @end smallexample 7195 1.1 mrg @end table 7196 1.1 mrg 7197 1.1 mrg 7198 1.1 mrg 7199 1.1 mrg @node GETGID 7200 1.1 mrg @section @code{GETGID} --- Group ID function 7201 1.1 mrg @fnindex GETGID 7202 1.1 mrg @cindex system, group ID 7203 1.1 mrg 7204 1.1 mrg @table @asis 7205 1.1 mrg @item @emph{Description}: 7206 1.1 mrg Returns the numerical group ID of the current process. 7207 1.1 mrg 7208 1.1 mrg @item @emph{Standard}: 7209 1.1 mrg GNU extension 7210 1.1 mrg 7211 1.1 mrg @item @emph{Class}: 7212 1.1 mrg Function 7213 1.1 mrg 7214 1.1 mrg @item @emph{Syntax}: 7215 1.1 mrg @code{RESULT = GETGID()} 7216 1.1 mrg 7217 1.1 mrg @item @emph{Return value}: 7218 1.1 mrg The return value of @code{GETGID} is an @code{INTEGER} of the default 7219 1.1 mrg kind. 7220 1.1 mrg 7221 1.1 mrg 7222 1.1 mrg @item @emph{Example}: 7223 1.1 mrg See @code{GETPID} for an example. 7224 1.1 mrg 7225 1.1 mrg @item @emph{See also}: 7226 1.1.1.2 mrg @ref{GETPID}, @gol 7227 1.1.1.2 mrg @ref{GETUID} 7228 1.1 mrg @end table 7229 1.1 mrg 7230 1.1 mrg 7231 1.1 mrg 7232 1.1 mrg @node GETLOG 7233 1.1 mrg @section @code{GETLOG} --- Get login name 7234 1.1 mrg @fnindex GETLOG 7235 1.1 mrg @cindex system, login name 7236 1.1 mrg @cindex login name 7237 1.1 mrg 7238 1.1 mrg @table @asis 7239 1.1 mrg @item @emph{Description}: 7240 1.1 mrg Gets the username under which the program is running. 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 GETLOG(C)} 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{C} @tab Shall be of type @code{CHARACTER} and of default kind. 7254 1.1 mrg @end multitable 7255 1.1 mrg 7256 1.1 mrg @item @emph{Return value}: 7257 1.1.1.3 mrg Stores the current user name in @var{C}. (On systems where POSIX 7258 1.1 mrg functions @code{geteuid} and @code{getpwuid} are not available, and 7259 1.1 mrg the @code{getlogin} function is not implemented either, this will 7260 1.1 mrg return a blank string.) 7261 1.1 mrg 7262 1.1 mrg @item @emph{Example}: 7263 1.1 mrg @smallexample 7264 1.1 mrg PROGRAM TEST_GETLOG 7265 1.1 mrg CHARACTER(32) :: login 7266 1.1 mrg CALL GETLOG(login) 7267 1.1 mrg WRITE(*,*) login 7268 1.1 mrg END PROGRAM 7269 1.1 mrg @end smallexample 7270 1.1 mrg 7271 1.1 mrg @item @emph{See also}: 7272 1.1 mrg @ref{GETUID} 7273 1.1 mrg @end table 7274 1.1 mrg 7275 1.1 mrg 7276 1.1 mrg 7277 1.1 mrg @node GETPID 7278 1.1 mrg @section @code{GETPID} --- Process ID function 7279 1.1 mrg @fnindex GETPID 7280 1.1 mrg @cindex system, process ID 7281 1.1 mrg @cindex process ID 7282 1.1 mrg 7283 1.1 mrg @table @asis 7284 1.1 mrg @item @emph{Description}: 7285 1.1 mrg Returns the numerical process identifier of the current process. 7286 1.1 mrg 7287 1.1 mrg @item @emph{Standard}: 7288 1.1 mrg GNU extension 7289 1.1 mrg 7290 1.1 mrg @item @emph{Class}: 7291 1.1 mrg Function 7292 1.1 mrg 7293 1.1 mrg @item @emph{Syntax}: 7294 1.1 mrg @code{RESULT = GETPID()} 7295 1.1 mrg 7296 1.1 mrg @item @emph{Return value}: 7297 1.1 mrg The return value of @code{GETPID} is an @code{INTEGER} of the default 7298 1.1 mrg kind. 7299 1.1 mrg 7300 1.1 mrg 7301 1.1 mrg @item @emph{Example}: 7302 1.1 mrg @smallexample 7303 1.1 mrg program info 7304 1.1 mrg print *, "The current process ID is ", getpid() 7305 1.1 mrg print *, "Your numerical user ID is ", getuid() 7306 1.1 mrg print *, "Your numerical group ID is ", getgid() 7307 1.1 mrg end program info 7308 1.1 mrg @end smallexample 7309 1.1 mrg 7310 1.1 mrg @item @emph{See also}: 7311 1.1.1.2 mrg @ref{GETGID}, @gol 7312 1.1.1.2 mrg @ref{GETUID} 7313 1.1 mrg @end table 7314 1.1 mrg 7315 1.1 mrg 7316 1.1 mrg 7317 1.1 mrg @node GETUID 7318 1.1 mrg @section @code{GETUID} --- User ID function 7319 1.1 mrg @fnindex GETUID 7320 1.1 mrg @cindex system, user ID 7321 1.1 mrg @cindex user id 7322 1.1 mrg 7323 1.1 mrg @table @asis 7324 1.1 mrg @item @emph{Description}: 7325 1.1 mrg Returns the numerical user ID of the current process. 7326 1.1 mrg 7327 1.1 mrg @item @emph{Standard}: 7328 1.1 mrg GNU extension 7329 1.1 mrg 7330 1.1 mrg @item @emph{Class}: 7331 1.1 mrg Function 7332 1.1 mrg 7333 1.1 mrg @item @emph{Syntax}: 7334 1.1 mrg @code{RESULT = GETUID()} 7335 1.1 mrg 7336 1.1 mrg @item @emph{Return value}: 7337 1.1 mrg The return value of @code{GETUID} is an @code{INTEGER} of the default 7338 1.1 mrg kind. 7339 1.1 mrg 7340 1.1 mrg 7341 1.1 mrg @item @emph{Example}: 7342 1.1 mrg See @code{GETPID} for an example. 7343 1.1 mrg 7344 1.1 mrg @item @emph{See also}: 7345 1.1.1.2 mrg @ref{GETPID}, @gol 7346 1.1.1.2 mrg @ref{GETLOG} 7347 1.1 mrg @end table 7348 1.1 mrg 7349 1.1 mrg 7350 1.1 mrg 7351 1.1 mrg @node GMTIME 7352 1.1 mrg @section @code{GMTIME} --- Convert time to GMT info 7353 1.1 mrg @fnindex GMTIME 7354 1.1 mrg @cindex time, conversion to GMT info 7355 1.1 mrg 7356 1.1 mrg @table @asis 7357 1.1 mrg @item @emph{Description}: 7358 1.1 mrg Given a system time value @var{TIME} (as provided by the @ref{TIME} 7359 1.1 mrg intrinsic), fills @var{VALUES} with values extracted from it appropriate 7360 1.1 mrg to the UTC time zone (Universal Coordinated Time, also known in some 7361 1.1 mrg countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}. 7362 1.1 mrg 7363 1.1 mrg This intrinsic routine is provided for backwards compatibility with 7364 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of 7365 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95 7366 1.1 mrg standard. 7367 1.1 mrg 7368 1.1 mrg @item @emph{Standard}: 7369 1.1 mrg GNU extension 7370 1.1 mrg 7371 1.1 mrg @item @emph{Class}: 7372 1.1 mrg Subroutine 7373 1.1 mrg 7374 1.1 mrg @item @emph{Syntax}: 7375 1.1 mrg @code{CALL GMTIME(TIME, VALUES)} 7376 1.1 mrg 7377 1.1 mrg @item @emph{Arguments}: 7378 1.1 mrg @multitable @columnfractions .15 .70 7379 1.1 mrg @item @var{TIME} @tab An @code{INTEGER} scalar expression 7380 1.1 mrg corresponding to a system time, with @code{INTENT(IN)}. 7381 1.1 mrg @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements, 7382 1.1 mrg with @code{INTENT(OUT)}. 7383 1.1 mrg @end multitable 7384 1.1 mrg 7385 1.1 mrg @item @emph{Return value}: 7386 1.1 mrg The elements of @var{VALUES} are assigned as follows: 7387 1.1 mrg @enumerate 7388 1.1 mrg @item Seconds after the minute, range 0--59 or 0--61 to allow for leap 7389 1.1 mrg seconds 7390 1.1 mrg @item Minutes after the hour, range 0--59 7391 1.1 mrg @item Hours past midnight, range 0--23 7392 1.1 mrg @item Day of month, range 1--31 7393 1.1 mrg @item Number of months since January, range 0--11 7394 1.1 mrg @item Years since 1900 7395 1.1 mrg @item Number of days since Sunday, range 0--6 7396 1.1 mrg @item Days since January 1, range 0--365 7397 1.1 mrg @item Daylight savings indicator: positive if daylight savings is in 7398 1.1 mrg effect, zero if not, and negative if the information is not available. 7399 1.1 mrg @end enumerate 7400 1.1 mrg 7401 1.1 mrg @item @emph{See also}: 7402 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol 7403 1.1.1.2 mrg @ref{CTIME}, @gol 7404 1.1.1.2 mrg @ref{LTIME}, @gol 7405 1.1.1.2 mrg @ref{TIME}, @gol 7406 1.1.1.2 mrg @ref{TIME8} 7407 1.1 mrg @end table 7408 1.1 mrg 7409 1.1 mrg 7410 1.1 mrg 7411 1.1 mrg @node HOSTNM 7412 1.1 mrg @section @code{HOSTNM} --- Get system host name 7413 1.1 mrg @fnindex HOSTNM 7414 1.1 mrg @cindex system, host name 7415 1.1 mrg 7416 1.1 mrg @table @asis 7417 1.1 mrg @item @emph{Description}: 7418 1.1 mrg Retrieves the host name of the system on which the program is running. 7419 1.1 mrg 7420 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 7421 1.1 mrg only one form can be used in any given program unit. 7422 1.1 mrg 7423 1.1 mrg @item @emph{Standard}: 7424 1.1 mrg GNU extension 7425 1.1 mrg 7426 1.1 mrg @item @emph{Class}: 7427 1.1 mrg Subroutine, function 7428 1.1 mrg 7429 1.1 mrg @item @emph{Syntax}: 7430 1.1 mrg @multitable @columnfractions .80 7431 1.1 mrg @item @code{CALL HOSTNM(C [, STATUS])} 7432 1.1 mrg @item @code{STATUS = HOSTNM(NAME)} 7433 1.1 mrg @end multitable 7434 1.1 mrg 7435 1.1 mrg @item @emph{Arguments}: 7436 1.1 mrg @multitable @columnfractions .15 .70 7437 1.1 mrg @item @var{C} @tab Shall of type @code{CHARACTER} and of default kind. 7438 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. 7439 1.1 mrg Returns 0 on success, or a system specific error code otherwise. 7440 1.1 mrg @end multitable 7441 1.1 mrg 7442 1.1 mrg @item @emph{Return value}: 7443 1.1 mrg In either syntax, @var{NAME} is set to the current hostname if it can 7444 1.1 mrg be obtained, or to a blank string otherwise. 7445 1.1 mrg 7446 1.1 mrg @end table 7447 1.1 mrg 7448 1.1 mrg 7449 1.1 mrg 7450 1.1 mrg @node HUGE 7451 1.1 mrg @section @code{HUGE} --- Largest number of a kind 7452 1.1 mrg @fnindex HUGE 7453 1.1 mrg @cindex limits, largest number 7454 1.1 mrg @cindex model representation, largest number 7455 1.1 mrg 7456 1.1 mrg @table @asis 7457 1.1 mrg @item @emph{Description}: 7458 1.1 mrg @code{HUGE(X)} returns the largest number that is not an infinity in 7459 1.1 mrg the model of the type of @code{X}. 7460 1.1 mrg 7461 1.1 mrg @item @emph{Standard}: 7462 1.1.1.2 mrg Fortran 90 and later 7463 1.1 mrg 7464 1.1 mrg @item @emph{Class}: 7465 1.1 mrg Inquiry function 7466 1.1 mrg 7467 1.1 mrg @item @emph{Syntax}: 7468 1.1 mrg @code{RESULT = HUGE(X)} 7469 1.1 mrg 7470 1.1 mrg @item @emph{Arguments}: 7471 1.1 mrg @multitable @columnfractions .15 .70 7472 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}. 7473 1.1 mrg @end multitable 7474 1.1 mrg 7475 1.1 mrg @item @emph{Return value}: 7476 1.1 mrg The return value is of the same type and kind as @var{X} 7477 1.1 mrg 7478 1.1 mrg @item @emph{Example}: 7479 1.1 mrg @smallexample 7480 1.1 mrg program test_huge_tiny 7481 1.1 mrg print *, huge(0), huge(0.0), huge(0.0d0) 7482 1.1 mrg print *, tiny(0.0), tiny(0.0d0) 7483 1.1 mrg end program test_huge_tiny 7484 1.1 mrg @end smallexample 7485 1.1 mrg @end table 7486 1.1 mrg 7487 1.1 mrg 7488 1.1 mrg 7489 1.1 mrg @node HYPOT 7490 1.1 mrg @section @code{HYPOT} --- Euclidean distance function 7491 1.1 mrg @fnindex HYPOT 7492 1.1 mrg @cindex Euclidean distance 7493 1.1 mrg 7494 1.1 mrg @table @asis 7495 1.1 mrg @item @emph{Description}: 7496 1.1 mrg @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to 7497 1.1 mrg @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow. 7498 1.1 mrg 7499 1.1 mrg @item @emph{Standard}: 7500 1.1 mrg Fortran 2008 and later 7501 1.1 mrg 7502 1.1 mrg @item @emph{Class}: 7503 1.1 mrg Elemental function 7504 1.1 mrg 7505 1.1 mrg @item @emph{Syntax}: 7506 1.1 mrg @code{RESULT = HYPOT(X, Y)} 7507 1.1 mrg 7508 1.1 mrg @item @emph{Arguments}: 7509 1.1 mrg @multitable @columnfractions .15 .70 7510 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 7511 1.1 mrg @item @var{Y} @tab The type and kind type parameter shall be the same as 7512 1.1 mrg @var{X}. 7513 1.1 mrg @end multitable 7514 1.1 mrg 7515 1.1 mrg @item @emph{Return value}: 7516 1.1 mrg The return value has the same type and kind type parameter as @var{X}. 7517 1.1 mrg 7518 1.1 mrg @item @emph{Example}: 7519 1.1 mrg @smallexample 7520 1.1 mrg program test_hypot 7521 1.1 mrg real(4) :: x = 1.e0_4, y = 0.5e0_4 7522 1.1 mrg x = hypot(x,y) 7523 1.1 mrg end program test_hypot 7524 1.1 mrg @end smallexample 7525 1.1 mrg @end table 7526 1.1 mrg 7527 1.1 mrg 7528 1.1 mrg 7529 1.1 mrg @node IACHAR 7530 1.1 mrg @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 7531 1.1 mrg @fnindex IACHAR 7532 1.1 mrg @cindex @acronym{ASCII} collating sequence 7533 1.1 mrg @cindex collating sequence, @acronym{ASCII} 7534 1.1 mrg @cindex conversion, to integer 7535 1.1 mrg 7536 1.1 mrg @table @asis 7537 1.1 mrg @item @emph{Description}: 7538 1.1 mrg @code{IACHAR(C)} returns the code for the @acronym{ASCII} character 7539 1.1 mrg in the first character position of @code{C}. 7540 1.1 mrg 7541 1.1 mrg @item @emph{Standard}: 7542 1.1 mrg Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later 7543 1.1 mrg 7544 1.1 mrg @item @emph{Class}: 7545 1.1 mrg Elemental function 7546 1.1 mrg 7547 1.1 mrg @item @emph{Syntax}: 7548 1.1 mrg @code{RESULT = IACHAR(C [, KIND])} 7549 1.1 mrg 7550 1.1 mrg @item @emph{Arguments}: 7551 1.1 mrg @multitable @columnfractions .15 .70 7552 1.1 mrg @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)} 7553 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 7554 1.1 mrg expression indicating the kind parameter of the result. 7555 1.1 mrg @end multitable 7556 1.1 mrg 7557 1.1 mrg @item @emph{Return value}: 7558 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 7559 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 7560 1.1 mrg 7561 1.1 mrg @item @emph{Example}: 7562 1.1 mrg @smallexample 7563 1.1 mrg program test_iachar 7564 1.1 mrg integer i 7565 1.1 mrg i = iachar(' ') 7566 1.1 mrg end program test_iachar 7567 1.1 mrg @end smallexample 7568 1.1 mrg 7569 1.1 mrg @item @emph{Note}: 7570 1.1 mrg See @ref{ICHAR} for a discussion of converting between numerical values 7571 1.1 mrg and formatted string representations. 7572 1.1 mrg 7573 1.1 mrg @item @emph{See also}: 7574 1.1.1.2 mrg @ref{ACHAR}, @gol 7575 1.1.1.2 mrg @ref{CHAR}, @gol 7576 1.1.1.2 mrg @ref{ICHAR} 7577 1.1 mrg @end table 7578 1.1 mrg 7579 1.1 mrg 7580 1.1 mrg 7581 1.1 mrg @node IALL 7582 1.1 mrg @section @code{IALL} --- Bitwise AND of array elements 7583 1.1 mrg @fnindex IALL 7584 1.1 mrg @cindex array, AND 7585 1.1 mrg @cindex bits, AND of array elements 7586 1.1 mrg 7587 1.1 mrg @table @asis 7588 1.1 mrg @item @emph{Description}: 7589 1.1 mrg Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM} 7590 1.1 mrg if the corresponding element in @var{MASK} is @code{TRUE}. 7591 1.1 mrg 7592 1.1 mrg @item @emph{Standard}: 7593 1.1 mrg Fortran 2008 and later 7594 1.1 mrg 7595 1.1 mrg @item @emph{Class}: 7596 1.1 mrg Transformational function 7597 1.1 mrg 7598 1.1 mrg @item @emph{Syntax}: 7599 1.1 mrg @multitable @columnfractions .80 7600 1.1 mrg @item @code{RESULT = IALL(ARRAY[, MASK])} 7601 1.1 mrg @item @code{RESULT = IALL(ARRAY, DIM[, MASK])} 7602 1.1 mrg @end multitable 7603 1.1 mrg 7604 1.1 mrg @item @emph{Arguments}: 7605 1.1 mrg @multitable @columnfractions .15 .70 7606 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} 7607 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type 7608 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n 7609 1.1 mrg equals the rank of @var{ARRAY}. 7610 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} 7611 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}. 7612 1.1 mrg @end multitable 7613 1.1 mrg 7614 1.1 mrg @item @emph{Return value}: 7615 1.1 mrg The result is of the same type as @var{ARRAY}. 7616 1.1 mrg 7617 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in 7618 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 7619 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 7620 1.1 mrg dimension @var{DIM} dropped is returned. 7621 1.1 mrg 7622 1.1 mrg @item @emph{Example}: 7623 1.1 mrg @smallexample 7624 1.1 mrg PROGRAM test_iall 7625 1.1 mrg INTEGER(1) :: a(2) 7626 1.1 mrg 7627 1.1 mrg a(1) = b'00100100' 7628 1.1 mrg a(2) = b'01101010' 7629 1.1 mrg 7630 1.1 mrg ! prints 00100000 7631 1.1 mrg PRINT '(b8.8)', IALL(a) 7632 1.1 mrg END PROGRAM 7633 1.1 mrg @end smallexample 7634 1.1 mrg 7635 1.1 mrg @item @emph{See also}: 7636 1.1.1.2 mrg @ref{IANY}, @gol 7637 1.1.1.2 mrg @ref{IPARITY}, @gol 7638 1.1.1.2 mrg @ref{IAND} 7639 1.1 mrg @end table 7640 1.1 mrg 7641 1.1 mrg 7642 1.1 mrg 7643 1.1 mrg @node IAND 7644 1.1 mrg @section @code{IAND} --- Bitwise logical and 7645 1.1 mrg @fnindex IAND 7646 1.1 mrg @fnindex BIAND 7647 1.1 mrg @fnindex IIAND 7648 1.1 mrg @fnindex JIAND 7649 1.1 mrg @fnindex KIAND 7650 1.1 mrg @cindex bitwise logical and 7651 1.1 mrg @cindex logical and, bitwise 7652 1.1 mrg 7653 1.1 mrg @table @asis 7654 1.1 mrg @item @emph{Description}: 7655 1.1 mrg Bitwise logical @code{AND}. 7656 1.1 mrg 7657 1.1 mrg @item @emph{Standard}: 7658 1.1.1.2 mrg Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions 7659 1.1 mrg 7660 1.1 mrg @item @emph{Class}: 7661 1.1 mrg Elemental function 7662 1.1 mrg 7663 1.1 mrg @item @emph{Syntax}: 7664 1.1 mrg @code{RESULT = IAND(I, J)} 7665 1.1 mrg 7666 1.1 mrg @item @emph{Arguments}: 7667 1.1 mrg @multitable @columnfractions .15 .70 7668 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant. 7669 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same 7670 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant. 7671 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants. 7672 1.1 mrg @end multitable 7673 1.1 mrg 7674 1.1 mrg @item @emph{Return value}: 7675 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the 7676 1.1 mrg arguments. 7677 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind 7678 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred. 7679 1.1 mrg 7680 1.1 mrg @item @emph{Example}: 7681 1.1 mrg @smallexample 7682 1.1 mrg PROGRAM test_iand 7683 1.1 mrg INTEGER :: a, b 7684 1.1 mrg DATA a / Z'F' /, b / Z'3' / 7685 1.1 mrg WRITE (*,*) IAND(a, b) 7686 1.1 mrg END PROGRAM 7687 1.1 mrg @end smallexample 7688 1.1 mrg 7689 1.1 mrg @item @emph{Specific names}: 7690 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 7691 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 7692 1.1.1.2 mrg @item @code{IAND(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 7693 1.1 mrg @item @code{BIAND(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 7694 1.1 mrg @item @code{IIAND(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 7695 1.1 mrg @item @code{JIAND(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 7696 1.1 mrg @item @code{KIAND(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 7697 1.1 mrg @end multitable 7698 1.1 mrg 7699 1.1 mrg @item @emph{See also}: 7700 1.1.1.2 mrg @ref{IOR}, @gol 7701 1.1.1.2 mrg @ref{IEOR}, @gol 7702 1.1.1.2 mrg @ref{IBITS}, @gol 7703 1.1.1.2 mrg @ref{IBSET}, @gol 7704 1.1.1.2 mrg @ref{IBCLR}, @gol 7705 1.1.1.2 mrg @ref{NOT} 7706 1.1 mrg @end table 7707 1.1 mrg 7708 1.1 mrg 7709 1.1 mrg 7710 1.1 mrg @node IANY 7711 1.1 mrg @section @code{IANY} --- Bitwise OR of array elements 7712 1.1 mrg @fnindex IANY 7713 1.1 mrg @cindex array, OR 7714 1.1 mrg @cindex bits, OR of array elements 7715 1.1 mrg 7716 1.1 mrg @table @asis 7717 1.1 mrg @item @emph{Description}: 7718 1.1 mrg Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along 7719 1.1 mrg dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}. 7720 1.1 mrg 7721 1.1 mrg @item @emph{Standard}: 7722 1.1 mrg Fortran 2008 and later 7723 1.1 mrg 7724 1.1 mrg @item @emph{Class}: 7725 1.1 mrg Transformational function 7726 1.1 mrg 7727 1.1 mrg @item @emph{Syntax}: 7728 1.1 mrg @multitable @columnfractions .80 7729 1.1 mrg @item @code{RESULT = IANY(ARRAY[, MASK])} 7730 1.1 mrg @item @code{RESULT = IANY(ARRAY, DIM[, MASK])} 7731 1.1 mrg @end multitable 7732 1.1 mrg 7733 1.1 mrg @item @emph{Arguments}: 7734 1.1 mrg @multitable @columnfractions .15 .70 7735 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} 7736 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type 7737 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n 7738 1.1 mrg equals the rank of @var{ARRAY}. 7739 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} 7740 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}. 7741 1.1 mrg @end multitable 7742 1.1 mrg 7743 1.1 mrg @item @emph{Return value}: 7744 1.1 mrg The result is of the same type as @var{ARRAY}. 7745 1.1 mrg 7746 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise OR of all elements in 7747 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 7748 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 7749 1.1 mrg dimension @var{DIM} dropped is returned. 7750 1.1 mrg 7751 1.1 mrg @item @emph{Example}: 7752 1.1 mrg @smallexample 7753 1.1 mrg PROGRAM test_iany 7754 1.1 mrg INTEGER(1) :: a(2) 7755 1.1 mrg 7756 1.1 mrg a(1) = b'00100100' 7757 1.1 mrg a(2) = b'01101010' 7758 1.1 mrg 7759 1.1 mrg ! prints 01101110 7760 1.1 mrg PRINT '(b8.8)', IANY(a) 7761 1.1 mrg END PROGRAM 7762 1.1 mrg @end smallexample 7763 1.1 mrg 7764 1.1 mrg @item @emph{See also}: 7765 1.1.1.2 mrg @ref{IPARITY}, @gol 7766 1.1.1.2 mrg @ref{IALL}, @gol 7767 1.1.1.2 mrg @ref{IOR} 7768 1.1 mrg @end table 7769 1.1 mrg 7770 1.1 mrg 7771 1.1 mrg 7772 1.1 mrg @node IARGC 7773 1.1 mrg @section @code{IARGC} --- Get the number of command line arguments 7774 1.1 mrg @fnindex IARGC 7775 1.1 mrg @cindex command-line arguments 7776 1.1 mrg @cindex command-line arguments, number of 7777 1.1 mrg @cindex arguments, to program 7778 1.1 mrg 7779 1.1 mrg @table @asis 7780 1.1 mrg @item @emph{Description}: 7781 1.1 mrg @code{IARGC} returns the number of arguments passed on the 7782 1.1 mrg command line when the containing program was invoked. 7783 1.1 mrg 7784 1.1 mrg This intrinsic routine is provided for backwards compatibility with 7785 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of 7786 1.1 mrg the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 7787 1.1 mrg standard. 7788 1.1 mrg 7789 1.1 mrg @item @emph{Standard}: 7790 1.1 mrg GNU extension 7791 1.1 mrg 7792 1.1 mrg @item @emph{Class}: 7793 1.1 mrg Function 7794 1.1 mrg 7795 1.1 mrg @item @emph{Syntax}: 7796 1.1 mrg @code{RESULT = IARGC()} 7797 1.1 mrg 7798 1.1 mrg @item @emph{Arguments}: 7799 1.1.1.2 mrg None 7800 1.1 mrg 7801 1.1 mrg @item @emph{Return value}: 7802 1.1 mrg The number of command line arguments, type @code{INTEGER(4)}. 7803 1.1 mrg 7804 1.1 mrg @item @emph{Example}: 7805 1.1 mrg See @ref{GETARG} 7806 1.1 mrg 7807 1.1 mrg @item @emph{See also}: 7808 1.1.1.2 mrg GNU Fortran 77 compatibility subroutine: @gol 7809 1.1.1.2 mrg @ref{GETARG} @gol 7810 1.1.1.2 mrg Fortran 2003 functions and subroutines: @gol 7811 1.1.1.2 mrg @ref{GET_COMMAND}, @gol 7812 1.1.1.2 mrg @ref{GET_COMMAND_ARGUMENT}, @gol 7813 1.1.1.2 mrg @ref{COMMAND_ARGUMENT_COUNT} 7814 1.1 mrg @end table 7815 1.1 mrg 7816 1.1 mrg 7817 1.1 mrg 7818 1.1 mrg @node IBCLR 7819 1.1 mrg @section @code{IBCLR} --- Clear bit 7820 1.1 mrg @fnindex IBCLR 7821 1.1 mrg @fnindex BBCLR 7822 1.1 mrg @fnindex IIBCLR 7823 1.1 mrg @fnindex JIBCLR 7824 1.1 mrg @fnindex KIBCLR 7825 1.1 mrg @cindex bits, unset 7826 1.1 mrg @cindex bits, clear 7827 1.1 mrg 7828 1.1 mrg @table @asis 7829 1.1 mrg @item @emph{Description}: 7830 1.1 mrg @code{IBCLR} returns the value of @var{I} with the bit at position 7831 1.1 mrg @var{POS} set to zero. 7832 1.1 mrg 7833 1.1 mrg @item @emph{Standard}: 7834 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions 7835 1.1 mrg 7836 1.1 mrg @item @emph{Class}: 7837 1.1 mrg Elemental function 7838 1.1 mrg 7839 1.1 mrg @item @emph{Syntax}: 7840 1.1 mrg @code{RESULT = IBCLR(I, POS)} 7841 1.1 mrg 7842 1.1 mrg @item @emph{Arguments}: 7843 1.1 mrg @multitable @columnfractions .15 .70 7844 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 7845 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}. 7846 1.1 mrg @end multitable 7847 1.1 mrg 7848 1.1 mrg @item @emph{Return value}: 7849 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 7850 1.1 mrg @var{I}. 7851 1.1 mrg 7852 1.1 mrg @item @emph{Specific names}: 7853 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 7854 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 7855 1.1.1.2 mrg @item @code{IBCLR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 7856 1.1 mrg @item @code{BBCLR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 7857 1.1 mrg @item @code{IIBCLR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 7858 1.1 mrg @item @code{JIBCLR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 7859 1.1 mrg @item @code{KIBCLR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 7860 1.1 mrg @end multitable 7861 1.1 mrg 7862 1.1 mrg @item @emph{See also}: 7863 1.1.1.2 mrg @ref{IBITS}, @gol 7864 1.1.1.2 mrg @ref{IBSET}, @gol 7865 1.1.1.2 mrg @ref{IAND}, @gol 7866 1.1.1.2 mrg @ref{IOR}, @gol 7867 1.1.1.2 mrg @ref{IEOR}, @gol 7868 1.1.1.2 mrg @ref{MVBITS} 7869 1.1 mrg @end table 7870 1.1 mrg 7871 1.1 mrg 7872 1.1 mrg 7873 1.1 mrg @node IBITS 7874 1.1 mrg @section @code{IBITS} --- Bit extraction 7875 1.1 mrg @fnindex IBITS 7876 1.1 mrg @fnindex BBITS 7877 1.1 mrg @fnindex IIBITS 7878 1.1 mrg @fnindex JIBITS 7879 1.1 mrg @fnindex KIBITS 7880 1.1 mrg @cindex bits, get 7881 1.1 mrg @cindex bits, extract 7882 1.1 mrg 7883 1.1 mrg @table @asis 7884 1.1 mrg @item @emph{Description}: 7885 1.1 mrg @code{IBITS} extracts a field of length @var{LEN} from @var{I}, 7886 1.1 mrg starting from bit position @var{POS} and extending left for @var{LEN} 7887 1.1 mrg bits. The result is right-justified and the remaining bits are 7888 1.1 mrg zeroed. The value of @code{POS+LEN} must be less than or equal to the 7889 1.1 mrg value @code{BIT_SIZE(I)}. 7890 1.1 mrg 7891 1.1 mrg @item @emph{Standard}: 7892 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions 7893 1.1 mrg 7894 1.1 mrg @item @emph{Class}: 7895 1.1 mrg Elemental function 7896 1.1 mrg 7897 1.1 mrg @item @emph{Syntax}: 7898 1.1 mrg @code{RESULT = IBITS(I, POS, LEN)} 7899 1.1 mrg 7900 1.1 mrg @item @emph{Arguments}: 7901 1.1 mrg @multitable @columnfractions .15 .70 7902 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 7903 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}. 7904 1.1 mrg @item @var{LEN} @tab The type shall be @code{INTEGER}. 7905 1.1 mrg @end multitable 7906 1.1 mrg 7907 1.1 mrg @item @emph{Return value}: 7908 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 7909 1.1 mrg @var{I}. 7910 1.1 mrg 7911 1.1 mrg @item @emph{Specific names}: 7912 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 7913 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 7914 1.1.1.2 mrg @item @code{IBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 7915 1.1 mrg @item @code{BBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 7916 1.1 mrg @item @code{IIBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 7917 1.1 mrg @item @code{JIBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 7918 1.1 mrg @item @code{KIBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 7919 1.1 mrg @end multitable 7920 1.1 mrg 7921 1.1 mrg @item @emph{See also}: 7922 1.1.1.2 mrg @ref{BIT_SIZE}, @gol 7923 1.1.1.2 mrg @ref{IBCLR}, @gol 7924 1.1.1.2 mrg @ref{IBSET}, @gol 7925 1.1.1.2 mrg @ref{IAND}, @gol 7926 1.1.1.2 mrg @ref{IOR}, @gol 7927 1.1.1.2 mrg @ref{IEOR} 7928 1.1 mrg @end table 7929 1.1 mrg 7930 1.1 mrg 7931 1.1 mrg 7932 1.1 mrg @node IBSET 7933 1.1 mrg @section @code{IBSET} --- Set bit 7934 1.1 mrg @fnindex IBSET 7935 1.1 mrg @fnindex BBSET 7936 1.1 mrg @fnindex IIBSET 7937 1.1 mrg @fnindex JIBSET 7938 1.1 mrg @fnindex KIBSET 7939 1.1 mrg @cindex bits, set 7940 1.1 mrg 7941 1.1 mrg @table @asis 7942 1.1 mrg @item @emph{Description}: 7943 1.1 mrg @code{IBSET} returns the value of @var{I} with the bit at position 7944 1.1 mrg @var{POS} set to one. 7945 1.1 mrg 7946 1.1 mrg @item @emph{Standard}: 7947 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions 7948 1.1 mrg 7949 1.1 mrg @item @emph{Class}: 7950 1.1 mrg Elemental function 7951 1.1 mrg 7952 1.1 mrg @item @emph{Syntax}: 7953 1.1 mrg @code{RESULT = IBSET(I, POS)} 7954 1.1 mrg 7955 1.1 mrg @item @emph{Arguments}: 7956 1.1 mrg @multitable @columnfractions .15 .70 7957 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 7958 1.1 mrg @item @var{POS} @tab The type shall be @code{INTEGER}. 7959 1.1 mrg @end multitable 7960 1.1 mrg 7961 1.1 mrg @item @emph{Return value}: 7962 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 7963 1.1 mrg @var{I}. 7964 1.1 mrg 7965 1.1 mrg @item @emph{Specific names}: 7966 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 7967 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 7968 1.1.1.2 mrg @item @code{IBSET(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 7969 1.1 mrg @item @code{BBSET(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 7970 1.1 mrg @item @code{IIBSET(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 7971 1.1 mrg @item @code{JIBSET(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 7972 1.1 mrg @item @code{KIBSET(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 7973 1.1 mrg @end multitable 7974 1.1 mrg 7975 1.1 mrg @item @emph{See also}: 7976 1.1.1.2 mrg @ref{IBCLR}, @gol 7977 1.1.1.2 mrg @ref{IBITS}, @gol 7978 1.1.1.2 mrg @ref{IAND}, @gol 7979 1.1.1.2 mrg @ref{IOR}, @gol 7980 1.1.1.2 mrg @ref{IEOR}, @gol 7981 1.1.1.2 mrg @ref{MVBITS} 7982 1.1 mrg @end table 7983 1.1 mrg 7984 1.1 mrg 7985 1.1 mrg 7986 1.1 mrg @node ICHAR 7987 1.1 mrg @section @code{ICHAR} --- Character-to-integer conversion function 7988 1.1 mrg @fnindex ICHAR 7989 1.1 mrg @cindex conversion, to integer 7990 1.1 mrg 7991 1.1 mrg @table @asis 7992 1.1 mrg @item @emph{Description}: 7993 1.1 mrg @code{ICHAR(C)} returns the code for the character in the first character 7994 1.1 mrg position of @code{C} in the system's native character set. 7995 1.1 mrg The correspondence between characters and their codes is not necessarily 7996 1.1 mrg the same across different GNU Fortran implementations. 7997 1.1 mrg 7998 1.1 mrg @item @emph{Standard}: 7999 1.1.1.2 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later 8000 1.1 mrg 8001 1.1 mrg @item @emph{Class}: 8002 1.1 mrg Elemental function 8003 1.1 mrg 8004 1.1 mrg @item @emph{Syntax}: 8005 1.1 mrg @code{RESULT = ICHAR(C [, KIND])} 8006 1.1 mrg 8007 1.1 mrg @item @emph{Arguments}: 8008 1.1 mrg @multitable @columnfractions .15 .70 8009 1.1 mrg @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)} 8010 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 8011 1.1 mrg expression indicating the kind parameter of the result. 8012 1.1 mrg @end multitable 8013 1.1 mrg 8014 1.1 mrg @item @emph{Return value}: 8015 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 8016 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 8017 1.1 mrg 8018 1.1 mrg @item @emph{Example}: 8019 1.1 mrg @smallexample 8020 1.1 mrg program test_ichar 8021 1.1 mrg integer i 8022 1.1 mrg i = ichar(' ') 8023 1.1 mrg end program test_ichar 8024 1.1 mrg @end smallexample 8025 1.1 mrg 8026 1.1 mrg @item @emph{Specific names}: 8027 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 8028 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 8029 1.1 mrg @item @code{ICHAR(C)} @tab @code{CHARACTER C} @tab @code{INTEGER(4)} @tab Fortran 77 and later 8030 1.1 mrg @end multitable 8031 1.1 mrg 8032 1.1 mrg @item @emph{Note}: 8033 1.1 mrg No intrinsic exists to convert between a numeric value and a formatted 8034 1.1 mrg character string representation -- for instance, given the 8035 1.1 mrg @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or 8036 1.1 mrg @code{REAL} value with the value 154, or vice versa. Instead, this 8037 1.1 mrg functionality is provided by internal-file I/O, as in the following 8038 1.1 mrg example: 8039 1.1 mrg @smallexample 8040 1.1 mrg program read_val 8041 1.1 mrg integer value 8042 1.1 mrg character(len=10) string, string2 8043 1.1 mrg string = '154' 8044 1.1 mrg 8045 1.1 mrg ! Convert a string to a numeric value 8046 1.1 mrg read (string,'(I10)') value 8047 1.1 mrg print *, value 8048 1.1 mrg 8049 1.1 mrg ! Convert a value to a formatted string 8050 1.1 mrg write (string2,'(I10)') value 8051 1.1 mrg print *, string2 8052 1.1 mrg end program read_val 8053 1.1 mrg @end smallexample 8054 1.1 mrg 8055 1.1 mrg @item @emph{See also}: 8056 1.1.1.2 mrg @ref{ACHAR}, @gol 8057 1.1.1.2 mrg @ref{CHAR}, @gol 8058 1.1.1.2 mrg @ref{IACHAR} 8059 1.1 mrg @end table 8060 1.1 mrg 8061 1.1 mrg 8062 1.1 mrg 8063 1.1 mrg @node IDATE 8064 1.1 mrg @section @code{IDATE} --- Get current local time subroutine (day/month/year) 8065 1.1 mrg @fnindex IDATE 8066 1.1 mrg @cindex date, current 8067 1.1 mrg @cindex current date 8068 1.1 mrg 8069 1.1 mrg @table @asis 8070 1.1 mrg @item @emph{Description}: 8071 1.1 mrg @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the 8072 1.1 mrg current local time. The day (in the range 1-31), month (in the range 1-12), 8073 1.1 mrg and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively. 8074 1.1 mrg The year has four significant digits. 8075 1.1 mrg 8076 1.1 mrg This intrinsic routine is provided for backwards compatibility with 8077 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of 8078 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95 8079 1.1 mrg standard. 8080 1.1 mrg 8081 1.1 mrg @item @emph{Standard}: 8082 1.1 mrg GNU extension 8083 1.1 mrg 8084 1.1 mrg @item @emph{Class}: 8085 1.1 mrg Subroutine 8086 1.1 mrg 8087 1.1 mrg @item @emph{Syntax}: 8088 1.1 mrg @code{CALL IDATE(VALUES)} 8089 1.1 mrg 8090 1.1 mrg @item @emph{Arguments}: 8091 1.1 mrg @multitable @columnfractions .15 .70 8092 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and 8093 1.1 mrg the kind shall be the default integer kind. 8094 1.1 mrg @end multitable 8095 1.1 mrg 8096 1.1 mrg @item @emph{Return value}: 8097 1.1 mrg Does not return anything. 8098 1.1 mrg 8099 1.1 mrg @item @emph{Example}: 8100 1.1 mrg @smallexample 8101 1.1 mrg program test_idate 8102 1.1 mrg integer, dimension(3) :: tarray 8103 1.1 mrg call idate(tarray) 8104 1.1 mrg print *, tarray(1) 8105 1.1 mrg print *, tarray(2) 8106 1.1 mrg print *, tarray(3) 8107 1.1 mrg end program test_idate 8108 1.1 mrg @end smallexample 8109 1.1 mrg 8110 1.1 mrg @item @emph{See also}: 8111 1.1 mrg @ref{DATE_AND_TIME} 8112 1.1 mrg @end table 8113 1.1 mrg 8114 1.1 mrg 8115 1.1 mrg @node IEOR 8116 1.1 mrg @section @code{IEOR} --- Bitwise logical exclusive or 8117 1.1 mrg @fnindex IEOR 8118 1.1 mrg @fnindex BIEOR 8119 1.1 mrg @fnindex IIEOR 8120 1.1 mrg @fnindex JIEOR 8121 1.1 mrg @fnindex KIEOR 8122 1.1 mrg @cindex bitwise logical exclusive or 8123 1.1 mrg @cindex logical exclusive or, bitwise 8124 1.1 mrg 8125 1.1 mrg @table @asis 8126 1.1 mrg @item @emph{Description}: 8127 1.1 mrg @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and 8128 1.1 mrg @var{J}. 8129 1.1 mrg 8130 1.1 mrg @item @emph{Standard}: 8131 1.1.1.2 mrg Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions 8132 1.1 mrg 8133 1.1 mrg @item @emph{Class}: 8134 1.1 mrg Elemental function 8135 1.1 mrg 8136 1.1 mrg @item @emph{Syntax}: 8137 1.1 mrg @code{RESULT = IEOR(I, J)} 8138 1.1 mrg 8139 1.1 mrg @item @emph{Arguments}: 8140 1.1 mrg @multitable @columnfractions .15 .70 8141 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant. 8142 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same 8143 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant. 8144 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants. 8145 1.1 mrg @end multitable 8146 1.1 mrg 8147 1.1 mrg @item @emph{Return value}: 8148 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the 8149 1.1 mrg arguments. 8150 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind 8151 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred. 8152 1.1 mrg 8153 1.1 mrg @item @emph{Specific names}: 8154 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 8155 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 8156 1.1.1.2 mrg @item @code{IEOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 8157 1.1 mrg @item @code{BIEOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 8158 1.1 mrg @item @code{IIEOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 8159 1.1 mrg @item @code{JIEOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 8160 1.1 mrg @item @code{KIEOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 8161 1.1 mrg @end multitable 8162 1.1 mrg 8163 1.1 mrg @item @emph{See also}: 8164 1.1.1.2 mrg @ref{IOR}, @gol 8165 1.1.1.2 mrg @ref{IAND}, @gol 8166 1.1.1.2 mrg @ref{IBITS}, @gol 8167 1.1.1.2 mrg @ref{IBSET}, @gol 8168 1.1.1.2 mrg @ref{IBCLR}, @gol 8169 1.1.1.2 mrg @ref{NOT} 8170 1.1 mrg @end table 8171 1.1 mrg 8172 1.1 mrg 8173 1.1 mrg 8174 1.1 mrg @node IERRNO 8175 1.1 mrg @section @code{IERRNO} --- Get the last system error number 8176 1.1 mrg @fnindex IERRNO 8177 1.1 mrg @cindex system, error handling 8178 1.1 mrg 8179 1.1 mrg @table @asis 8180 1.1 mrg @item @emph{Description}: 8181 1.1 mrg Returns the last system error number, as given by the C @code{errno} 8182 1.1 mrg variable. 8183 1.1 mrg 8184 1.1 mrg @item @emph{Standard}: 8185 1.1 mrg GNU extension 8186 1.1 mrg 8187 1.1 mrg @item @emph{Class}: 8188 1.1 mrg Function 8189 1.1 mrg 8190 1.1 mrg @item @emph{Syntax}: 8191 1.1 mrg @code{RESULT = IERRNO()} 8192 1.1 mrg 8193 1.1 mrg @item @emph{Arguments}: 8194 1.1.1.2 mrg None 8195 1.1 mrg 8196 1.1 mrg @item @emph{Return value}: 8197 1.1 mrg The return value is of type @code{INTEGER} and of the default integer 8198 1.1 mrg kind. 8199 1.1 mrg 8200 1.1 mrg @item @emph{See also}: 8201 1.1 mrg @ref{PERROR} 8202 1.1 mrg @end table 8203 1.1 mrg 8204 1.1 mrg 8205 1.1 mrg 8206 1.1 mrg @node IMAGE_INDEX 8207 1.1 mrg @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index 8208 1.1 mrg @fnindex IMAGE_INDEX 8209 1.1 mrg @cindex coarray, @code{IMAGE_INDEX} 8210 1.1 mrg @cindex images, cosubscript to image index conversion 8211 1.1 mrg 8212 1.1 mrg @table @asis 8213 1.1 mrg @item @emph{Description}: 8214 1.1 mrg Returns the image index belonging to a cosubscript. 8215 1.1 mrg 8216 1.1 mrg @item @emph{Standard}: 8217 1.1 mrg Fortran 2008 and later 8218 1.1 mrg 8219 1.1 mrg @item @emph{Class}: 8220 1.1 mrg Inquiry function. 8221 1.1 mrg 8222 1.1 mrg @item @emph{Syntax}: 8223 1.1 mrg @code{RESULT = IMAGE_INDEX(COARRAY, SUB)} 8224 1.1 mrg 8225 1.1.1.2 mrg @item @emph{Arguments}: 8226 1.1 mrg @multitable @columnfractions .15 .70 8227 1.1 mrg @item @var{COARRAY} @tab Coarray of any type. 8228 1.1 mrg @item @var{SUB} @tab default integer rank-1 array of a size equal to 8229 1.1 mrg the corank of @var{COARRAY}. 8230 1.1 mrg @end multitable 8231 1.1 mrg 8232 1.1 mrg 8233 1.1 mrg @item @emph{Return value}: 8234 1.1 mrg Scalar default integer with the value of the image index which corresponds 8235 1.1 mrg to the cosubscripts. For invalid cosubscripts the result is zero. 8236 1.1 mrg 8237 1.1 mrg @item @emph{Example}: 8238 1.1 mrg @smallexample 8239 1.1 mrg INTEGER :: array[2,-1:4,8,*] 8240 1.1 mrg ! Writes 28 (or 0 if there are fewer than 28 images) 8241 1.1 mrg WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1]) 8242 1.1 mrg @end smallexample 8243 1.1 mrg 8244 1.1 mrg @item @emph{See also}: 8245 1.1.1.2 mrg @ref{THIS_IMAGE}, @gol 8246 1.1.1.2 mrg @ref{NUM_IMAGES} 8247 1.1 mrg @end table 8248 1.1 mrg 8249 1.1 mrg 8250 1.1 mrg 8251 1.1 mrg @node INDEX intrinsic 8252 1.1 mrg @section @code{INDEX} --- Position of a substring within a string 8253 1.1 mrg @fnindex INDEX 8254 1.1 mrg @cindex substring position 8255 1.1 mrg @cindex string, find substring 8256 1.1 mrg 8257 1.1 mrg @table @asis 8258 1.1 mrg @item @emph{Description}: 8259 1.1 mrg Returns the position of the start of the first occurrence of string 8260 1.1 mrg @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If 8261 1.1 mrg @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If 8262 1.1 mrg the @var{BACK} argument is present and true, the return value is the 8263 1.1 mrg start of the last occurrence rather than the first. 8264 1.1 mrg 8265 1.1 mrg @item @emph{Standard}: 8266 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later 8267 1.1 mrg 8268 1.1 mrg @item @emph{Class}: 8269 1.1 mrg Elemental function 8270 1.1 mrg 8271 1.1 mrg @item @emph{Syntax}: 8272 1.1 mrg @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])} 8273 1.1 mrg 8274 1.1 mrg @item @emph{Arguments}: 8275 1.1 mrg @multitable @columnfractions .15 .70 8276 1.1 mrg @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with 8277 1.1 mrg @code{INTENT(IN)} 8278 1.1 mrg @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with 8279 1.1 mrg @code{INTENT(IN)} 8280 1.1 mrg @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with 8281 1.1 mrg @code{INTENT(IN)} 8282 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 8283 1.1 mrg expression indicating the kind parameter of the result. 8284 1.1 mrg @end multitable 8285 1.1 mrg 8286 1.1 mrg @item @emph{Return value}: 8287 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 8288 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 8289 1.1 mrg 8290 1.1 mrg @item @emph{Specific names}: 8291 1.1.1.3 mrg @multitable @columnfractions .35 .15 .17 .30 8292 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 8293 1.1.1.3 mrg @item @code{INDEX(STRING,SUBSTRING)} @tab @code{CHARACTER} @tab @code{INTEGER(4)} @tab Fortran 77 and later 8294 1.1 mrg @end multitable 8295 1.1 mrg 8296 1.1 mrg @item @emph{See also}: 8297 1.1.1.2 mrg @ref{SCAN}, @gol 8298 1.1.1.2 mrg @ref{VERIFY} 8299 1.1 mrg @end table 8300 1.1 mrg 8301 1.1 mrg 8302 1.1 mrg 8303 1.1 mrg @node INT 8304 1.1 mrg @section @code{INT} --- Convert to integer type 8305 1.1 mrg @fnindex INT 8306 1.1 mrg @fnindex IFIX 8307 1.1 mrg @fnindex IDINT 8308 1.1 mrg @cindex conversion, to integer 8309 1.1 mrg 8310 1.1 mrg @table @asis 8311 1.1 mrg @item @emph{Description}: 8312 1.1 mrg Convert to integer type 8313 1.1 mrg 8314 1.1 mrg @item @emph{Standard}: 8315 1.1.1.2 mrg Fortran 77 and later, with boz-literal-constant Fortran 2008 and later. 8316 1.1 mrg 8317 1.1 mrg @item @emph{Class}: 8318 1.1 mrg Elemental function 8319 1.1 mrg 8320 1.1 mrg @item @emph{Syntax}: 8321 1.1 mrg @code{RESULT = INT(A [, KIND))} 8322 1.1 mrg 8323 1.1 mrg @item @emph{Arguments}: 8324 1.1 mrg @multitable @columnfractions .15 .70 8325 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER}, 8326 1.1.1.3 mrg @code{REAL}, or @code{COMPLEX} or a boz-literal-constant. 8327 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 8328 1.1 mrg expression indicating the kind parameter of the result. 8329 1.1 mrg @end multitable 8330 1.1 mrg 8331 1.1 mrg @item @emph{Return value}: 8332 1.1 mrg These functions return a @code{INTEGER} variable or array under 8333 1.1 mrg the following rules: 8334 1.1 mrg 8335 1.1 mrg @table @asis 8336 1.1 mrg @item (A) 8337 1.1 mrg If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} 8338 1.1 mrg @item (B) 8339 1.1 mrg If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} 8340 1.1 mrg equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer 8341 1.1 mrg whose magnitude is the largest integer that does not exceed the magnitude 8342 1.1 mrg of @var{A} and whose sign is the same as the sign of @var{A}. 8343 1.1 mrg @item (C) 8344 1.1 mrg If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}. 8345 1.1 mrg @end table 8346 1.1 mrg 8347 1.1 mrg @item @emph{Example}: 8348 1.1 mrg @smallexample 8349 1.1 mrg program test_int 8350 1.1 mrg integer :: i = 42 8351 1.1 mrg complex :: z = (-3.7, 1.0) 8352 1.1 mrg print *, int(i) 8353 1.1 mrg print *, int(z), int(z,8) 8354 1.1 mrg end program 8355 1.1 mrg @end smallexample 8356 1.1 mrg 8357 1.1 mrg @item @emph{Specific names}: 8358 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 8359 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 8360 1.1 mrg @item @code{INT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later 8361 1.1 mrg @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later 8362 1.1 mrg @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later 8363 1.1 mrg @end multitable 8364 1.1 mrg 8365 1.1 mrg @end table 8366 1.1 mrg 8367 1.1 mrg 8368 1.1 mrg @node INT2 8369 1.1 mrg @section @code{INT2} --- Convert to 16-bit integer type 8370 1.1 mrg @fnindex INT2 8371 1.1 mrg @cindex conversion, to integer 8372 1.1 mrg 8373 1.1 mrg @table @asis 8374 1.1 mrg @item @emph{Description}: 8375 1.1 mrg Convert to a @code{KIND=2} integer type. This is equivalent to the 8376 1.1 mrg standard @code{INT} intrinsic with an optional argument of 8377 1.1 mrg @code{KIND=2}, and is only included for backwards compatibility. 8378 1.1 mrg 8379 1.1 mrg @item @emph{Standard}: 8380 1.1 mrg GNU extension 8381 1.1 mrg 8382 1.1 mrg @item @emph{Class}: 8383 1.1 mrg Elemental function 8384 1.1 mrg 8385 1.1 mrg @item @emph{Syntax}: 8386 1.1 mrg @code{RESULT = INT2(A)} 8387 1.1 mrg 8388 1.1 mrg @item @emph{Arguments}: 8389 1.1 mrg @multitable @columnfractions .15 .70 8390 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER}, 8391 1.1 mrg @code{REAL}, or @code{COMPLEX}. 8392 1.1 mrg @end multitable 8393 1.1 mrg 8394 1.1 mrg @item @emph{Return value}: 8395 1.1 mrg The return value is a @code{INTEGER(2)} variable. 8396 1.1 mrg 8397 1.1 mrg @item @emph{See also}: 8398 1.1.1.2 mrg @ref{INT}, @gol 8399 1.1.1.3 mrg @ref{INT8} 8400 1.1 mrg @end table 8401 1.1 mrg 8402 1.1 mrg 8403 1.1 mrg 8404 1.1 mrg @node INT8 8405 1.1 mrg @section @code{INT8} --- Convert to 64-bit integer type 8406 1.1 mrg @fnindex INT8 8407 1.1 mrg @cindex conversion, to integer 8408 1.1 mrg 8409 1.1 mrg @table @asis 8410 1.1 mrg @item @emph{Description}: 8411 1.1 mrg Convert to a @code{KIND=8} integer type. This is equivalent to the 8412 1.1 mrg standard @code{INT} intrinsic with an optional argument of 8413 1.1 mrg @code{KIND=8}, and is only included for backwards compatibility. 8414 1.1 mrg 8415 1.1 mrg @item @emph{Standard}: 8416 1.1 mrg GNU extension 8417 1.1 mrg 8418 1.1 mrg @item @emph{Class}: 8419 1.1 mrg Elemental function 8420 1.1 mrg 8421 1.1 mrg @item @emph{Syntax}: 8422 1.1 mrg @code{RESULT = INT8(A)} 8423 1.1 mrg 8424 1.1 mrg @item @emph{Arguments}: 8425 1.1 mrg @multitable @columnfractions .15 .70 8426 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER}, 8427 1.1 mrg @code{REAL}, or @code{COMPLEX}. 8428 1.1 mrg @end multitable 8429 1.1 mrg 8430 1.1 mrg @item @emph{Return value}: 8431 1.1 mrg The return value is a @code{INTEGER(8)} variable. 8432 1.1 mrg 8433 1.1 mrg @item @emph{See also}: 8434 1.1.1.2 mrg @ref{INT}, @gol 8435 1.1.1.3 mrg @ref{INT2} 8436 1.1 mrg @end table 8437 1.1 mrg 8438 1.1 mrg 8439 1.1 mrg 8440 1.1 mrg @node IOR 8441 1.1 mrg @section @code{IOR} --- Bitwise logical or 8442 1.1 mrg @fnindex IOR 8443 1.1 mrg @fnindex BIOR 8444 1.1 mrg @fnindex IIOR 8445 1.1 mrg @fnindex JIOR 8446 1.1 mrg @fnindex KIOR 8447 1.1 mrg @cindex bitwise logical or 8448 1.1 mrg @cindex logical or, bitwise 8449 1.1 mrg 8450 1.1 mrg @table @asis 8451 1.1 mrg @item @emph{Description}: 8452 1.1 mrg @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and 8453 1.1 mrg @var{J}. 8454 1.1 mrg 8455 1.1 mrg @item @emph{Standard}: 8456 1.1.1.2 mrg Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions 8457 1.1 mrg 8458 1.1 mrg @item @emph{Class}: 8459 1.1 mrg Elemental function 8460 1.1 mrg 8461 1.1 mrg @item @emph{Syntax}: 8462 1.1 mrg @code{RESULT = IOR(I, J)} 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{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant. 8467 1.1 mrg @item @var{J} @tab The type shall be @code{INTEGER} with the same 8468 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant. 8469 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants. 8470 1.1 mrg @end multitable 8471 1.1 mrg 8472 1.1 mrg @item @emph{Return value}: 8473 1.1 mrg The return type is @code{INTEGER} with the kind type parameter of the 8474 1.1 mrg arguments. 8475 1.1 mrg A boz-literal-constant is converted to an @code{INTEGER} with the kind 8476 1.1 mrg type parameter of the other argument as-if a call to @ref{INT} occurred. 8477 1.1 mrg 8478 1.1 mrg @item @emph{Specific names}: 8479 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 8480 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 8481 1.1.1.2 mrg @item @code{IOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 8482 1.1 mrg @item @code{BIOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 8483 1.1 mrg @item @code{IIOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 8484 1.1 mrg @item @code{JIOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 8485 1.1 mrg @item @code{KIOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 8486 1.1 mrg @end multitable 8487 1.1 mrg 8488 1.1 mrg @item @emph{See also}: 8489 1.1.1.2 mrg @ref{IEOR}, @gol 8490 1.1.1.2 mrg @ref{IAND}, @gol 8491 1.1.1.2 mrg @ref{IBITS}, @gol 8492 1.1.1.2 mrg @ref{IBSET}, @gol 8493 1.1.1.2 mrg @ref{IBCLR}, @gol 8494 1.1.1.2 mrg @ref{NOT} 8495 1.1 mrg @end table 8496 1.1 mrg 8497 1.1 mrg 8498 1.1 mrg 8499 1.1 mrg @node IPARITY 8500 1.1 mrg @section @code{IPARITY} --- Bitwise XOR of array elements 8501 1.1 mrg @fnindex IPARITY 8502 1.1 mrg @cindex array, parity 8503 1.1 mrg @cindex array, XOR 8504 1.1 mrg @cindex bits, XOR of array elements 8505 1.1 mrg 8506 1.1 mrg @table @asis 8507 1.1 mrg @item @emph{Description}: 8508 1.1 mrg Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along 8509 1.1 mrg dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}. 8510 1.1 mrg 8511 1.1 mrg @item @emph{Standard}: 8512 1.1 mrg Fortran 2008 and later 8513 1.1 mrg 8514 1.1 mrg @item @emph{Class}: 8515 1.1 mrg Transformational function 8516 1.1 mrg 8517 1.1 mrg @item @emph{Syntax}: 8518 1.1 mrg @multitable @columnfractions .80 8519 1.1 mrg @item @code{RESULT = IPARITY(ARRAY[, MASK])} 8520 1.1 mrg @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])} 8521 1.1 mrg @end multitable 8522 1.1 mrg 8523 1.1 mrg @item @emph{Arguments}: 8524 1.1 mrg @multitable @columnfractions .15 .70 8525 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} 8526 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type 8527 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n 8528 1.1 mrg equals the rank of @var{ARRAY}. 8529 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} 8530 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}. 8531 1.1 mrg @end multitable 8532 1.1 mrg 8533 1.1 mrg @item @emph{Return value}: 8534 1.1 mrg The result is of the same type as @var{ARRAY}. 8535 1.1 mrg 8536 1.1 mrg If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in 8537 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 8538 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 8539 1.1 mrg dimension @var{DIM} dropped is returned. 8540 1.1 mrg 8541 1.1 mrg @item @emph{Example}: 8542 1.1 mrg @smallexample 8543 1.1 mrg PROGRAM test_iparity 8544 1.1 mrg INTEGER(1) :: a(2) 8545 1.1 mrg 8546 1.1.1.2 mrg a(1) = int(b'00100100', 1) 8547 1.1.1.2 mrg a(2) = int(b'01101010', 1) 8548 1.1 mrg 8549 1.1 mrg ! prints 01001110 8550 1.1 mrg PRINT '(b8.8)', IPARITY(a) 8551 1.1 mrg END PROGRAM 8552 1.1 mrg @end smallexample 8553 1.1 mrg 8554 1.1 mrg @item @emph{See also}: 8555 1.1.1.2 mrg @ref{IANY}, @gol 8556 1.1.1.2 mrg @ref{IALL}, @gol 8557 1.1.1.2 mrg @ref{IEOR}, @gol 8558 1.1.1.2 mrg @ref{PARITY} 8559 1.1 mrg @end table 8560 1.1 mrg 8561 1.1 mrg 8562 1.1 mrg 8563 1.1 mrg @node IRAND 8564 1.1 mrg @section @code{IRAND} --- Integer pseudo-random number 8565 1.1 mrg @fnindex IRAND 8566 1.1 mrg @cindex random number generation 8567 1.1 mrg 8568 1.1 mrg @table @asis 8569 1.1 mrg @item @emph{Description}: 8570 1.1 mrg @code{IRAND(FLAG)} returns a pseudo-random number from a uniform 8571 1.1 mrg distribution between 0 and a system-dependent limit (which is in most 8572 1.1 mrg cases 2147483647). If @var{FLAG} is 0, the next number 8573 1.1 mrg in the current sequence is returned; if @var{FLAG} is 1, the generator 8574 1.1 mrg is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value, 8575 1.1 mrg it is used as a new seed with @code{SRAND}. 8576 1.1 mrg 8577 1.1 mrg This intrinsic routine is provided for backwards compatibility with 8578 1.1 mrg GNU Fortran 77. It implements a simple modulo generator as provided 8579 1.1 mrg by @command{g77}. For new code, one should consider the use of 8580 1.1 mrg @ref{RANDOM_NUMBER} as it implements a superior algorithm. 8581 1.1 mrg 8582 1.1 mrg @item @emph{Standard}: 8583 1.1 mrg GNU extension 8584 1.1 mrg 8585 1.1 mrg @item @emph{Class}: 8586 1.1 mrg Function 8587 1.1 mrg 8588 1.1 mrg @item @emph{Syntax}: 8589 1.1 mrg @code{RESULT = IRAND(I)} 8590 1.1 mrg 8591 1.1 mrg @item @emph{Arguments}: 8592 1.1 mrg @multitable @columnfractions .15 .70 8593 1.1 mrg @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4. 8594 1.1 mrg @end multitable 8595 1.1 mrg 8596 1.1 mrg @item @emph{Return value}: 8597 1.1 mrg The return value is of @code{INTEGER(kind=4)} type. 8598 1.1 mrg 8599 1.1 mrg @item @emph{Example}: 8600 1.1 mrg @smallexample 8601 1.1 mrg program test_irand 8602 1.1 mrg integer,parameter :: seed = 86456 8603 1.1 mrg 8604 1.1 mrg call srand(seed) 8605 1.1 mrg print *, irand(), irand(), irand(), irand() 8606 1.1 mrg print *, irand(seed), irand(), irand(), irand() 8607 1.1 mrg end program test_irand 8608 1.1 mrg @end smallexample 8609 1.1 mrg 8610 1.1 mrg @end table 8611 1.1 mrg 8612 1.1 mrg 8613 1.1 mrg 8614 1.1 mrg @node IS_CONTIGUOUS 8615 1.1 mrg @section @code{IS_CONTIGUOUS} --- Test whether an array is contiguous 8616 1.1 mrg @fnindex IS_IOSTAT_EOR 8617 1.1 mrg @cindex array, contiguity 8618 1.1 mrg 8619 1.1 mrg @table @asis 8620 1.1 mrg @item @emph{Description}: 8621 1.1 mrg @code{IS_CONTIGUOUS} tests whether an array is contiguous. 8622 1.1 mrg 8623 1.1 mrg @item @emph{Standard}: 8624 1.1 mrg Fortran 2008 and later 8625 1.1 mrg 8626 1.1 mrg @item @emph{Class}: 8627 1.1 mrg Inquiry function 8628 1.1 mrg 8629 1.1 mrg @item @emph{Syntax}: 8630 1.1 mrg @code{RESULT = IS_CONTIGUOUS(ARRAY)} 8631 1.1 mrg 8632 1.1 mrg @item @emph{Arguments}: 8633 1.1 mrg @multitable @columnfractions .15 .70 8634 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type. 8635 1.1 mrg @end multitable 8636 1.1 mrg 8637 1.1 mrg @item @emph{Return value}: 8638 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if 8639 1.1 mrg @var{ARRAY} is contiguous and false otherwise. 8640 1.1 mrg 8641 1.1 mrg @item @emph{Example}: 8642 1.1 mrg @smallexample 8643 1.1 mrg program test 8644 1.1 mrg integer :: a(10) 8645 1.1 mrg a = [1,2,3,4,5,6,7,8,9,10] 8646 1.1 mrg call sub (a) ! every element, is contiguous 8647 1.1 mrg call sub (a(::2)) ! every other element, is noncontiguous 8648 1.1 mrg contains 8649 1.1 mrg subroutine sub (x) 8650 1.1 mrg integer :: x(:) 8651 1.1 mrg if (is_contiguous (x)) then 8652 1.1 mrg write (*,*) 'X is contiguous' 8653 1.1 mrg else 8654 1.1 mrg write (*,*) 'X is not contiguous' 8655 1.1 mrg end if 8656 1.1 mrg end subroutine sub 8657 1.1 mrg end program test 8658 1.1 mrg @end smallexample 8659 1.1 mrg @end table 8660 1.1 mrg 8661 1.1 mrg 8662 1.1 mrg 8663 1.1 mrg @node IS_IOSTAT_END 8664 1.1 mrg @section @code{IS_IOSTAT_END} --- Test for end-of-file value 8665 1.1 mrg @fnindex IS_IOSTAT_END 8666 1.1 mrg @cindex @code{IOSTAT}, end of file 8667 1.1 mrg 8668 1.1 mrg @table @asis 8669 1.1 mrg @item @emph{Description}: 8670 1.1 mrg @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O 8671 1.1 mrg status ``end of file''. The function is equivalent to comparing the variable 8672 1.1 mrg with the @code{IOSTAT_END} parameter of the intrinsic module 8673 1.1 mrg @code{ISO_FORTRAN_ENV}. 8674 1.1 mrg 8675 1.1 mrg @item @emph{Standard}: 8676 1.1 mrg Fortran 2003 and later 8677 1.1 mrg 8678 1.1 mrg @item @emph{Class}: 8679 1.1 mrg Elemental function 8680 1.1 mrg 8681 1.1 mrg @item @emph{Syntax}: 8682 1.1 mrg @code{RESULT = IS_IOSTAT_END(I)} 8683 1.1 mrg 8684 1.1 mrg @item @emph{Arguments}: 8685 1.1 mrg @multitable @columnfractions .15 .70 8686 1.1 mrg @item @var{I} @tab Shall be of the type @code{INTEGER}. 8687 1.1 mrg @end multitable 8688 1.1 mrg 8689 1.1 mrg @item @emph{Return value}: 8690 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if 8691 1.1 mrg @var{I} has the value which indicates an end of file condition for 8692 1.1 mrg @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise. 8693 1.1 mrg 8694 1.1 mrg @item @emph{Example}: 8695 1.1 mrg @smallexample 8696 1.1 mrg PROGRAM iostat 8697 1.1 mrg IMPLICIT NONE 8698 1.1 mrg INTEGER :: stat, i 8699 1.1 mrg OPEN(88, FILE='test.dat') 8700 1.1 mrg READ(88, *, IOSTAT=stat) i 8701 1.1 mrg IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE' 8702 1.1 mrg END PROGRAM 8703 1.1 mrg @end smallexample 8704 1.1 mrg @end table 8705 1.1 mrg 8706 1.1 mrg 8707 1.1 mrg 8708 1.1 mrg @node IS_IOSTAT_EOR 8709 1.1 mrg @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value 8710 1.1 mrg @fnindex IS_IOSTAT_EOR 8711 1.1 mrg @cindex @code{IOSTAT}, end of record 8712 1.1 mrg 8713 1.1 mrg @table @asis 8714 1.1 mrg @item @emph{Description}: 8715 1.1 mrg @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O 8716 1.1 mrg status ``end of record''. The function is equivalent to comparing the 8717 1.1 mrg variable with the @code{IOSTAT_EOR} parameter of the intrinsic module 8718 1.1 mrg @code{ISO_FORTRAN_ENV}. 8719 1.1 mrg 8720 1.1 mrg @item @emph{Standard}: 8721 1.1 mrg Fortran 2003 and later 8722 1.1 mrg 8723 1.1 mrg @item @emph{Class}: 8724 1.1 mrg Elemental function 8725 1.1 mrg 8726 1.1 mrg @item @emph{Syntax}: 8727 1.1 mrg @code{RESULT = IS_IOSTAT_EOR(I)} 8728 1.1 mrg 8729 1.1 mrg @item @emph{Arguments}: 8730 1.1 mrg @multitable @columnfractions .15 .70 8731 1.1 mrg @item @var{I} @tab Shall be of the type @code{INTEGER}. 8732 1.1 mrg @end multitable 8733 1.1 mrg 8734 1.1 mrg @item @emph{Return value}: 8735 1.1 mrg Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if 8736 1.1 mrg @var{I} has the value which indicates an end of file condition for 8737 1.1 mrg @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise. 8738 1.1 mrg 8739 1.1 mrg @item @emph{Example}: 8740 1.1 mrg @smallexample 8741 1.1 mrg PROGRAM iostat 8742 1.1 mrg IMPLICIT NONE 8743 1.1 mrg INTEGER :: stat, i(50) 8744 1.1 mrg OPEN(88, FILE='test.dat', FORM='UNFORMATTED') 8745 1.1 mrg READ(88, IOSTAT=stat) i 8746 1.1 mrg IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD' 8747 1.1 mrg END PROGRAM 8748 1.1 mrg @end smallexample 8749 1.1 mrg @end table 8750 1.1 mrg 8751 1.1 mrg 8752 1.1 mrg @node ISATTY 8753 1.1 mrg @section @code{ISATTY} --- Whether a unit is a terminal device. 8754 1.1 mrg @fnindex ISATTY 8755 1.1 mrg @cindex system, terminal 8756 1.1 mrg 8757 1.1 mrg @table @asis 8758 1.1 mrg @item @emph{Description}: 8759 1.1 mrg Determine whether a unit is connected to a terminal device. 8760 1.1 mrg 8761 1.1 mrg @item @emph{Standard}: 8762 1.1 mrg GNU extension 8763 1.1 mrg 8764 1.1 mrg @item @emph{Class}: 8765 1.1 mrg Function 8766 1.1 mrg 8767 1.1 mrg @item @emph{Syntax}: 8768 1.1 mrg @code{RESULT = ISATTY(UNIT)} 8769 1.1 mrg 8770 1.1 mrg @item @emph{Arguments}: 8771 1.1 mrg @multitable @columnfractions .15 .70 8772 1.1 mrg @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}. 8773 1.1 mrg @end multitable 8774 1.1 mrg 8775 1.1 mrg @item @emph{Return value}: 8776 1.1 mrg Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal 8777 1.1 mrg device, @code{.FALSE.} otherwise. 8778 1.1 mrg 8779 1.1 mrg @item @emph{Example}: 8780 1.1 mrg @smallexample 8781 1.1 mrg PROGRAM test_isatty 8782 1.1 mrg INTEGER(kind=1) :: unit 8783 1.1 mrg DO unit = 1, 10 8784 1.1 mrg write(*,*) isatty(unit=unit) 8785 1.1 mrg END DO 8786 1.1 mrg END PROGRAM 8787 1.1 mrg @end smallexample 8788 1.1 mrg @item @emph{See also}: 8789 1.1 mrg @ref{TTYNAM} 8790 1.1 mrg @end table 8791 1.1 mrg 8792 1.1 mrg 8793 1.1 mrg 8794 1.1 mrg @node ISHFT 8795 1.1 mrg @section @code{ISHFT} --- Shift bits 8796 1.1 mrg @fnindex ISHFT 8797 1.1 mrg @fnindex BSHFT 8798 1.1 mrg @fnindex IISHFT 8799 1.1 mrg @fnindex JISHFT 8800 1.1 mrg @fnindex KISHFT 8801 1.1 mrg @cindex bits, shift 8802 1.1 mrg 8803 1.1 mrg @table @asis 8804 1.1 mrg @item @emph{Description}: 8805 1.1 mrg @code{ISHFT} returns a value corresponding to @var{I} with all of the 8806 1.1 mrg bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than 8807 1.1 mrg zero corresponds to a left shift, a value of zero corresponds to no 8808 1.1 mrg shift, and a value less than zero corresponds to a right shift. If the 8809 1.1 mrg absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the 8810 1.1 mrg value is undefined. Bits shifted out from the left end or right end are 8811 1.1 mrg lost; zeros are shifted in from the opposite end. 8812 1.1 mrg 8813 1.1 mrg @item @emph{Standard}: 8814 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions 8815 1.1 mrg 8816 1.1 mrg @item @emph{Class}: 8817 1.1 mrg Elemental function 8818 1.1 mrg 8819 1.1 mrg @item @emph{Syntax}: 8820 1.1 mrg @code{RESULT = ISHFT(I, SHIFT)} 8821 1.1 mrg 8822 1.1 mrg @item @emph{Arguments}: 8823 1.1 mrg @multitable @columnfractions .15 .70 8824 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 8825 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 8826 1.1 mrg @end multitable 8827 1.1 mrg 8828 1.1 mrg @item @emph{Return value}: 8829 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 8830 1.1 mrg @var{I}. 8831 1.1 mrg 8832 1.1 mrg @item @emph{Specific names}: 8833 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 8834 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 8835 1.1.1.2 mrg @item @code{ISHFT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 8836 1.1 mrg @item @code{BSHFT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 8837 1.1 mrg @item @code{IISHFT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 8838 1.1 mrg @item @code{JISHFT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 8839 1.1 mrg @item @code{KISHFT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 8840 1.1 mrg @end multitable 8841 1.1 mrg 8842 1.1 mrg @item @emph{See also}: 8843 1.1 mrg @ref{ISHFTC} 8844 1.1 mrg @end table 8845 1.1 mrg 8846 1.1 mrg 8847 1.1 mrg 8848 1.1 mrg @node ISHFTC 8849 1.1 mrg @section @code{ISHFTC} --- Shift bits circularly 8850 1.1 mrg @fnindex ISHFTC 8851 1.1 mrg @fnindex BSHFTC 8852 1.1 mrg @fnindex IISHFTC 8853 1.1 mrg @fnindex JISHFTC 8854 1.1 mrg @fnindex KISHFTC 8855 1.1 mrg @cindex bits, shift circular 8856 1.1 mrg 8857 1.1 mrg @table @asis 8858 1.1 mrg @item @emph{Description}: 8859 1.1 mrg @code{ISHFTC} returns a value corresponding to @var{I} with the 8860 1.1 mrg rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that 8861 1.1 mrg is, bits shifted out one end are shifted into the opposite end. A value 8862 1.1 mrg of @var{SHIFT} greater than zero corresponds to a left shift, a value of 8863 1.1 mrg zero corresponds to no shift, and a value less than zero corresponds to 8864 1.1 mrg a right shift. The absolute value of @var{SHIFT} must be less than 8865 1.1 mrg @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be 8866 1.1 mrg equivalent to @code{BIT_SIZE(I)}. 8867 1.1 mrg 8868 1.1 mrg @item @emph{Standard}: 8869 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions 8870 1.1 mrg 8871 1.1 mrg @item @emph{Class}: 8872 1.1 mrg Elemental function 8873 1.1 mrg 8874 1.1 mrg @item @emph{Syntax}: 8875 1.1 mrg @code{RESULT = ISHFTC(I, SHIFT [, SIZE])} 8876 1.1 mrg 8877 1.1 mrg @item @emph{Arguments}: 8878 1.1 mrg @multitable @columnfractions .15 .70 8879 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 8880 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 8881 1.1 mrg @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER}; 8882 1.1 mrg the value must be greater than zero and less than or equal to 8883 1.1 mrg @code{BIT_SIZE(I)}. 8884 1.1 mrg @end multitable 8885 1.1 mrg 8886 1.1 mrg @item @emph{Return value}: 8887 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 8888 1.1 mrg @var{I}. 8889 1.1 mrg 8890 1.1 mrg @item @emph{Specific names}: 8891 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 8892 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 8893 1.1.1.2 mrg @item @code{ISHFTC(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 8894 1.1 mrg @item @code{BSHFTC(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 8895 1.1 mrg @item @code{IISHFTC(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 8896 1.1 mrg @item @code{JISHFTC(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 8897 1.1 mrg @item @code{KISHFTC(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 8898 1.1 mrg @end multitable 8899 1.1 mrg 8900 1.1 mrg @item @emph{See also}: 8901 1.1 mrg @ref{ISHFT} 8902 1.1 mrg @end table 8903 1.1 mrg 8904 1.1 mrg 8905 1.1 mrg 8906 1.1 mrg @node ISNAN 8907 1.1 mrg @section @code{ISNAN} --- Test for a NaN 8908 1.1 mrg @fnindex ISNAN 8909 1.1 mrg @cindex IEEE, ISNAN 8910 1.1 mrg 8911 1.1 mrg @table @asis 8912 1.1 mrg @item @emph{Description}: 8913 1.1 mrg @code{ISNAN} tests whether a floating-point value is an IEEE 8914 1.1 mrg Not-a-Number (NaN). 8915 1.1 mrg @item @emph{Standard}: 8916 1.1 mrg GNU extension 8917 1.1 mrg 8918 1.1 mrg @item @emph{Class}: 8919 1.1 mrg Elemental function 8920 1.1 mrg 8921 1.1 mrg @item @emph{Syntax}: 8922 1.1 mrg @code{ISNAN(X)} 8923 1.1 mrg 8924 1.1 mrg @item @emph{Arguments}: 8925 1.1 mrg @multitable @columnfractions .15 .70 8926 1.1 mrg @item @var{X} @tab Variable of the type @code{REAL}. 8927 1.1 mrg 8928 1.1 mrg @end multitable 8929 1.1 mrg 8930 1.1 mrg @item @emph{Return value}: 8931 1.1 mrg Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE} 8932 1.1 mrg if @var{X} is a NaN and @code{FALSE} otherwise. 8933 1.1 mrg 8934 1.1 mrg @item @emph{Example}: 8935 1.1 mrg @smallexample 8936 1.1 mrg program test_nan 8937 1.1 mrg implicit none 8938 1.1 mrg real :: x 8939 1.1 mrg x = -1.0 8940 1.1 mrg x = sqrt(x) 8941 1.1 mrg if (isnan(x)) stop '"x" is a NaN' 8942 1.1 mrg end program test_nan 8943 1.1 mrg @end smallexample 8944 1.1 mrg @end table 8945 1.1 mrg 8946 1.1 mrg 8947 1.1 mrg 8948 1.1 mrg @node ITIME 8949 1.1 mrg @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 8950 1.1 mrg @fnindex ITIME 8951 1.1 mrg @cindex time, current 8952 1.1 mrg @cindex current time 8953 1.1 mrg 8954 1.1 mrg @table @asis 8955 1.1 mrg @item @emph{Description}: 8956 1.1 mrg @code{ITIME(VALUES)} Fills @var{VALUES} with the numerical values at the 8957 1.1 mrg current local time. The hour (in the range 1-24), minute (in the range 1-60), 8958 1.1 mrg and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, 8959 1.1 mrg respectively. 8960 1.1 mrg 8961 1.1 mrg This intrinsic routine is provided for backwards compatibility with 8962 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of 8963 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95 8964 1.1 mrg standard. 8965 1.1 mrg 8966 1.1 mrg @item @emph{Standard}: 8967 1.1 mrg GNU extension 8968 1.1 mrg 8969 1.1 mrg @item @emph{Class}: 8970 1.1 mrg Subroutine 8971 1.1 mrg 8972 1.1 mrg @item @emph{Syntax}: 8973 1.1 mrg @code{CALL ITIME(VALUES)} 8974 1.1 mrg 8975 1.1 mrg @item @emph{Arguments}: 8976 1.1 mrg @multitable @columnfractions .15 .70 8977 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} 8978 1.1 mrg and the kind shall be the default integer kind. 8979 1.1 mrg @end multitable 8980 1.1 mrg 8981 1.1 mrg @item @emph{Return value}: 8982 1.1 mrg Does not return anything. 8983 1.1 mrg 8984 1.1 mrg 8985 1.1 mrg @item @emph{Example}: 8986 1.1 mrg @smallexample 8987 1.1 mrg program test_itime 8988 1.1 mrg integer, dimension(3) :: tarray 8989 1.1 mrg call itime(tarray) 8990 1.1 mrg print *, tarray(1) 8991 1.1 mrg print *, tarray(2) 8992 1.1 mrg print *, tarray(3) 8993 1.1 mrg end program test_itime 8994 1.1 mrg @end smallexample 8995 1.1 mrg 8996 1.1 mrg @item @emph{See also}: 8997 1.1 mrg @ref{DATE_AND_TIME} 8998 1.1 mrg @end table 8999 1.1 mrg 9000 1.1 mrg 9001 1.1 mrg 9002 1.1 mrg @node KILL 9003 1.1 mrg @section @code{KILL} --- Send a signal to a process 9004 1.1 mrg @fnindex KILL 9005 1.1 mrg 9006 1.1 mrg @table @asis 9007 1.1 mrg @item @emph{Description}: 9008 1.1 mrg Sends the signal specified by @var{SIG} to the process @var{PID}. 9009 1.1 mrg See @code{kill(2)}. 9010 1.1 mrg 9011 1.1 mrg This intrinsic is provided in both subroutine and function forms; 9012 1.1 mrg however, only one form can be used in any given program unit. 9013 1.1.1.2 mrg @item @emph{Standard}: 9014 1.1.1.2 mrg GNU extension 9015 1.1.1.2 mrg 9016 1.1.1.2 mrg @item @emph{Standard}: 9017 1.1.1.2 mrg GNU extension 9018 1.1 mrg 9019 1.1 mrg @item @emph{Class}: 9020 1.1 mrg Subroutine, function 9021 1.1 mrg 9022 1.1 mrg @item @emph{Syntax}: 9023 1.1 mrg @multitable @columnfractions .80 9024 1.1 mrg @item @code{CALL KILL(PID, SIG [, STATUS])} 9025 1.1 mrg @item @code{STATUS = KILL(PID, SIG)} 9026 1.1 mrg @end multitable 9027 1.1 mrg 9028 1.1 mrg @item @emph{Arguments}: 9029 1.1 mrg @multitable @columnfractions .15 .70 9030 1.1 mrg @item @var{PID} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}. 9031 1.1 mrg @item @var{SIG} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}. 9032 1.1 mrg @item @var{STATUS} @tab [Subroutine](Optional) 9033 1.1 mrg Shall be a scalar @code{INTEGER}. 9034 1.1 mrg Returns 0 on success; otherwise a system-specific error code is returned. 9035 1.1 mrg @item @var{STATUS} @tab [Function] The kind type parameter is that of 9036 1.1 mrg @code{pid}. 9037 1.1 mrg Returns 0 on success; otherwise a system-specific error code is returned. 9038 1.1 mrg @end multitable 9039 1.1 mrg 9040 1.1 mrg @item @emph{See also}: 9041 1.1.1.2 mrg @ref{ABORT}, @gol 9042 1.1.1.2 mrg @ref{EXIT} 9043 1.1 mrg @end table 9044 1.1 mrg 9045 1.1 mrg 9046 1.1 mrg @node KIND 9047 1.1 mrg @section @code{KIND} --- Kind of an entity 9048 1.1 mrg @fnindex KIND 9049 1.1 mrg @cindex kind 9050 1.1 mrg 9051 1.1 mrg @table @asis 9052 1.1 mrg @item @emph{Description}: 9053 1.1 mrg @code{KIND(X)} returns the kind value of the entity @var{X}. 9054 1.1 mrg 9055 1.1 mrg @item @emph{Standard}: 9056 1.1 mrg Fortran 95 and later 9057 1.1 mrg 9058 1.1 mrg @item @emph{Class}: 9059 1.1 mrg Inquiry function 9060 1.1 mrg 9061 1.1 mrg @item @emph{Syntax}: 9062 1.1 mrg @code{K = KIND(X)} 9063 1.1 mrg 9064 1.1 mrg @item @emph{Arguments}: 9065 1.1 mrg @multitable @columnfractions .15 .70 9066 1.1 mrg @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER}, 9067 1.1.1.2 mrg @code{REAL}, @code{COMPLEX} or @code{CHARACTER}. It may be scalar or 9068 1.1.1.2 mrg array valued. 9069 1.1 mrg @end multitable 9070 1.1 mrg 9071 1.1 mrg @item @emph{Return value}: 9072 1.1 mrg The return value is a scalar of type @code{INTEGER} and of the default 9073 1.1 mrg integer kind. 9074 1.1 mrg 9075 1.1 mrg @item @emph{Example}: 9076 1.1 mrg @smallexample 9077 1.1 mrg program test_kind 9078 1.1 mrg integer,parameter :: kc = kind(' ') 9079 1.1 mrg integer,parameter :: kl = kind(.true.) 9080 1.1 mrg 9081 1.1 mrg print *, "The default character kind is ", kc 9082 1.1 mrg print *, "The default logical kind is ", kl 9083 1.1 mrg end program test_kind 9084 1.1 mrg @end smallexample 9085 1.1 mrg 9086 1.1 mrg @end table 9087 1.1 mrg 9088 1.1 mrg 9089 1.1 mrg 9090 1.1 mrg @node LBOUND 9091 1.1 mrg @section @code{LBOUND} --- Lower dimension bounds of an array 9092 1.1 mrg @fnindex LBOUND 9093 1.1 mrg @cindex array, lower bound 9094 1.1 mrg 9095 1.1 mrg @table @asis 9096 1.1 mrg @item @emph{Description}: 9097 1.1 mrg Returns the lower bounds of an array, or a single lower bound 9098 1.1 mrg along the @var{DIM} dimension. 9099 1.1 mrg @item @emph{Standard}: 9100 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later 9101 1.1 mrg 9102 1.1 mrg @item @emph{Class}: 9103 1.1 mrg Inquiry function 9104 1.1 mrg 9105 1.1 mrg @item @emph{Syntax}: 9106 1.1 mrg @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])} 9107 1.1 mrg 9108 1.1 mrg @item @emph{Arguments}: 9109 1.1 mrg @multitable @columnfractions .15 .70 9110 1.1 mrg @item @var{ARRAY} @tab Shall be an array, of any type. 9111 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}. 9112 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 9113 1.1 mrg expression indicating the kind parameter of the result. 9114 1.1 mrg @end multitable 9115 1.1 mrg 9116 1.1 mrg @item @emph{Return value}: 9117 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 9118 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 9119 1.1 mrg If @var{DIM} is absent, the result is an array of the lower bounds of 9120 1.1 mrg @var{ARRAY}. If @var{DIM} is present, the result is a scalar 9121 1.1 mrg corresponding to the lower bound of the array along that dimension. If 9122 1.1 mrg @var{ARRAY} is an expression rather than a whole array or array 9123 1.1 mrg structure component, or if it has a zero extent along the relevant 9124 1.1 mrg dimension, the lower bound is taken to be 1. 9125 1.1 mrg 9126 1.1 mrg @item @emph{See also}: 9127 1.1.1.2 mrg @ref{UBOUND}, @gol 9128 1.1.1.2 mrg @ref{LCOBOUND} 9129 1.1 mrg @end table 9130 1.1 mrg 9131 1.1 mrg 9132 1.1 mrg 9133 1.1 mrg @node LCOBOUND 9134 1.1 mrg @section @code{LCOBOUND} --- Lower codimension bounds of an array 9135 1.1 mrg @fnindex LCOBOUND 9136 1.1 mrg @cindex coarray, lower bound 9137 1.1 mrg 9138 1.1 mrg @table @asis 9139 1.1 mrg @item @emph{Description}: 9140 1.1 mrg Returns the lower bounds of a coarray, or a single lower cobound 9141 1.1 mrg along the @var{DIM} codimension. 9142 1.1 mrg @item @emph{Standard}: 9143 1.1 mrg Fortran 2008 and later 9144 1.1 mrg 9145 1.1 mrg @item @emph{Class}: 9146 1.1 mrg Inquiry function 9147 1.1 mrg 9148 1.1 mrg @item @emph{Syntax}: 9149 1.1 mrg @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])} 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{ARRAY} @tab Shall be an coarray, of any type. 9154 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}. 9155 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 9156 1.1 mrg expression indicating the kind parameter of the result. 9157 1.1 mrg @end multitable 9158 1.1 mrg 9159 1.1 mrg @item @emph{Return value}: 9160 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 9161 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 9162 1.1 mrg If @var{DIM} is absent, the result is an array of the lower cobounds of 9163 1.1 mrg @var{COARRAY}. If @var{DIM} is present, the result is a scalar 9164 1.1 mrg corresponding to the lower cobound of the array along that codimension. 9165 1.1 mrg 9166 1.1 mrg @item @emph{See also}: 9167 1.1.1.2 mrg @ref{UCOBOUND}, @gol 9168 1.1.1.2 mrg @ref{LBOUND} 9169 1.1 mrg @end table 9170 1.1 mrg 9171 1.1 mrg 9172 1.1 mrg 9173 1.1 mrg @node LEADZ 9174 1.1 mrg @section @code{LEADZ} --- Number of leading zero bits of an integer 9175 1.1 mrg @fnindex LEADZ 9176 1.1 mrg @cindex zero bits 9177 1.1 mrg 9178 1.1 mrg @table @asis 9179 1.1 mrg @item @emph{Description}: 9180 1.1 mrg @code{LEADZ} returns the number of leading zero bits of an integer. 9181 1.1 mrg 9182 1.1 mrg @item @emph{Standard}: 9183 1.1 mrg Fortran 2008 and later 9184 1.1 mrg 9185 1.1 mrg @item @emph{Class}: 9186 1.1 mrg Elemental function 9187 1.1 mrg 9188 1.1 mrg @item @emph{Syntax}: 9189 1.1 mrg @code{RESULT = LEADZ(I)} 9190 1.1 mrg 9191 1.1 mrg @item @emph{Arguments}: 9192 1.1 mrg @multitable @columnfractions .15 .70 9193 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}. 9194 1.1 mrg @end multitable 9195 1.1 mrg 9196 1.1 mrg @item @emph{Return value}: 9197 1.1 mrg The type of the return value is the default @code{INTEGER}. 9198 1.1 mrg If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}. 9199 1.1 mrg 9200 1.1 mrg @item @emph{Example}: 9201 1.1 mrg @smallexample 9202 1.1 mrg PROGRAM test_leadz 9203 1.1 mrg WRITE (*,*) BIT_SIZE(1) ! prints 32 9204 1.1 mrg WRITE (*,*) LEADZ(1) ! prints 31 9205 1.1 mrg END PROGRAM 9206 1.1 mrg @end smallexample 9207 1.1 mrg 9208 1.1 mrg @item @emph{See also}: 9209 1.1.1.2 mrg @ref{BIT_SIZE}, @gol 9210 1.1.1.2 mrg @ref{TRAILZ}, @gol 9211 1.1.1.2 mrg @ref{POPCNT}, @gol 9212 1.1.1.2 mrg @ref{POPPAR} 9213 1.1 mrg @end table 9214 1.1 mrg 9215 1.1 mrg 9216 1.1 mrg 9217 1.1 mrg @node LEN 9218 1.1 mrg @section @code{LEN} --- Length of a character entity 9219 1.1 mrg @fnindex LEN 9220 1.1 mrg @cindex string, length 9221 1.1 mrg 9222 1.1 mrg @table @asis 9223 1.1 mrg @item @emph{Description}: 9224 1.1 mrg Returns the length of a character string. If @var{STRING} is an array, 9225 1.1 mrg the length of an element of @var{STRING} is returned. Note that 9226 1.1 mrg @var{STRING} need not be defined when this intrinsic is invoked, since 9227 1.1 mrg only the length, not the content, of @var{STRING} is needed. 9228 1.1 mrg 9229 1.1 mrg @item @emph{Standard}: 9230 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later 9231 1.1 mrg 9232 1.1 mrg @item @emph{Class}: 9233 1.1 mrg Inquiry function 9234 1.1 mrg 9235 1.1 mrg @item @emph{Syntax}: 9236 1.1 mrg @code{L = LEN(STRING [, KIND])} 9237 1.1 mrg 9238 1.1 mrg @item @emph{Arguments}: 9239 1.1 mrg @multitable @columnfractions .15 .70 9240 1.1 mrg @item @var{STRING} @tab Shall be a scalar or array of type 9241 1.1 mrg @code{CHARACTER}, with @code{INTENT(IN)} 9242 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 9243 1.1 mrg expression indicating the kind parameter of the result. 9244 1.1 mrg @end multitable 9245 1.1 mrg 9246 1.1 mrg @item @emph{Return value}: 9247 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 9248 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 9249 1.1 mrg 9250 1.1 mrg 9251 1.1 mrg @item @emph{Specific names}: 9252 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 9253 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 9254 1.1 mrg @item @code{LEN(STRING)} @tab @code{CHARACTER} @tab @code{INTEGER} @tab Fortran 77 and later 9255 1.1 mrg @end multitable 9256 1.1 mrg 9257 1.1 mrg 9258 1.1 mrg @item @emph{See also}: 9259 1.1.1.2 mrg @ref{LEN_TRIM}, @gol 9260 1.1.1.2 mrg @ref{ADJUSTL}, @gol 9261 1.1.1.2 mrg @ref{ADJUSTR} 9262 1.1 mrg @end table 9263 1.1 mrg 9264 1.1 mrg 9265 1.1 mrg 9266 1.1 mrg @node LEN_TRIM 9267 1.1 mrg @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters 9268 1.1 mrg @fnindex LEN_TRIM 9269 1.1 mrg @cindex string, length, without trailing whitespace 9270 1.1 mrg 9271 1.1 mrg @table @asis 9272 1.1 mrg @item @emph{Description}: 9273 1.1 mrg Returns the length of a character string, ignoring any trailing blanks. 9274 1.1 mrg 9275 1.1 mrg @item @emph{Standard}: 9276 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later 9277 1.1 mrg 9278 1.1 mrg @item @emph{Class}: 9279 1.1 mrg Elemental function 9280 1.1 mrg 9281 1.1 mrg @item @emph{Syntax}: 9282 1.1 mrg @code{RESULT = LEN_TRIM(STRING [, KIND])} 9283 1.1 mrg 9284 1.1 mrg @item @emph{Arguments}: 9285 1.1 mrg @multitable @columnfractions .15 .70 9286 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}, 9287 1.1 mrg with @code{INTENT(IN)} 9288 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 9289 1.1 mrg expression indicating the kind parameter of the result. 9290 1.1 mrg @end multitable 9291 1.1 mrg 9292 1.1 mrg @item @emph{Return value}: 9293 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 9294 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 9295 1.1 mrg 9296 1.1 mrg @item @emph{See also}: 9297 1.1.1.2 mrg @ref{LEN}, @gol 9298 1.1.1.2 mrg @ref{ADJUSTL}, @gol 9299 1.1.1.2 mrg @ref{ADJUSTR} 9300 1.1 mrg @end table 9301 1.1 mrg 9302 1.1 mrg 9303 1.1 mrg 9304 1.1 mrg @node LGE 9305 1.1 mrg @section @code{LGE} --- Lexical greater than or equal 9306 1.1 mrg @fnindex LGE 9307 1.1 mrg @cindex lexical comparison of strings 9308 1.1 mrg @cindex string, comparison 9309 1.1 mrg 9310 1.1 mrg @table @asis 9311 1.1 mrg @item @emph{Description}: 9312 1.1 mrg Determines whether one string is lexically greater than or equal to 9313 1.1 mrg another string, where the two strings are interpreted as containing 9314 1.1 mrg ASCII character codes. If the String A and String B are not the same 9315 1.1 mrg length, the shorter is compared as if spaces were appended to it to form 9316 1.1 mrg a value that has the same length as the longer. 9317 1.1 mrg 9318 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT}, 9319 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic 9320 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in 9321 1.1 mrg that the latter use the processor's character ordering (which is not 9322 1.1 mrg ASCII on some targets), whereas the former always use the ASCII 9323 1.1 mrg ordering. 9324 1.1 mrg 9325 1.1 mrg @item @emph{Standard}: 9326 1.1 mrg Fortran 77 and later 9327 1.1 mrg 9328 1.1 mrg @item @emph{Class}: 9329 1.1 mrg Elemental function 9330 1.1 mrg 9331 1.1 mrg @item @emph{Syntax}: 9332 1.1 mrg @code{RESULT = LGE(STRING_A, STRING_B)} 9333 1.1 mrg 9334 1.1 mrg @item @emph{Arguments}: 9335 1.1 mrg @multitable @columnfractions .15 .70 9336 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type. 9337 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type. 9338 1.1 mrg @end multitable 9339 1.1 mrg 9340 1.1 mrg @item @emph{Return value}: 9341 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.} 9342 1.1 mrg otherwise, based on the ASCII ordering. 9343 1.1 mrg 9344 1.1 mrg @item @emph{Specific names}: 9345 1.1.1.3 mrg @multitable @columnfractions .34 .16 .17 .30 9346 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 9347 1.1.1.3 mrg @item @code{LGE(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later 9348 1.1 mrg @end multitable 9349 1.1 mrg 9350 1.1 mrg @item @emph{See also}: 9351 1.1.1.2 mrg @ref{LGT}, @gol 9352 1.1.1.2 mrg @ref{LLE}, @gol 9353 1.1.1.2 mrg @ref{LLT} 9354 1.1 mrg @end table 9355 1.1 mrg 9356 1.1 mrg 9357 1.1 mrg 9358 1.1 mrg @node LGT 9359 1.1 mrg @section @code{LGT} --- Lexical greater than 9360 1.1 mrg @fnindex LGT 9361 1.1 mrg @cindex lexical comparison of strings 9362 1.1 mrg @cindex string, comparison 9363 1.1 mrg 9364 1.1 mrg @table @asis 9365 1.1 mrg @item @emph{Description}: 9366 1.1 mrg Determines whether one string is lexically greater than another string, 9367 1.1 mrg where the two strings are interpreted as containing ASCII character 9368 1.1 mrg codes. If the String A and String B are not the same length, the 9369 1.1 mrg shorter is compared as if spaces were appended to it to form a value 9370 1.1 mrg that has the same length as the longer. 9371 1.1 mrg 9372 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT}, 9373 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic 9374 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in 9375 1.1 mrg that the latter use the processor's character ordering (which is not 9376 1.1 mrg ASCII on some targets), whereas the former always use the ASCII 9377 1.1 mrg ordering. 9378 1.1 mrg 9379 1.1 mrg @item @emph{Standard}: 9380 1.1 mrg Fortran 77 and later 9381 1.1 mrg 9382 1.1 mrg @item @emph{Class}: 9383 1.1 mrg Elemental function 9384 1.1 mrg 9385 1.1 mrg @item @emph{Syntax}: 9386 1.1 mrg @code{RESULT = LGT(STRING_A, STRING_B)} 9387 1.1 mrg 9388 1.1 mrg @item @emph{Arguments}: 9389 1.1 mrg @multitable @columnfractions .15 .70 9390 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type. 9391 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type. 9392 1.1 mrg @end multitable 9393 1.1 mrg 9394 1.1 mrg @item @emph{Return value}: 9395 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.} 9396 1.1 mrg otherwise, based on the ASCII ordering. 9397 1.1 mrg 9398 1.1 mrg @item @emph{Specific names}: 9399 1.1.1.3 mrg @multitable @columnfractions .34 .16 .17 .30 9400 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 9401 1.1.1.3 mrg @item @code{LGT(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later 9402 1.1 mrg @end multitable 9403 1.1 mrg 9404 1.1 mrg @item @emph{See also}: 9405 1.1.1.2 mrg @ref{LGE}, @gol 9406 1.1.1.2 mrg @ref{LLE}, @gol 9407 1.1.1.2 mrg @ref{LLT} 9408 1.1 mrg @end table 9409 1.1 mrg 9410 1.1 mrg 9411 1.1 mrg 9412 1.1 mrg @node LINK 9413 1.1 mrg @section @code{LINK} --- Create a hard link 9414 1.1 mrg @fnindex LINK 9415 1.1 mrg @cindex file system, create link 9416 1.1 mrg @cindex file system, hard link 9417 1.1 mrg 9418 1.1 mrg @table @asis 9419 1.1 mrg @item @emph{Description}: 9420 1.1 mrg Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null 9421 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in 9422 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file 9423 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it 9424 1.1 mrg contains 0 on success or a nonzero error code upon return; see 9425 1.1 mrg @code{link(2)}. 9426 1.1 mrg 9427 1.1 mrg This intrinsic is provided in both subroutine and function forms; 9428 1.1 mrg however, only one form can be used in any given program unit. 9429 1.1 mrg 9430 1.1 mrg @item @emph{Standard}: 9431 1.1 mrg GNU extension 9432 1.1 mrg 9433 1.1 mrg @item @emph{Class}: 9434 1.1 mrg Subroutine, function 9435 1.1 mrg 9436 1.1 mrg @item @emph{Syntax}: 9437 1.1 mrg @multitable @columnfractions .80 9438 1.1 mrg @item @code{CALL LINK(PATH1, PATH2 [, STATUS])} 9439 1.1 mrg @item @code{STATUS = LINK(PATH1, PATH2)} 9440 1.1 mrg @end multitable 9441 1.1 mrg 9442 1.1 mrg @item @emph{Arguments}: 9443 1.1 mrg @multitable @columnfractions .15 .70 9444 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type. 9445 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type. 9446 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. 9447 1.1 mrg @end multitable 9448 1.1 mrg 9449 1.1 mrg @item @emph{See also}: 9450 1.1.1.2 mrg @ref{SYMLNK}, @gol 9451 1.1.1.2 mrg @ref{UNLINK} 9452 1.1 mrg @end table 9453 1.1 mrg 9454 1.1 mrg 9455 1.1 mrg 9456 1.1 mrg @node LLE 9457 1.1 mrg @section @code{LLE} --- Lexical less than or equal 9458 1.1 mrg @fnindex LLE 9459 1.1 mrg @cindex lexical comparison of strings 9460 1.1 mrg @cindex string, comparison 9461 1.1 mrg 9462 1.1 mrg @table @asis 9463 1.1 mrg @item @emph{Description}: 9464 1.1 mrg Determines whether one string is lexically less than or equal to another 9465 1.1 mrg string, where the two strings are interpreted as containing ASCII 9466 1.1 mrg character codes. If the String A and String B are not the same length, 9467 1.1 mrg the shorter is compared as if spaces were appended to it to form a value 9468 1.1 mrg that has the same length as the longer. 9469 1.1 mrg 9470 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT}, 9471 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic 9472 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in 9473 1.1 mrg that the latter use the processor's character ordering (which is not 9474 1.1 mrg ASCII on some targets), whereas the former always use the ASCII 9475 1.1 mrg ordering. 9476 1.1 mrg 9477 1.1 mrg @item @emph{Standard}: 9478 1.1 mrg Fortran 77 and later 9479 1.1 mrg 9480 1.1 mrg @item @emph{Class}: 9481 1.1 mrg Elemental function 9482 1.1 mrg 9483 1.1 mrg @item @emph{Syntax}: 9484 1.1 mrg @code{RESULT = LLE(STRING_A, STRING_B)} 9485 1.1 mrg 9486 1.1 mrg @item @emph{Arguments}: 9487 1.1 mrg @multitable @columnfractions .15 .70 9488 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type. 9489 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type. 9490 1.1 mrg @end multitable 9491 1.1 mrg 9492 1.1 mrg @item @emph{Return value}: 9493 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.} 9494 1.1 mrg otherwise, based on the ASCII ordering. 9495 1.1 mrg 9496 1.1 mrg @item @emph{Specific names}: 9497 1.1.1.3 mrg @multitable @columnfractions .34 .16 .17 .30 9498 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 9499 1.1.1.3 mrg @item @code{LLE(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later 9500 1.1 mrg @end multitable 9501 1.1 mrg 9502 1.1 mrg @item @emph{See also}: 9503 1.1.1.2 mrg @ref{LGE}, @gol 9504 1.1.1.2 mrg @ref{LGT}, @gol 9505 1.1.1.2 mrg @ref{LLT} 9506 1.1 mrg @end table 9507 1.1 mrg 9508 1.1 mrg 9509 1.1 mrg 9510 1.1 mrg @node LLT 9511 1.1 mrg @section @code{LLT} --- Lexical less than 9512 1.1 mrg @fnindex LLT 9513 1.1 mrg @cindex lexical comparison of strings 9514 1.1 mrg @cindex string, comparison 9515 1.1 mrg 9516 1.1 mrg @table @asis 9517 1.1 mrg @item @emph{Description}: 9518 1.1 mrg Determines whether one string is lexically less than another string, 9519 1.1 mrg where the two strings are interpreted as containing ASCII character 9520 1.1 mrg codes. If the String A and String B are not the same length, the 9521 1.1 mrg shorter is compared as if spaces were appended to it to form a value 9522 1.1 mrg that has the same length as the longer. 9523 1.1 mrg 9524 1.1 mrg In general, the lexical comparison intrinsics @code{LGE}, @code{LGT}, 9525 1.1 mrg @code{LLE}, and @code{LLT} differ from the corresponding intrinsic 9526 1.1 mrg operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in 9527 1.1 mrg that the latter use the processor's character ordering (which is not 9528 1.1 mrg ASCII on some targets), whereas the former always use the ASCII 9529 1.1 mrg ordering. 9530 1.1 mrg 9531 1.1 mrg @item @emph{Standard}: 9532 1.1 mrg Fortran 77 and later 9533 1.1 mrg 9534 1.1 mrg @item @emph{Class}: 9535 1.1 mrg Elemental function 9536 1.1 mrg 9537 1.1 mrg @item @emph{Syntax}: 9538 1.1 mrg @code{RESULT = LLT(STRING_A, STRING_B)} 9539 1.1 mrg 9540 1.1 mrg @item @emph{Arguments}: 9541 1.1 mrg @multitable @columnfractions .15 .70 9542 1.1 mrg @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type. 9543 1.1 mrg @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type. 9544 1.1 mrg @end multitable 9545 1.1 mrg 9546 1.1 mrg @item @emph{Return value}: 9547 1.1 mrg Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.} 9548 1.1 mrg otherwise, based on the ASCII ordering. 9549 1.1 mrg 9550 1.1 mrg @item @emph{Specific names}: 9551 1.1.1.3 mrg @multitable @columnfractions .34 .16 .17 .30 9552 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 9553 1.1.1.3 mrg @item @code{LLT(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later 9554 1.1 mrg @end multitable 9555 1.1 mrg 9556 1.1 mrg @item @emph{See also}: 9557 1.1.1.2 mrg @ref{LGE}, @gol 9558 1.1.1.2 mrg @ref{LGT}, @gol 9559 1.1.1.2 mrg @ref{LLE} 9560 1.1 mrg @end table 9561 1.1 mrg 9562 1.1 mrg 9563 1.1 mrg 9564 1.1 mrg @node LNBLNK 9565 1.1 mrg @section @code{LNBLNK} --- Index of the last non-blank character in a string 9566 1.1 mrg @fnindex LNBLNK 9567 1.1 mrg @cindex string, find non-blank character 9568 1.1 mrg 9569 1.1 mrg @table @asis 9570 1.1 mrg @item @emph{Description}: 9571 1.1 mrg Returns the length of a character string, ignoring any trailing blanks. 9572 1.1 mrg This is identical to the standard @code{LEN_TRIM} intrinsic, and is only 9573 1.1 mrg included for backwards compatibility. 9574 1.1 mrg 9575 1.1 mrg @item @emph{Standard}: 9576 1.1 mrg GNU extension 9577 1.1 mrg 9578 1.1 mrg @item @emph{Class}: 9579 1.1 mrg Elemental function 9580 1.1 mrg 9581 1.1 mrg @item @emph{Syntax}: 9582 1.1 mrg @code{RESULT = LNBLNK(STRING)} 9583 1.1 mrg 9584 1.1 mrg @item @emph{Arguments}: 9585 1.1 mrg @multitable @columnfractions .15 .70 9586 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}, 9587 1.1 mrg with @code{INTENT(IN)} 9588 1.1 mrg @end multitable 9589 1.1 mrg 9590 1.1 mrg @item @emph{Return value}: 9591 1.1 mrg The return value is of @code{INTEGER(kind=4)} type. 9592 1.1 mrg 9593 1.1 mrg @item @emph{See also}: 9594 1.1.1.2 mrg @ref{INDEX intrinsic}, @gol 9595 1.1.1.2 mrg @ref{LEN_TRIM} 9596 1.1 mrg @end table 9597 1.1 mrg 9598 1.1 mrg 9599 1.1 mrg 9600 1.1 mrg @node LOC 9601 1.1 mrg @section @code{LOC} --- Returns the address of a variable 9602 1.1 mrg @fnindex LOC 9603 1.1 mrg @cindex location of a variable in memory 9604 1.1 mrg 9605 1.1 mrg @table @asis 9606 1.1 mrg @item @emph{Description}: 9607 1.1 mrg @code{LOC(X)} returns the address of @var{X} as an integer. 9608 1.1 mrg 9609 1.1 mrg @item @emph{Standard}: 9610 1.1 mrg GNU extension 9611 1.1 mrg 9612 1.1 mrg @item @emph{Class}: 9613 1.1 mrg Inquiry function 9614 1.1 mrg 9615 1.1 mrg @item @emph{Syntax}: 9616 1.1 mrg @code{RESULT = LOC(X)} 9617 1.1 mrg 9618 1.1 mrg @item @emph{Arguments}: 9619 1.1 mrg @multitable @columnfractions .15 .70 9620 1.1 mrg @item @var{X} @tab Variable of any type. 9621 1.1 mrg @end multitable 9622 1.1 mrg 9623 1.1 mrg @item @emph{Return value}: 9624 1.1 mrg The return value is of type @code{INTEGER}, with a @code{KIND} 9625 1.1 mrg corresponding to the size (in bytes) of a memory address on the target 9626 1.1 mrg machine. 9627 1.1 mrg 9628 1.1 mrg @item @emph{Example}: 9629 1.1 mrg @smallexample 9630 1.1 mrg program test_loc 9631 1.1 mrg integer :: i 9632 1.1 mrg real :: r 9633 1.1 mrg i = loc(r) 9634 1.1 mrg print *, i 9635 1.1 mrg end program test_loc 9636 1.1 mrg @end smallexample 9637 1.1 mrg @end table 9638 1.1 mrg 9639 1.1 mrg 9640 1.1 mrg 9641 1.1 mrg @node LOG 9642 1.1 mrg @section @code{LOG} --- Natural logarithm function 9643 1.1 mrg @fnindex LOG 9644 1.1 mrg @fnindex ALOG 9645 1.1 mrg @fnindex DLOG 9646 1.1 mrg @fnindex CLOG 9647 1.1 mrg @fnindex ZLOG 9648 1.1 mrg @fnindex CDLOG 9649 1.1 mrg @cindex exponential function, inverse 9650 1.1 mrg @cindex logarithm function 9651 1.1 mrg @cindex natural logarithm function 9652 1.1 mrg 9653 1.1 mrg @table @asis 9654 1.1 mrg @item @emph{Description}: 9655 1.1 mrg @code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the 9656 1.1 mrg logarithm to the base @math{e}. 9657 1.1 mrg 9658 1.1 mrg @item @emph{Standard}: 9659 1.1.1.2 mrg Fortran 77 and later, has GNU extensions 9660 1.1 mrg 9661 1.1 mrg @item @emph{Class}: 9662 1.1 mrg Elemental function 9663 1.1 mrg 9664 1.1 mrg @item @emph{Syntax}: 9665 1.1 mrg @code{RESULT = LOG(X)} 9666 1.1 mrg 9667 1.1 mrg @item @emph{Arguments}: 9668 1.1 mrg @multitable @columnfractions .15 .70 9669 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or 9670 1.1 mrg @code{COMPLEX}. 9671 1.1 mrg @end multitable 9672 1.1 mrg 9673 1.1 mrg @item @emph{Return value}: 9674 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}. 9675 1.1 mrg The kind type parameter is the same as @var{X}. 9676 1.1 mrg If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range 9677 1.1 mrg @math{-\pi < \omega \leq \pi}. 9678 1.1 mrg 9679 1.1 mrg @item @emph{Example}: 9680 1.1 mrg @smallexample 9681 1.1 mrg program test_log 9682 1.1 mrg real(8) :: x = 2.7182818284590451_8 9683 1.1 mrg complex :: z = (1.0, 2.0) 9684 1.1 mrg x = log(x) ! will yield (approximately) 1 9685 1.1 mrg z = log(z) 9686 1.1 mrg end program test_log 9687 1.1 mrg @end smallexample 9688 1.1 mrg 9689 1.1 mrg @item @emph{Specific names}: 9690 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 9691 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 9692 1.1.1.2 mrg @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 or later 9693 1.1.1.2 mrg @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 or later 9694 1.1.1.2 mrg @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 or later 9695 1.1.1.2 mrg @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 9696 1.1.1.2 mrg @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 9697 1.1 mrg @end multitable 9698 1.1 mrg @end table 9699 1.1 mrg 9700 1.1 mrg 9701 1.1 mrg 9702 1.1 mrg @node LOG10 9703 1.1 mrg @section @code{LOG10} --- Base 10 logarithm function 9704 1.1 mrg @fnindex LOG10 9705 1.1 mrg @fnindex ALOG10 9706 1.1 mrg @fnindex DLOG10 9707 1.1 mrg @cindex exponential function, inverse 9708 1.1 mrg @cindex logarithm function with base 10 9709 1.1 mrg @cindex base 10 logarithm function 9710 1.1 mrg 9711 1.1 mrg @table @asis 9712 1.1 mrg @item @emph{Description}: 9713 1.1 mrg @code{LOG10(X)} computes the base 10 logarithm of @var{X}. 9714 1.1 mrg 9715 1.1 mrg @item @emph{Standard}: 9716 1.1 mrg Fortran 77 and later 9717 1.1 mrg 9718 1.1 mrg @item @emph{Class}: 9719 1.1 mrg Elemental function 9720 1.1 mrg 9721 1.1 mrg @item @emph{Syntax}: 9722 1.1 mrg @code{RESULT = LOG10(X)} 9723 1.1 mrg 9724 1.1 mrg @item @emph{Arguments}: 9725 1.1 mrg @multitable @columnfractions .15 .70 9726 1.1 mrg @item @var{X} @tab The type shall be @code{REAL}. 9727 1.1 mrg @end multitable 9728 1.1 mrg 9729 1.1 mrg @item @emph{Return value}: 9730 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}. 9731 1.1 mrg The kind type parameter is the same as @var{X}. 9732 1.1 mrg 9733 1.1 mrg @item @emph{Example}: 9734 1.1 mrg @smallexample 9735 1.1 mrg program test_log10 9736 1.1 mrg real(8) :: x = 10.0_8 9737 1.1 mrg x = log10(x) 9738 1.1 mrg end program test_log10 9739 1.1 mrg @end smallexample 9740 1.1 mrg 9741 1.1 mrg @item @emph{Specific names}: 9742 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 9743 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 9744 1.1.1.2 mrg @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 9745 1.1.1.2 mrg @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 9746 1.1 mrg @end multitable 9747 1.1 mrg @end table 9748 1.1 mrg 9749 1.1 mrg 9750 1.1 mrg 9751 1.1 mrg @node LOG_GAMMA 9752 1.1 mrg @section @code{LOG_GAMMA} --- Logarithm of the Gamma function 9753 1.1 mrg @fnindex LOG_GAMMA 9754 1.1 mrg @fnindex LGAMMA 9755 1.1 mrg @fnindex ALGAMA 9756 1.1 mrg @fnindex DLGAMA 9757 1.1 mrg @cindex Gamma function, logarithm of 9758 1.1 mrg 9759 1.1 mrg @table @asis 9760 1.1 mrg @item @emph{Description}: 9761 1.1 mrg @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value 9762 1.1 mrg of the Gamma (@math{\Gamma}) function. 9763 1.1 mrg 9764 1.1 mrg @item @emph{Standard}: 9765 1.1 mrg Fortran 2008 and later 9766 1.1 mrg 9767 1.1 mrg @item @emph{Class}: 9768 1.1 mrg Elemental function 9769 1.1 mrg 9770 1.1 mrg @item @emph{Syntax}: 9771 1.1 mrg @code{X = LOG_GAMMA(X)} 9772 1.1 mrg 9773 1.1 mrg @item @emph{Arguments}: 9774 1.1 mrg @multitable @columnfractions .15 .70 9775 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL} and neither zero 9776 1.1 mrg nor a negative integer. 9777 1.1 mrg @end multitable 9778 1.1 mrg 9779 1.1 mrg @item @emph{Return value}: 9780 1.1 mrg The return value is of type @code{REAL} of the same kind as @var{X}. 9781 1.1 mrg 9782 1.1 mrg @item @emph{Example}: 9783 1.1 mrg @smallexample 9784 1.1 mrg program test_log_gamma 9785 1.1 mrg real :: x = 1.0 9786 1.1 mrg x = lgamma(x) ! returns 0.0 9787 1.1 mrg end program test_log_gamma 9788 1.1 mrg @end smallexample 9789 1.1 mrg 9790 1.1 mrg @item @emph{Specific names}: 9791 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 9792 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 9793 1.1.1.2 mrg @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 9794 1.1.1.2 mrg @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 9795 1.1.1.2 mrg @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 9796 1.1 mrg @end multitable 9797 1.1 mrg 9798 1.1 mrg @item @emph{See also}: 9799 1.1.1.2 mrg Gamma function: @gol 9800 1.1.1.2 mrg @ref{GAMMA} 9801 1.1 mrg @end table 9802 1.1 mrg 9803 1.1 mrg 9804 1.1 mrg 9805 1.1 mrg @node LOGICAL 9806 1.1 mrg @section @code{LOGICAL} --- Convert to logical type 9807 1.1 mrg @fnindex LOGICAL 9808 1.1 mrg @cindex conversion, to logical 9809 1.1 mrg 9810 1.1 mrg @table @asis 9811 1.1 mrg @item @emph{Description}: 9812 1.1 mrg Converts one kind of @code{LOGICAL} variable to another. 9813 1.1 mrg 9814 1.1 mrg @item @emph{Standard}: 9815 1.1.1.2 mrg Fortran 90 and later 9816 1.1 mrg 9817 1.1 mrg @item @emph{Class}: 9818 1.1 mrg Elemental function 9819 1.1 mrg 9820 1.1 mrg @item @emph{Syntax}: 9821 1.1 mrg @code{RESULT = LOGICAL(L [, KIND])} 9822 1.1 mrg 9823 1.1 mrg @item @emph{Arguments}: 9824 1.1 mrg @multitable @columnfractions .15 .70 9825 1.1 mrg @item @var{L} @tab The type shall be @code{LOGICAL}. 9826 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 9827 1.1 mrg expression indicating the kind parameter of the result. 9828 1.1 mrg @end multitable 9829 1.1 mrg 9830 1.1 mrg @item @emph{Return value}: 9831 1.1 mrg The return value is a @code{LOGICAL} value equal to @var{L}, with a 9832 1.1 mrg kind corresponding to @var{KIND}, or of the default logical kind if 9833 1.1 mrg @var{KIND} is not given. 9834 1.1 mrg 9835 1.1 mrg @item @emph{See also}: 9836 1.1.1.2 mrg @ref{INT}, @gol 9837 1.1.1.2 mrg @ref{REAL}, @gol 9838 1.1.1.2 mrg @ref{CMPLX} 9839 1.1 mrg @end table 9840 1.1 mrg 9841 1.1 mrg 9842 1.1 mrg 9843 1.1 mrg @node LSHIFT 9844 1.1 mrg @section @code{LSHIFT} --- Left shift bits 9845 1.1 mrg @fnindex LSHIFT 9846 1.1 mrg @cindex bits, shift left 9847 1.1 mrg 9848 1.1 mrg @table @asis 9849 1.1 mrg @item @emph{Description}: 9850 1.1 mrg @code{LSHIFT} returns a value corresponding to @var{I} with all of the 9851 1.1 mrg bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be 9852 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise 9853 1.1 mrg the result value is undefined. Bits shifted out from the left end are 9854 1.1 mrg lost; zeros are shifted in from the opposite end. 9855 1.1 mrg 9856 1.1 mrg This function has been superseded by the @code{ISHFT} intrinsic, which 9857 1.1 mrg is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic, 9858 1.1 mrg which is standard in Fortran 2008 and later. 9859 1.1 mrg 9860 1.1 mrg @item @emph{Standard}: 9861 1.1 mrg GNU extension 9862 1.1 mrg 9863 1.1 mrg @item @emph{Class}: 9864 1.1 mrg Elemental function 9865 1.1 mrg 9866 1.1 mrg @item @emph{Syntax}: 9867 1.1 mrg @code{RESULT = LSHIFT(I, SHIFT)} 9868 1.1 mrg 9869 1.1 mrg @item @emph{Arguments}: 9870 1.1 mrg @multitable @columnfractions .15 .70 9871 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 9872 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 9873 1.1 mrg @end multitable 9874 1.1 mrg 9875 1.1 mrg @item @emph{Return value}: 9876 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 9877 1.1 mrg @var{I}. 9878 1.1 mrg 9879 1.1 mrg @item @emph{See also}: 9880 1.1.1.2 mrg @ref{ISHFT}, @gol 9881 1.1.1.2 mrg @ref{ISHFTC}, @gol 9882 1.1.1.2 mrg @ref{RSHIFT}, @gol 9883 1.1.1.2 mrg @ref{SHIFTA}, @gol 9884 1.1.1.2 mrg @ref{SHIFTL}, @gol 9885 1.1 mrg @ref{SHIFTR} 9886 1.1 mrg @end table 9887 1.1 mrg 9888 1.1 mrg 9889 1.1 mrg 9890 1.1 mrg @node LSTAT 9891 1.1 mrg @section @code{LSTAT} --- Get file status 9892 1.1 mrg @fnindex LSTAT 9893 1.1 mrg @cindex file system, file status 9894 1.1 mrg 9895 1.1 mrg @table @asis 9896 1.1 mrg @item @emph{Description}: 9897 1.1 mrg @code{LSTAT} is identical to @ref{STAT}, except that if path is a 9898 1.1 mrg symbolic link, then the link itself is statted, not the file that it 9899 1.1 mrg refers to. 9900 1.1 mrg 9901 1.1 mrg The elements in @code{VALUES} are the same as described by @ref{STAT}. 9902 1.1 mrg 9903 1.1 mrg This intrinsic is provided in both subroutine and function forms; 9904 1.1 mrg however, only one form can be used in any given program unit. 9905 1.1 mrg 9906 1.1 mrg @item @emph{Standard}: 9907 1.1 mrg GNU extension 9908 1.1 mrg 9909 1.1 mrg @item @emph{Class}: 9910 1.1 mrg Subroutine, function 9911 1.1 mrg 9912 1.1 mrg @item @emph{Syntax}: 9913 1.1 mrg @multitable @columnfractions .80 9914 1.1 mrg @item @code{CALL LSTAT(NAME, VALUES [, STATUS])} 9915 1.1 mrg @item @code{STATUS = LSTAT(NAME, VALUES)} 9916 1.1 mrg @end multitable 9917 1.1 mrg 9918 1.1 mrg @item @emph{Arguments}: 9919 1.1 mrg @multitable @columnfractions .15 .70 9920 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER} of the default 9921 1.1 mrg kind, a valid path within the file system. 9922 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}. 9923 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. 9924 1.1 mrg Returns 0 on success and a system specific error code otherwise. 9925 1.1 mrg @end multitable 9926 1.1 mrg 9927 1.1 mrg @item @emph{Example}: 9928 1.1 mrg See @ref{STAT} for an example. 9929 1.1 mrg 9930 1.1 mrg @item @emph{See also}: 9931 1.1.1.2 mrg To stat an open file: @gol 9932 1.1.1.2 mrg @ref{FSTAT} @gol 9933 1.1.1.2 mrg To stat a file: @gol 9934 1.1.1.2 mrg @ref{STAT} 9935 1.1 mrg @end table 9936 1.1 mrg 9937 1.1 mrg 9938 1.1 mrg 9939 1.1 mrg @node LTIME 9940 1.1 mrg @section @code{LTIME} --- Convert time to local time info 9941 1.1 mrg @fnindex LTIME 9942 1.1 mrg @cindex time, conversion to local time info 9943 1.1 mrg 9944 1.1 mrg @table @asis 9945 1.1 mrg @item @emph{Description}: 9946 1.1 mrg Given a system time value @var{TIME} (as provided by the @ref{TIME} 9947 1.1 mrg intrinsic), fills @var{VALUES} with values extracted from it appropriate 9948 1.1 mrg to the local time zone using @code{localtime(3)}. 9949 1.1 mrg 9950 1.1 mrg This intrinsic routine is provided for backwards compatibility with 9951 1.1 mrg GNU Fortran 77. In new code, programmers should consider the use of 9952 1.1 mrg the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95 9953 1.1 mrg standard. 9954 1.1 mrg 9955 1.1 mrg @item @emph{Standard}: 9956 1.1 mrg GNU extension 9957 1.1 mrg 9958 1.1 mrg @item @emph{Class}: 9959 1.1 mrg Subroutine 9960 1.1 mrg 9961 1.1 mrg @item @emph{Syntax}: 9962 1.1 mrg @code{CALL LTIME(TIME, VALUES)} 9963 1.1 mrg 9964 1.1 mrg @item @emph{Arguments}: 9965 1.1 mrg @multitable @columnfractions .15 .70 9966 1.1 mrg @item @var{TIME} @tab An @code{INTEGER} scalar expression 9967 1.1 mrg corresponding to a system time, with @code{INTENT(IN)}. 9968 1.1 mrg @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements, 9969 1.1 mrg with @code{INTENT(OUT)}. 9970 1.1 mrg @end multitable 9971 1.1 mrg 9972 1.1 mrg @item @emph{Return value}: 9973 1.1 mrg The elements of @var{VALUES} are assigned as follows: 9974 1.1 mrg @enumerate 9975 1.1 mrg @item Seconds after the minute, range 0--59 or 0--61 to allow for leap 9976 1.1 mrg seconds 9977 1.1 mrg @item Minutes after the hour, range 0--59 9978 1.1 mrg @item Hours past midnight, range 0--23 9979 1.1 mrg @item Day of month, range 1--31 9980 1.1 mrg @item Number of months since January, range 0--11 9981 1.1 mrg @item Years since 1900 9982 1.1 mrg @item Number of days since Sunday, range 0--6 9983 1.1 mrg @item Days since January 1, range 0--365 9984 1.1 mrg @item Daylight savings indicator: positive if daylight savings is in 9985 1.1 mrg effect, zero if not, and negative if the information is not available. 9986 1.1 mrg @end enumerate 9987 1.1 mrg 9988 1.1 mrg @item @emph{See also}: 9989 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol 9990 1.1.1.2 mrg @ref{CTIME}, @gol 9991 1.1.1.2 mrg @ref{GMTIME}, @gol 9992 1.1.1.2 mrg @ref{TIME}, @gol 9993 1.1.1.2 mrg @ref{TIME8} 9994 1.1 mrg @end table 9995 1.1 mrg 9996 1.1 mrg 9997 1.1 mrg 9998 1.1 mrg @node MALLOC 9999 1.1 mrg @section @code{MALLOC} --- Allocate dynamic memory 10000 1.1 mrg @fnindex MALLOC 10001 1.1 mrg @cindex pointer, cray 10002 1.1 mrg 10003 1.1 mrg @table @asis 10004 1.1 mrg @item @emph{Description}: 10005 1.1 mrg @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and 10006 1.1 mrg returns the address of the allocated memory. The @code{MALLOC} intrinsic 10007 1.1 mrg is an extension intended to be used with Cray pointers, and is provided 10008 1.1 mrg in GNU Fortran to allow the user to compile legacy code. For new code 10009 1.1 mrg using Fortran 95 pointers, the memory allocation intrinsic is 10010 1.1 mrg @code{ALLOCATE}. 10011 1.1 mrg 10012 1.1 mrg @item @emph{Standard}: 10013 1.1 mrg GNU extension 10014 1.1 mrg 10015 1.1 mrg @item @emph{Class}: 10016 1.1 mrg Function 10017 1.1 mrg 10018 1.1 mrg @item @emph{Syntax}: 10019 1.1 mrg @code{PTR = MALLOC(SIZE)} 10020 1.1 mrg 10021 1.1 mrg @item @emph{Arguments}: 10022 1.1 mrg @multitable @columnfractions .15 .70 10023 1.1 mrg @item @var{SIZE} @tab The type shall be @code{INTEGER}. 10024 1.1 mrg @end multitable 10025 1.1 mrg 10026 1.1 mrg @item @emph{Return value}: 10027 1.1 mrg The return value is of type @code{INTEGER(K)}, with @var{K} such that 10028 1.1 mrg variables of type @code{INTEGER(K)} have the same size as 10029 1.1 mrg C pointers (@code{sizeof(void *)}). 10030 1.1 mrg 10031 1.1 mrg @item @emph{Example}: 10032 1.1 mrg The following example demonstrates the use of @code{MALLOC} and 10033 1.1 mrg @code{FREE} with Cray pointers. 10034 1.1 mrg 10035 1.1 mrg @smallexample 10036 1.1 mrg program test_malloc 10037 1.1 mrg implicit none 10038 1.1 mrg integer i 10039 1.1 mrg real*8 x(*), z 10040 1.1 mrg pointer(ptr_x,x) 10041 1.1 mrg 10042 1.1 mrg ptr_x = malloc(20*8) 10043 1.1 mrg do i = 1, 20 10044 1.1 mrg x(i) = sqrt(1.0d0 / i) 10045 1.1 mrg end do 10046 1.1 mrg z = 0 10047 1.1 mrg do i = 1, 20 10048 1.1 mrg z = z + x(i) 10049 1.1 mrg print *, z 10050 1.1 mrg end do 10051 1.1 mrg call free(ptr_x) 10052 1.1 mrg end program test_malloc 10053 1.1 mrg @end smallexample 10054 1.1 mrg 10055 1.1 mrg @item @emph{See also}: 10056 1.1 mrg @ref{FREE} 10057 1.1 mrg @end table 10058 1.1 mrg 10059 1.1 mrg 10060 1.1 mrg 10061 1.1 mrg @node MASKL 10062 1.1 mrg @section @code{MASKL} --- Left justified mask 10063 1.1 mrg @fnindex MASKL 10064 1.1 mrg @cindex mask, left justified 10065 1.1 mrg 10066 1.1 mrg @table @asis 10067 1.1 mrg @item @emph{Description}: 10068 1.1 mrg @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the 10069 1.1 mrg remaining bits set to 0. 10070 1.1 mrg 10071 1.1 mrg @item @emph{Standard}: 10072 1.1 mrg Fortran 2008 and later 10073 1.1 mrg 10074 1.1 mrg @item @emph{Class}: 10075 1.1 mrg Elemental function 10076 1.1 mrg 10077 1.1 mrg @item @emph{Syntax}: 10078 1.1 mrg @code{RESULT = MASKL(I[, KIND])} 10079 1.1 mrg 10080 1.1 mrg @item @emph{Arguments}: 10081 1.1 mrg @multitable @columnfractions .15 .70 10082 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}. 10083 1.1 mrg @item @var{KIND} @tab Shall be a scalar constant expression of type 10084 1.1 mrg @code{INTEGER}. 10085 1.1 mrg @end multitable 10086 1.1 mrg 10087 1.1 mrg @item @emph{Return value}: 10088 1.1 mrg The return value is of type @code{INTEGER}. If @var{KIND} is present, it 10089 1.1 mrg specifies the kind value of the return type; otherwise, it is of the 10090 1.1 mrg default integer kind. 10091 1.1 mrg 10092 1.1 mrg @item @emph{See also}: 10093 1.1 mrg @ref{MASKR} 10094 1.1 mrg @end table 10095 1.1 mrg 10096 1.1 mrg 10097 1.1 mrg 10098 1.1 mrg @node MASKR 10099 1.1 mrg @section @code{MASKR} --- Right justified mask 10100 1.1 mrg @fnindex MASKR 10101 1.1 mrg @cindex mask, right justified 10102 1.1 mrg 10103 1.1 mrg @table @asis 10104 1.1 mrg @item @emph{Description}: 10105 1.1 mrg @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the 10106 1.1 mrg remaining bits set to 0. 10107 1.1 mrg 10108 1.1 mrg @item @emph{Standard}: 10109 1.1 mrg Fortran 2008 and later 10110 1.1 mrg 10111 1.1 mrg @item @emph{Class}: 10112 1.1 mrg Elemental function 10113 1.1 mrg 10114 1.1 mrg @item @emph{Syntax}: 10115 1.1 mrg @code{RESULT = MASKR(I[, KIND])} 10116 1.1 mrg 10117 1.1 mrg @item @emph{Arguments}: 10118 1.1 mrg @multitable @columnfractions .15 .70 10119 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}. 10120 1.1 mrg @item @var{KIND} @tab Shall be a scalar constant expression of type 10121 1.1 mrg @code{INTEGER}. 10122 1.1 mrg @end multitable 10123 1.1 mrg 10124 1.1 mrg @item @emph{Return value}: 10125 1.1 mrg The return value is of type @code{INTEGER}. If @var{KIND} is present, it 10126 1.1 mrg specifies the kind value of the return type; otherwise, it is of the 10127 1.1 mrg default integer kind. 10128 1.1 mrg 10129 1.1 mrg @item @emph{See also}: 10130 1.1 mrg @ref{MASKL} 10131 1.1 mrg @end table 10132 1.1 mrg 10133 1.1 mrg 10134 1.1 mrg 10135 1.1 mrg @node MATMUL 10136 1.1 mrg @section @code{MATMUL} --- matrix multiplication 10137 1.1 mrg @fnindex MATMUL 10138 1.1 mrg @cindex matrix multiplication 10139 1.1 mrg @cindex product, matrix 10140 1.1 mrg 10141 1.1 mrg @table @asis 10142 1.1 mrg @item @emph{Description}: 10143 1.1 mrg Performs a matrix multiplication on numeric or logical arguments. 10144 1.1 mrg 10145 1.1 mrg @item @emph{Standard}: 10146 1.1.1.2 mrg Fortran 90 and later 10147 1.1 mrg 10148 1.1 mrg @item @emph{Class}: 10149 1.1 mrg Transformational function 10150 1.1 mrg 10151 1.1 mrg @item @emph{Syntax}: 10152 1.1 mrg @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)} 10153 1.1 mrg 10154 1.1 mrg @item @emph{Arguments}: 10155 1.1 mrg @multitable @columnfractions .15 .70 10156 1.1 mrg @item @var{MATRIX_A} @tab An array of @code{INTEGER}, 10157 1.1 mrg @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of 10158 1.1 mrg one or two. 10159 1.1 mrg @item @var{MATRIX_B} @tab An array of @code{INTEGER}, 10160 1.1 mrg @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric 10161 1.1 mrg type; otherwise, an array of @code{LOGICAL} type. The rank shall be one 10162 1.1 mrg or two, and the first (or only) dimension of @var{MATRIX_B} shall be 10163 1.1 mrg equal to the last (or only) dimension of @var{MATRIX_A}. 10164 1.1 mrg @var{MATRIX_A} and @var{MATRIX_B} shall not both be rank one arrays. 10165 1.1 mrg @end multitable 10166 1.1 mrg 10167 1.1 mrg @item @emph{Return value}: 10168 1.1 mrg The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and 10169 1.1 mrg kind of the result follow the usual type and kind promotion rules, as 10170 1.1 mrg for the @code{*} or @code{.AND.} operators. 10171 1.1 mrg @end table 10172 1.1 mrg 10173 1.1 mrg 10174 1.1 mrg 10175 1.1 mrg @node MAX 10176 1.1 mrg @section @code{MAX} --- Maximum value of an argument list 10177 1.1 mrg @fnindex MAX 10178 1.1 mrg @fnindex MAX0 10179 1.1 mrg @fnindex AMAX0 10180 1.1 mrg @fnindex MAX1 10181 1.1 mrg @fnindex AMAX1 10182 1.1 mrg @fnindex DMAX1 10183 1.1 mrg @cindex maximum value 10184 1.1 mrg 10185 1.1 mrg @table @asis 10186 1.1 mrg @item @emph{Description}: 10187 1.1 mrg Returns the argument with the largest (most positive) value. 10188 1.1 mrg 10189 1.1 mrg @item @emph{Standard}: 10190 1.1 mrg Fortran 77 and later 10191 1.1 mrg 10192 1.1 mrg @item @emph{Class}: 10193 1.1 mrg Elemental function 10194 1.1 mrg 10195 1.1 mrg @item @emph{Syntax}: 10196 1.1 mrg @code{RESULT = MAX(A1, A2 [, A3 [, ...]])} 10197 1.1 mrg 10198 1.1 mrg @item @emph{Arguments}: 10199 1.1 mrg @multitable @columnfractions .15 .70 10200 1.1 mrg @item @var{A1} @tab The type shall be @code{INTEGER} or 10201 1.1 mrg @code{REAL}. 10202 1.1 mrg @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind 10203 1.1 mrg as @var{A1}. (As a GNU extension, arguments of different kinds are 10204 1.1 mrg permitted.) 10205 1.1 mrg @end multitable 10206 1.1 mrg 10207 1.1 mrg @item @emph{Return value}: 10208 1.1 mrg The return value corresponds to the maximum value among the arguments, 10209 1.1 mrg and has the same type and kind as the first argument. 10210 1.1 mrg 10211 1.1 mrg @item @emph{Specific names}: 10212 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 10213 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 10214 1.1 mrg @item @code{MAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later 10215 1.1 mrg @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later 10216 1.1 mrg @item @code{MAX1(A1)} @tab @code{REAL A1} @tab @code{INT(MAX(X))} @tab Fortran 77 and later 10217 1.1 mrg @item @code{AMAX1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later 10218 1.1 mrg @item @code{DMAX1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later 10219 1.1 mrg @end multitable 10220 1.1 mrg 10221 1.1 mrg @item @emph{See also}: 10222 1.1.1.2 mrg @ref{MAXLOC} @gol 10223 1.1.1.2 mrg @ref{MAXVAL}, @gol 10224 1.1.1.2 mrg @ref{MIN} 10225 1.1 mrg @end table 10226 1.1 mrg 10227 1.1 mrg 10228 1.1 mrg 10229 1.1 mrg @node MAXEXPONENT 10230 1.1 mrg @section @code{MAXEXPONENT} --- Maximum exponent of a real kind 10231 1.1 mrg @fnindex MAXEXPONENT 10232 1.1 mrg @cindex model representation, maximum exponent 10233 1.1 mrg 10234 1.1 mrg @table @asis 10235 1.1 mrg @item @emph{Description}: 10236 1.1 mrg @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the 10237 1.1 mrg type of @code{X}. 10238 1.1 mrg 10239 1.1 mrg @item @emph{Standard}: 10240 1.1.1.2 mrg Fortran 90 and later 10241 1.1 mrg 10242 1.1 mrg @item @emph{Class}: 10243 1.1 mrg Inquiry function 10244 1.1 mrg 10245 1.1 mrg @item @emph{Syntax}: 10246 1.1 mrg @code{RESULT = MAXEXPONENT(X)} 10247 1.1 mrg 10248 1.1 mrg @item @emph{Arguments}: 10249 1.1 mrg @multitable @columnfractions .15 .70 10250 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}. 10251 1.1 mrg @end multitable 10252 1.1 mrg 10253 1.1 mrg @item @emph{Return value}: 10254 1.1 mrg The return value is of type @code{INTEGER} and of the default integer 10255 1.1 mrg kind. 10256 1.1 mrg 10257 1.1 mrg @item @emph{Example}: 10258 1.1 mrg @smallexample 10259 1.1 mrg program exponents 10260 1.1 mrg real(kind=4) :: x 10261 1.1 mrg real(kind=8) :: y 10262 1.1 mrg 10263 1.1 mrg print *, minexponent(x), maxexponent(x) 10264 1.1 mrg print *, minexponent(y), maxexponent(y) 10265 1.1 mrg end program exponents 10266 1.1 mrg @end smallexample 10267 1.1 mrg @end table 10268 1.1 mrg 10269 1.1 mrg 10270 1.1 mrg 10271 1.1 mrg @node MAXLOC 10272 1.1 mrg @section @code{MAXLOC} --- Location of the maximum value within an array 10273 1.1 mrg @fnindex MAXLOC 10274 1.1 mrg @cindex array, location of maximum element 10275 1.1 mrg 10276 1.1 mrg @table @asis 10277 1.1 mrg @item @emph{Description}: 10278 1.1 mrg Determines the location of the element in the array with the maximum 10279 1.1 mrg value, or, if the @var{DIM} argument is supplied, determines the 10280 1.1 mrg locations of the maximum element along each row of the array in the 10281 1.1 mrg @var{DIM} direction. If @var{MASK} is present, only the elements for 10282 1.1 mrg which @var{MASK} is @code{.TRUE.} are considered. If more than one 10283 1.1 mrg element in the array has the maximum value, the location returned is 10284 1.1 mrg that of the first such element in array element order if the 10285 1.1 mrg @var{BACK} is not present, or is false; if @var{BACK} is true, the location 10286 1.1 mrg returned is that of the last such element. If the array has zero 10287 1.1 mrg size, or all of the elements of @var{MASK} are @code{.FALSE.}, then 10288 1.1 mrg the result is an array of zeroes. Similarly, if @var{DIM} is supplied 10289 1.1 mrg and all of the elements of @var{MASK} along a given row are zero, the 10290 1.1 mrg result value for that row is zero. 10291 1.1 mrg 10292 1.1 mrg @item @emph{Standard}: 10293 1.1 mrg Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the 10294 1.1 mrg @var{KIND} argument are available in Fortran 2003 and later. 10295 1.1 mrg The @var{BACK} argument is available in Fortran 2008 and later. 10296 1.1 mrg 10297 1.1 mrg @item @emph{Class}: 10298 1.1 mrg Transformational function 10299 1.1 mrg 10300 1.1 mrg @item @emph{Syntax}: 10301 1.1 mrg @multitable @columnfractions .80 10302 1.1 mrg @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])} 10303 1.1 mrg @item @code{RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])} 10304 1.1 mrg @end multitable 10305 1.1 mrg 10306 1.1 mrg @item @emph{Arguments}: 10307 1.1 mrg @multitable @columnfractions .15 .70 10308 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or 10309 1.1 mrg @code{REAL}. 10310 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type 10311 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY}, 10312 1.1 mrg inclusive. It may not be an optional dummy argument. 10313 1.1.1.3 mrg @item @var{MASK} @tab Shall be of type @code{LOGICAL}, 10314 1.1 mrg and conformable with @var{ARRAY}. 10315 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 10316 1.1 mrg expression indicating the kind parameter of the result. 10317 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}. 10318 1.1 mrg @end multitable 10319 1.1 mrg 10320 1.1 mrg @item @emph{Return value}: 10321 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length 10322 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result 10323 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a 10324 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM} 10325 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank 10326 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND} 10327 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it 10328 1.1 mrg is of default kind. 10329 1.1 mrg 10330 1.1 mrg @item @emph{See also}: 10331 1.1.1.2 mrg @ref{FINDLOC}, @gol 10332 1.1.1.2 mrg @ref{MAX}, @gol 10333 1.1.1.2 mrg @ref{MAXVAL} 10334 1.1 mrg @end table 10335 1.1 mrg 10336 1.1 mrg 10337 1.1 mrg 10338 1.1 mrg @node MAXVAL 10339 1.1 mrg @section @code{MAXVAL} --- Maximum value of an array 10340 1.1 mrg @fnindex MAXVAL 10341 1.1 mrg @cindex array, maximum value 10342 1.1 mrg @cindex maximum value 10343 1.1 mrg 10344 1.1 mrg @table @asis 10345 1.1 mrg @item @emph{Description}: 10346 1.1 mrg Determines the maximum value of the elements in an array value, or, if 10347 1.1 mrg the @var{DIM} argument is supplied, determines the maximum value along 10348 1.1 mrg each row of the array in the @var{DIM} direction. If @var{MASK} is 10349 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are 10350 1.1 mrg considered. If the array has zero size, or all of the elements of 10351 1.1 mrg @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)} 10352 1.1 mrg if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character 10353 1.1 mrg type. 10354 1.1 mrg 10355 1.1 mrg @item @emph{Standard}: 10356 1.1.1.2 mrg Fortran 90 and later 10357 1.1 mrg 10358 1.1 mrg @item @emph{Class}: 10359 1.1 mrg Transformational function 10360 1.1 mrg 10361 1.1 mrg @item @emph{Syntax}: 10362 1.1 mrg @multitable @columnfractions .80 10363 1.1 mrg @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])} 10364 1.1 mrg @item @code{RESULT = MAXVAL(ARRAY [, MASK])} 10365 1.1 mrg @end multitable 10366 1.1 mrg 10367 1.1 mrg @item @emph{Arguments}: 10368 1.1 mrg @multitable @columnfractions .15 .70 10369 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or 10370 1.1 mrg @code{REAL}. 10371 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type 10372 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY}, 10373 1.1 mrg inclusive. It may not be an optional dummy argument. 10374 1.1.1.3 mrg @item @var{MASK} @tab (Optional) Shall be of type @code{LOGICAL}, 10375 1.1 mrg and conformable with @var{ARRAY}. 10376 1.1 mrg @end multitable 10377 1.1 mrg 10378 1.1 mrg @item @emph{Return value}: 10379 1.1 mrg If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result 10380 1.1 mrg is a scalar. If @var{DIM} is present, the result is an array with a 10381 1.1 mrg rank one less than the rank of @var{ARRAY}, and a size corresponding to 10382 1.1 mrg the size of @var{ARRAY} with the @var{DIM} dimension removed. In all 10383 1.1 mrg cases, the result is of the same type and kind as @var{ARRAY}. 10384 1.1 mrg 10385 1.1 mrg @item @emph{See also}: 10386 1.1.1.2 mrg @ref{MAX}, @gol 10387 1.1.1.2 mrg @ref{MAXLOC} 10388 1.1 mrg @end table 10389 1.1 mrg 10390 1.1 mrg 10391 1.1 mrg 10392 1.1 mrg @node MCLOCK 10393 1.1 mrg @section @code{MCLOCK} --- Time function 10394 1.1 mrg @fnindex MCLOCK 10395 1.1 mrg @cindex time, clock ticks 10396 1.1 mrg @cindex clock ticks 10397 1.1 mrg 10398 1.1 mrg @table @asis 10399 1.1 mrg @item @emph{Description}: 10400 1.1 mrg Returns the number of clock ticks since the start of the process, based 10401 1.1 mrg on the function @code{clock(3)} in the C standard library. 10402 1.1 mrg 10403 1.1 mrg This intrinsic is not fully portable, such as to systems with 32-bit 10404 1.1 mrg @code{INTEGER} types but supporting times wider than 32 bits. Therefore, 10405 1.1 mrg the values returned by this intrinsic might be, or become, negative, or 10406 1.1 mrg numerically less than previous values, during a single run of the 10407 1.1 mrg compiled program. 10408 1.1 mrg 10409 1.1 mrg @item @emph{Standard}: 10410 1.1 mrg GNU extension 10411 1.1 mrg 10412 1.1 mrg @item @emph{Class}: 10413 1.1 mrg Function 10414 1.1 mrg 10415 1.1 mrg @item @emph{Syntax}: 10416 1.1 mrg @code{RESULT = MCLOCK()} 10417 1.1 mrg 10418 1.1 mrg @item @emph{Return value}: 10419 1.1 mrg The return value is a scalar of type @code{INTEGER(4)}, equal to the 10420 1.1 mrg number of clock ticks since the start of the process, or @code{-1} if 10421 1.1 mrg the system does not support @code{clock(3)}. 10422 1.1 mrg 10423 1.1 mrg @item @emph{See also}: 10424 1.1.1.2 mrg @ref{CTIME}, @gol 10425 1.1.1.2 mrg @ref{GMTIME}, @gol 10426 1.1.1.2 mrg @ref{LTIME}, @gol 10427 1.1.1.2 mrg @ref{MCLOCK}, @gol 10428 1.1.1.2 mrg @ref{TIME} 10429 1.1 mrg @end table 10430 1.1 mrg 10431 1.1 mrg 10432 1.1 mrg 10433 1.1 mrg @node MCLOCK8 10434 1.1 mrg @section @code{MCLOCK8} --- Time function (64-bit) 10435 1.1 mrg @fnindex MCLOCK8 10436 1.1 mrg @cindex time, clock ticks 10437 1.1 mrg @cindex clock ticks 10438 1.1 mrg 10439 1.1 mrg @table @asis 10440 1.1 mrg @item @emph{Description}: 10441 1.1 mrg Returns the number of clock ticks since the start of the process, based 10442 1.1 mrg on the function @code{clock(3)} in the C standard library. 10443 1.1 mrg 10444 1.1 mrg @emph{Warning:} this intrinsic does not increase the range of the timing 10445 1.1 mrg values over that returned by @code{clock(3)}. On a system with a 32-bit 10446 1.1 mrg @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though 10447 1.1 mrg it is converted to a 64-bit @code{INTEGER(8)} value. That means 10448 1.1 mrg overflows of the 32-bit value can still occur. Therefore, the values 10449 1.1 mrg returned by this intrinsic might be or become negative or numerically 10450 1.1 mrg less than previous values during a single run of the compiled program. 10451 1.1 mrg 10452 1.1 mrg @item @emph{Standard}: 10453 1.1 mrg GNU extension 10454 1.1 mrg 10455 1.1 mrg @item @emph{Class}: 10456 1.1 mrg Function 10457 1.1 mrg 10458 1.1 mrg @item @emph{Syntax}: 10459 1.1 mrg @code{RESULT = MCLOCK8()} 10460 1.1 mrg 10461 1.1 mrg @item @emph{Return value}: 10462 1.1 mrg The return value is a scalar of type @code{INTEGER(8)}, equal to the 10463 1.1 mrg number of clock ticks since the start of the process, or @code{-1} if 10464 1.1 mrg the system does not support @code{clock(3)}. 10465 1.1 mrg 10466 1.1 mrg @item @emph{See also}: 10467 1.1.1.2 mrg @ref{CTIME}, @gol 10468 1.1.1.2 mrg @ref{GMTIME}, @gol 10469 1.1.1.2 mrg @ref{LTIME}, @gol 10470 1.1.1.2 mrg @ref{MCLOCK}, @gol 10471 1.1.1.2 mrg @ref{TIME8} 10472 1.1 mrg @end table 10473 1.1 mrg 10474 1.1 mrg 10475 1.1 mrg 10476 1.1 mrg @node MERGE 10477 1.1 mrg @section @code{MERGE} --- Merge variables 10478 1.1 mrg @fnindex MERGE 10479 1.1 mrg @cindex array, merge arrays 10480 1.1 mrg @cindex array, combine arrays 10481 1.1 mrg 10482 1.1 mrg @table @asis 10483 1.1 mrg @item @emph{Description}: 10484 1.1 mrg Select values from two arrays according to a logical mask. The result 10485 1.1 mrg is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to 10486 1.1 mrg @var{FSOURCE} if it is @code{.FALSE.}. 10487 1.1 mrg 10488 1.1 mrg @item @emph{Standard}: 10489 1.1.1.2 mrg Fortran 90 and later 10490 1.1 mrg 10491 1.1 mrg @item @emph{Class}: 10492 1.1 mrg Elemental function 10493 1.1 mrg 10494 1.1 mrg @item @emph{Syntax}: 10495 1.1 mrg @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)} 10496 1.1 mrg 10497 1.1 mrg @item @emph{Arguments}: 10498 1.1 mrg @multitable @columnfractions .15 .70 10499 1.1 mrg @item @var{TSOURCE} @tab May be of any type. 10500 1.1 mrg @item @var{FSOURCE} @tab Shall be of the same type and type parameters 10501 1.1 mrg as @var{TSOURCE}. 10502 1.1 mrg @item @var{MASK} @tab Shall be of type @code{LOGICAL}. 10503 1.1 mrg @end multitable 10504 1.1 mrg 10505 1.1 mrg @item @emph{Return value}: 10506 1.1 mrg The result is of the same type and type parameters as @var{TSOURCE}. 10507 1.1 mrg 10508 1.1 mrg @end table 10509 1.1 mrg 10510 1.1 mrg 10511 1.1 mrg 10512 1.1 mrg @node MERGE_BITS 10513 1.1 mrg @section @code{MERGE_BITS} --- Merge of bits under mask 10514 1.1 mrg @fnindex MERGE_BITS 10515 1.1 mrg @cindex bits, merge 10516 1.1 mrg 10517 1.1 mrg @table @asis 10518 1.1 mrg @item @emph{Description}: 10519 1.1 mrg @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J} 10520 1.1 mrg as determined by the mask. The i-th bit of the result is equal to the 10521 1.1 mrg i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to 10522 1.1 mrg the i-th bit of @var{J} otherwise. 10523 1.1 mrg 10524 1.1 mrg @item @emph{Standard}: 10525 1.1 mrg Fortran 2008 and later 10526 1.1 mrg 10527 1.1 mrg @item @emph{Class}: 10528 1.1 mrg Elemental function 10529 1.1 mrg 10530 1.1 mrg @item @emph{Syntax}: 10531 1.1 mrg @code{RESULT = MERGE_BITS(I, J, MASK)} 10532 1.1 mrg 10533 1.1 mrg @item @emph{Arguments}: 10534 1.1 mrg @multitable @columnfractions .15 .70 10535 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER} or a boz-literal-constant. 10536 1.1 mrg @item @var{J} @tab Shall be of type @code{INTEGER} with the same 10537 1.1 mrg kind type parameter as @var{I} or a boz-literal-constant. 10538 1.1 mrg @var{I} and @var{J} shall not both be boz-literal-constants. 10539 1.1 mrg @item @var{MASK} @tab Shall be of type @code{INTEGER} or a boz-literal-constant 10540 1.1 mrg and of the same kind as @var{I}. 10541 1.1 mrg @end multitable 10542 1.1 mrg 10543 1.1 mrg @item @emph{Return value}: 10544 1.1 mrg The result is of the same type and kind as @var{I}. 10545 1.1 mrg 10546 1.1 mrg @end table 10547 1.1 mrg 10548 1.1 mrg 10549 1.1 mrg 10550 1.1 mrg @node MIN 10551 1.1 mrg @section @code{MIN} --- Minimum value of an argument list 10552 1.1 mrg @fnindex MIN 10553 1.1 mrg @fnindex MIN0 10554 1.1 mrg @fnindex AMIN0 10555 1.1 mrg @fnindex MIN1 10556 1.1 mrg @fnindex AMIN1 10557 1.1 mrg @fnindex DMIN1 10558 1.1 mrg @cindex minimum value 10559 1.1 mrg 10560 1.1 mrg @table @asis 10561 1.1 mrg @item @emph{Description}: 10562 1.1 mrg Returns the argument with the smallest (most negative) value. 10563 1.1 mrg 10564 1.1 mrg @item @emph{Standard}: 10565 1.1 mrg Fortran 77 and later 10566 1.1 mrg 10567 1.1 mrg @item @emph{Class}: 10568 1.1 mrg Elemental function 10569 1.1 mrg 10570 1.1 mrg @item @emph{Syntax}: 10571 1.1 mrg @code{RESULT = MIN(A1, A2 [, A3, ...])} 10572 1.1 mrg 10573 1.1 mrg @item @emph{Arguments}: 10574 1.1 mrg @multitable @columnfractions .15 .70 10575 1.1 mrg @item @var{A1} @tab The type shall be @code{INTEGER} or 10576 1.1 mrg @code{REAL}. 10577 1.1 mrg @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind 10578 1.1 mrg as @var{A1}. (As a GNU extension, arguments of different kinds are 10579 1.1 mrg permitted.) 10580 1.1 mrg @end multitable 10581 1.1 mrg 10582 1.1 mrg @item @emph{Return value}: 10583 1.1.1.3 mrg The return value corresponds to the minimum value among the arguments, 10584 1.1 mrg and has the same type and kind as the first argument. 10585 1.1 mrg 10586 1.1 mrg @item @emph{Specific names}: 10587 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 10588 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 10589 1.1 mrg @item @code{MIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later 10590 1.1 mrg @item @code{AMIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later 10591 1.1 mrg @item @code{MIN1(A1)} @tab @code{REAL A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later 10592 1.1 mrg @item @code{AMIN1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later 10593 1.1 mrg @item @code{DMIN1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later 10594 1.1 mrg @end multitable 10595 1.1 mrg 10596 1.1 mrg @item @emph{See also}: 10597 1.1.1.2 mrg @ref{MAX}, @gol 10598 1.1.1.2 mrg @ref{MINLOC}, @gol 10599 1.1.1.2 mrg @ref{MINVAL} 10600 1.1 mrg @end table 10601 1.1 mrg 10602 1.1 mrg 10603 1.1 mrg 10604 1.1 mrg @node MINEXPONENT 10605 1.1 mrg @section @code{MINEXPONENT} --- Minimum exponent of a real kind 10606 1.1 mrg @fnindex MINEXPONENT 10607 1.1 mrg @cindex model representation, minimum exponent 10608 1.1 mrg 10609 1.1 mrg @table @asis 10610 1.1 mrg @item @emph{Description}: 10611 1.1 mrg @code{MINEXPONENT(X)} returns the minimum exponent in the model of the 10612 1.1 mrg type of @code{X}. 10613 1.1 mrg 10614 1.1 mrg @item @emph{Standard}: 10615 1.1.1.2 mrg Fortran 90 and later 10616 1.1 mrg 10617 1.1 mrg @item @emph{Class}: 10618 1.1 mrg Inquiry function 10619 1.1 mrg 10620 1.1 mrg @item @emph{Syntax}: 10621 1.1 mrg @code{RESULT = MINEXPONENT(X)} 10622 1.1 mrg 10623 1.1 mrg @item @emph{Arguments}: 10624 1.1 mrg @multitable @columnfractions .15 .70 10625 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}. 10626 1.1 mrg @end multitable 10627 1.1 mrg 10628 1.1 mrg @item @emph{Return value}: 10629 1.1 mrg The return value is of type @code{INTEGER} and of the default integer 10630 1.1 mrg kind. 10631 1.1 mrg 10632 1.1 mrg @item @emph{Example}: 10633 1.1 mrg See @code{MAXEXPONENT} for an example. 10634 1.1 mrg @end table 10635 1.1 mrg 10636 1.1 mrg 10637 1.1 mrg 10638 1.1 mrg @node MINLOC 10639 1.1 mrg @section @code{MINLOC} --- Location of the minimum value within an array 10640 1.1 mrg @fnindex MINLOC 10641 1.1 mrg @cindex array, location of minimum element 10642 1.1 mrg 10643 1.1 mrg @table @asis 10644 1.1 mrg @item @emph{Description}: 10645 1.1 mrg Determines the location of the element in the array with the minimum 10646 1.1 mrg value, or, if the @var{DIM} argument is supplied, determines the 10647 1.1 mrg locations of the minimum element along each row of the array in the 10648 1.1 mrg @var{DIM} direction. If @var{MASK} is present, only the elements for 10649 1.1 mrg which @var{MASK} is @code{.TRUE.} are considered. If more than one 10650 1.1 mrg element in the array has the minimum value, the location returned is 10651 1.1 mrg that of the first such element in array element order if the 10652 1.1 mrg @var{BACK} is not present, or is false; if @var{BACK} is true, the location 10653 1.1 mrg returned is that of the last such element. If the array has 10654 1.1 mrg zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then 10655 1.1 mrg the result is an array of zeroes. Similarly, if @var{DIM} is supplied 10656 1.1 mrg and all of the elements of @var{MASK} along a given row are zero, the 10657 1.1 mrg result value for that row is zero. 10658 1.1 mrg 10659 1.1 mrg @item @emph{Standard}: 10660 1.1.1.2 mrg Fortran 90 and later; @var{ARRAY} of @code{CHARACTER} and the 10661 1.1 mrg @var{KIND} argument are available in Fortran 2003 and later. 10662 1.1 mrg The @var{BACK} argument is available in Fortran 2008 and later. 10663 1.1 mrg 10664 1.1 mrg @item @emph{Class}: 10665 1.1 mrg Transformational function 10666 1.1 mrg 10667 1.1 mrg @item @emph{Syntax}: 10668 1.1 mrg @multitable @columnfractions .80 10669 1.1 mrg @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])} 10670 1.1 mrg @item @code{RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK])} 10671 1.1 mrg @end multitable 10672 1.1 mrg 10673 1.1 mrg @item @emph{Arguments}: 10674 1.1 mrg @multitable @columnfractions .15 .70 10675 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 10676 1.1 mrg @code{REAL} or @code{CHARACTER}. 10677 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type 10678 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY}, 10679 1.1 mrg inclusive. It may not be an optional dummy argument. 10680 1.1.1.3 mrg @item @var{MASK} @tab Shall be of type @code{LOGICAL}, 10681 1.1 mrg and conformable with @var{ARRAY}. 10682 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 10683 1.1 mrg expression indicating the kind parameter of the result. 10684 1.1 mrg @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}. 10685 1.1 mrg @end multitable 10686 1.1 mrg 10687 1.1 mrg @item @emph{Return value}: 10688 1.1 mrg If @var{DIM} is absent, the result is a rank-one array with a length 10689 1.1 mrg equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result 10690 1.1 mrg is an array with a rank one less than the rank of @var{ARRAY}, and a 10691 1.1 mrg size corresponding to the size of @var{ARRAY} with the @var{DIM} 10692 1.1 mrg dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank 10693 1.1 mrg of one, the result is a scalar. If the optional argument @var{KIND} 10694 1.1 mrg is present, the result is an integer of kind @var{KIND}, otherwise it 10695 1.1 mrg is of default kind. 10696 1.1 mrg 10697 1.1 mrg @item @emph{See also}: 10698 1.1.1.2 mrg @ref{FINDLOC}, @gol 10699 1.1.1.2 mrg @ref{MIN}, @gol 10700 1.1.1.2 mrg @ref{MINVAL} 10701 1.1 mrg @end table 10702 1.1 mrg 10703 1.1 mrg 10704 1.1 mrg 10705 1.1 mrg @node MINVAL 10706 1.1 mrg @section @code{MINVAL} --- Minimum value of an array 10707 1.1 mrg @fnindex MINVAL 10708 1.1 mrg @cindex array, minimum value 10709 1.1 mrg @cindex minimum value 10710 1.1 mrg 10711 1.1 mrg @table @asis 10712 1.1 mrg @item @emph{Description}: 10713 1.1 mrg Determines the minimum value of the elements in an array value, or, if 10714 1.1 mrg the @var{DIM} argument is supplied, determines the minimum value along 10715 1.1 mrg each row of the array in the @var{DIM} direction. If @var{MASK} is 10716 1.1 mrg present, only the elements for which @var{MASK} is @code{.TRUE.} are 10717 1.1 mrg considered. If the array has zero size, or all of the elements of 10718 1.1 mrg @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if 10719 1.1 mrg @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if 10720 1.1 mrg @var{ARRAY} is of character type. 10721 1.1 mrg 10722 1.1 mrg @item @emph{Standard}: 10723 1.1.1.2 mrg Fortran 90 and later 10724 1.1 mrg 10725 1.1 mrg @item @emph{Class}: 10726 1.1 mrg Transformational function 10727 1.1 mrg 10728 1.1 mrg @item @emph{Syntax}: 10729 1.1 mrg @multitable @columnfractions .80 10730 1.1 mrg @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])} 10731 1.1 mrg @item @code{RESULT = MINVAL(ARRAY [, MASK])} 10732 1.1 mrg @end multitable 10733 1.1 mrg 10734 1.1 mrg @item @emph{Arguments}: 10735 1.1 mrg @multitable @columnfractions .15 .70 10736 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or 10737 1.1 mrg @code{REAL}. 10738 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar of type 10739 1.1 mrg @code{INTEGER}, with a value between one and the rank of @var{ARRAY}, 10740 1.1 mrg inclusive. It may not be an optional dummy argument. 10741 1.1.1.3 mrg @item @var{MASK} @tab Shall be of type @code{LOGICAL}, 10742 1.1 mrg and conformable with @var{ARRAY}. 10743 1.1 mrg @end multitable 10744 1.1 mrg 10745 1.1 mrg @item @emph{Return value}: 10746 1.1 mrg If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result 10747 1.1 mrg is a scalar. If @var{DIM} is present, the result is an array with a 10748 1.1 mrg rank one less than the rank of @var{ARRAY}, and a size corresponding to 10749 1.1 mrg the size of @var{ARRAY} with the @var{DIM} dimension removed. In all 10750 1.1 mrg cases, the result is of the same type and kind as @var{ARRAY}. 10751 1.1 mrg 10752 1.1 mrg @item @emph{See also}: 10753 1.1.1.2 mrg @ref{MIN}, @gol 10754 1.1.1.2 mrg @ref{MINLOC} 10755 1.1 mrg @end table 10756 1.1 mrg 10757 1.1 mrg 10758 1.1 mrg 10759 1.1 mrg @node MOD 10760 1.1 mrg @section @code{MOD} --- Remainder function 10761 1.1 mrg @fnindex MOD 10762 1.1 mrg @fnindex AMOD 10763 1.1 mrg @fnindex DMOD 10764 1.1 mrg @fnindex BMOD 10765 1.1 mrg @fnindex IMOD 10766 1.1 mrg @fnindex JMOD 10767 1.1 mrg @fnindex KMOD 10768 1.1 mrg @cindex remainder 10769 1.1 mrg @cindex division, remainder 10770 1.1 mrg 10771 1.1 mrg @table @asis 10772 1.1 mrg @item @emph{Description}: 10773 1.1 mrg @code{MOD(A,P)} computes the remainder of the division of A by P@. 10774 1.1 mrg 10775 1.1 mrg @item @emph{Standard}: 10776 1.1 mrg Fortran 77 and later, has overloads that are GNU extensions 10777 1.1 mrg 10778 1.1 mrg @item @emph{Class}: 10779 1.1 mrg Elemental function 10780 1.1 mrg 10781 1.1 mrg @item @emph{Syntax}: 10782 1.1 mrg @code{RESULT = MOD(A, P)} 10783 1.1 mrg 10784 1.1 mrg @item @emph{Arguments}: 10785 1.1 mrg @multitable @columnfractions .15 .70 10786 1.1 mrg @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}. 10787 1.1 mrg @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A} 10788 1.1.1.2 mrg and not equal to zero. (As a GNU extension, arguments of different kinds are 10789 1.1.1.2 mrg permitted.) 10790 1.1 mrg @end multitable 10791 1.1 mrg 10792 1.1 mrg @item @emph{Return value}: 10793 1.1 mrg The return value is the result of @code{A - (INT(A/P) * P)}. The type 10794 1.1 mrg and kind of the return value is the same as that of the arguments. The 10795 1.1 mrg returned value has the same sign as A and a magnitude less than the 10796 1.1.1.2 mrg magnitude of P. (As a GNU extension, kind is the largest kind of the actual 10797 1.1.1.2 mrg arguments.) 10798 1.1 mrg 10799 1.1 mrg @item @emph{Example}: 10800 1.1 mrg @smallexample 10801 1.1 mrg program test_mod 10802 1.1 mrg print *, mod(17,3) 10803 1.1 mrg print *, mod(17.5,5.5) 10804 1.1 mrg print *, mod(17.5d0,5.5) 10805 1.1 mrg print *, mod(17.5,5.5d0) 10806 1.1 mrg 10807 1.1 mrg print *, mod(-17,3) 10808 1.1 mrg print *, mod(-17.5,5.5) 10809 1.1 mrg print *, mod(-17.5d0,5.5) 10810 1.1 mrg print *, mod(-17.5,5.5d0) 10811 1.1 mrg 10812 1.1 mrg print *, mod(17,-3) 10813 1.1 mrg print *, mod(17.5,-5.5) 10814 1.1 mrg print *, mod(17.5d0,-5.5) 10815 1.1 mrg print *, mod(17.5,-5.5d0) 10816 1.1 mrg end program test_mod 10817 1.1 mrg @end smallexample 10818 1.1 mrg 10819 1.1 mrg @item @emph{Specific names}: 10820 1.1.1.3 mrg @multitable @columnfractions .20 .25 .20 .31 10821 1.1.1.3 mrg @headitem Name @tab Arguments @tab Return type @tab Standard 10822 1.1.1.2 mrg @item @code{MOD(A,P)} @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 77 and later 10823 1.1.1.2 mrg @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 77 and later 10824 1.1.1.2 mrg @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 77 and later 10825 1.1 mrg @item @code{BMOD(A,P)} @tab @code{INTEGER(1) A,P} @tab @code{INTEGER(1)} @tab GNU extension 10826 1.1 mrg @item @code{IMOD(A,P)} @tab @code{INTEGER(2) A,P} @tab @code{INTEGER(2)} @tab GNU extension 10827 1.1 mrg @item @code{JMOD(A,P)} @tab @code{INTEGER(4) A,P} @tab @code{INTEGER(4)} @tab GNU extension 10828 1.1 mrg @item @code{KMOD(A,P)} @tab @code{INTEGER(8) A,P} @tab @code{INTEGER(8)} @tab GNU extension 10829 1.1 mrg @end multitable 10830 1.1 mrg 10831 1.1 mrg @item @emph{See also}: 10832 1.1 mrg @ref{MODULO} 10833 1.1 mrg 10834 1.1 mrg @end table 10835 1.1 mrg 10836 1.1 mrg 10837 1.1 mrg 10838 1.1 mrg @node MODULO 10839 1.1 mrg @section @code{MODULO} --- Modulo function 10840 1.1 mrg @fnindex MODULO 10841 1.1 mrg @cindex modulo 10842 1.1 mrg @cindex division, modulo 10843 1.1 mrg 10844 1.1 mrg @table @asis 10845 1.1 mrg @item @emph{Description}: 10846 1.1 mrg @code{MODULO(A,P)} computes the @var{A} modulo @var{P}. 10847 1.1 mrg 10848 1.1 mrg @item @emph{Standard}: 10849 1.1 mrg Fortran 95 and later 10850 1.1 mrg 10851 1.1 mrg @item @emph{Class}: 10852 1.1 mrg Elemental function 10853 1.1 mrg 10854 1.1 mrg @item @emph{Syntax}: 10855 1.1 mrg @code{RESULT = MODULO(A, P)} 10856 1.1 mrg 10857 1.1 mrg @item @emph{Arguments}: 10858 1.1 mrg @multitable @columnfractions .15 .70 10859 1.1 mrg @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}. 10860 1.1 mrg @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}. 10861 1.1.1.2 mrg It shall not be zero. (As a GNU extension, arguments of different kinds are 10862 1.1.1.2 mrg permitted.) 10863 1.1 mrg @end multitable 10864 1.1 mrg 10865 1.1 mrg @item @emph{Return value}: 10866 1.1.1.2 mrg The type and kind of the result are those of the arguments. (As a GNU 10867 1.1.1.2 mrg extension, kind is the largest kind of the actual arguments.) 10868 1.1 mrg @table @asis 10869 1.1 mrg @item If @var{A} and @var{P} are of type @code{INTEGER}: 10870 1.1 mrg @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where 10871 1.1 mrg @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P} 10872 1.1 mrg (exclusive). 10873 1.1 mrg @item If @var{A} and @var{P} are of type @code{REAL}: 10874 1.1 mrg @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}. 10875 1.1 mrg @end table 10876 1.1 mrg The returned value has the same sign as P and a magnitude less than 10877 1.1 mrg the magnitude of P. 10878 1.1 mrg 10879 1.1 mrg @item @emph{Example}: 10880 1.1 mrg @smallexample 10881 1.1 mrg program test_modulo 10882 1.1 mrg print *, modulo(17,3) 10883 1.1 mrg print *, modulo(17.5,5.5) 10884 1.1 mrg 10885 1.1 mrg print *, modulo(-17,3) 10886 1.1 mrg print *, modulo(-17.5,5.5) 10887 1.1 mrg 10888 1.1 mrg print *, modulo(17,-3) 10889 1.1 mrg print *, modulo(17.5,-5.5) 10890 1.1 mrg end program 10891 1.1 mrg @end smallexample 10892 1.1 mrg 10893 1.1 mrg @item @emph{See also}: 10894 1.1 mrg @ref{MOD} 10895 1.1 mrg 10896 1.1 mrg @end table 10897 1.1 mrg 10898 1.1 mrg 10899 1.1 mrg 10900 1.1 mrg @node MOVE_ALLOC 10901 1.1 mrg @section @code{MOVE_ALLOC} --- Move allocation from one object to another 10902 1.1 mrg @fnindex MOVE_ALLOC 10903 1.1 mrg @cindex moving allocation 10904 1.1 mrg @cindex allocation, moving 10905 1.1 mrg 10906 1.1 mrg @table @asis 10907 1.1 mrg @item @emph{Description}: 10908 1.1 mrg @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to 10909 1.1 mrg @var{TO}. @var{FROM} will become deallocated in the process. 10910 1.1 mrg 10911 1.1 mrg @item @emph{Standard}: 10912 1.1 mrg Fortran 2003 and later 10913 1.1 mrg 10914 1.1 mrg @item @emph{Class}: 10915 1.1 mrg Pure subroutine 10916 1.1 mrg 10917 1.1 mrg @item @emph{Syntax}: 10918 1.1 mrg @code{CALL MOVE_ALLOC(FROM, TO)} 10919 1.1 mrg 10920 1.1 mrg @item @emph{Arguments}: 10921 1.1 mrg @multitable @columnfractions .15 .70 10922 1.1 mrg @item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be 10923 1.1 mrg of any type and kind. 10924 1.1 mrg @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be 10925 1.1 mrg of the same type, kind and rank as @var{FROM}. 10926 1.1 mrg @end multitable 10927 1.1 mrg 10928 1.1 mrg @item @emph{Return value}: 10929 1.1 mrg None 10930 1.1 mrg 10931 1.1 mrg @item @emph{Example}: 10932 1.1 mrg @smallexample 10933 1.1 mrg program test_move_alloc 10934 1.1 mrg integer, allocatable :: a(:), b(:) 10935 1.1 mrg 10936 1.1 mrg allocate(a(3)) 10937 1.1 mrg a = [ 1, 2, 3 ] 10938 1.1 mrg call move_alloc(a, b) 10939 1.1 mrg print *, allocated(a), allocated(b) 10940 1.1 mrg print *, b 10941 1.1 mrg end program test_move_alloc 10942 1.1 mrg @end smallexample 10943 1.1 mrg @end table 10944 1.1 mrg 10945 1.1 mrg 10946 1.1 mrg 10947 1.1 mrg @node MVBITS 10948 1.1 mrg @section @code{MVBITS} --- Move bits from one integer to another 10949 1.1 mrg @fnindex MVBITS 10950 1.1 mrg @fnindex BMVBITS 10951 1.1 mrg @fnindex IMVBITS 10952 1.1 mrg @fnindex JMVBITS 10953 1.1 mrg @fnindex KMVBITS 10954 1.1 mrg @cindex bits, move 10955 1.1 mrg 10956 1.1 mrg @table @asis 10957 1.1 mrg @item @emph{Description}: 10958 1.1 mrg Moves @var{LEN} bits from positions @var{FROMPOS} through 10959 1.1 mrg @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through 10960 1.1 mrg @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not 10961 1.1 mrg affected by the movement of bits is unchanged. The values of 10962 1.1 mrg @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than 10963 1.1 mrg @code{BIT_SIZE(FROM)}. 10964 1.1 mrg 10965 1.1 mrg @item @emph{Standard}: 10966 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions 10967 1.1 mrg 10968 1.1 mrg @item @emph{Class}: 10969 1.1 mrg Elemental subroutine 10970 1.1 mrg 10971 1.1 mrg @item @emph{Syntax}: 10972 1.1 mrg @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)} 10973 1.1 mrg 10974 1.1 mrg @item @emph{Arguments}: 10975 1.1 mrg @multitable @columnfractions .15 .70 10976 1.1 mrg @item @var{FROM} @tab The type shall be @code{INTEGER}. 10977 1.1 mrg @item @var{FROMPOS} @tab The type shall be @code{INTEGER}. 10978 1.1 mrg @item @var{LEN} @tab The type shall be @code{INTEGER}. 10979 1.1 mrg @item @var{TO} @tab The type shall be @code{INTEGER}, of the 10980 1.1 mrg same kind as @var{FROM}. 10981 1.1 mrg @item @var{TOPOS} @tab The type shall be @code{INTEGER}. 10982 1.1 mrg @end multitable 10983 1.1 mrg 10984 1.1 mrg @item @emph{Specific names}: 10985 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 10986 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 10987 1.1.1.2 mrg @item @code{MVBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later 10988 1.1 mrg @item @code{BMVBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 10989 1.1 mrg @item @code{IMVBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 10990 1.1 mrg @item @code{JMVBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 10991 1.1 mrg @item @code{KMVBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 10992 1.1 mrg @end multitable 10993 1.1 mrg 10994 1.1 mrg @item @emph{See also}: 10995 1.1.1.2 mrg @ref{IBCLR}, @gol 10996 1.1.1.2 mrg @ref{IBSET}, @gol 10997 1.1.1.2 mrg @ref{IBITS}, @gol 10998 1.1.1.2 mrg @ref{IAND}, @gol 10999 1.1.1.2 mrg @ref{IOR}, @gol 11000 1.1.1.2 mrg @ref{IEOR} 11001 1.1 mrg @end table 11002 1.1 mrg 11003 1.1 mrg 11004 1.1 mrg 11005 1.1 mrg @node NEAREST 11006 1.1 mrg @section @code{NEAREST} --- Nearest representable number 11007 1.1 mrg @fnindex NEAREST 11008 1.1 mrg @cindex real number, nearest different 11009 1.1 mrg @cindex floating point, nearest different 11010 1.1 mrg 11011 1.1 mrg @table @asis 11012 1.1 mrg @item @emph{Description}: 11013 1.1 mrg @code{NEAREST(X, S)} returns the processor-representable number nearest 11014 1.1 mrg to @code{X} in the direction indicated by the sign of @code{S}. 11015 1.1 mrg 11016 1.1 mrg @item @emph{Standard}: 11017 1.1.1.2 mrg Fortran 90 and later 11018 1.1 mrg 11019 1.1 mrg @item @emph{Class}: 11020 1.1 mrg Elemental function 11021 1.1 mrg 11022 1.1 mrg @item @emph{Syntax}: 11023 1.1 mrg @code{RESULT = NEAREST(X, S)} 11024 1.1 mrg 11025 1.1 mrg @item @emph{Arguments}: 11026 1.1 mrg @multitable @columnfractions .15 .70 11027 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}. 11028 1.1 mrg @item @var{S} @tab Shall be of type @code{REAL} and 11029 1.1 mrg not equal to zero. 11030 1.1 mrg @end multitable 11031 1.1 mrg 11032 1.1 mrg @item @emph{Return value}: 11033 1.1 mrg The return value is of the same type as @code{X}. If @code{S} is 11034 1.1 mrg positive, @code{NEAREST} returns the processor-representable number 11035 1.1 mrg greater than @code{X} and nearest to it. If @code{S} is negative, 11036 1.1 mrg @code{NEAREST} returns the processor-representable number smaller than 11037 1.1 mrg @code{X} and nearest to it. 11038 1.1 mrg 11039 1.1 mrg @item @emph{Example}: 11040 1.1 mrg @smallexample 11041 1.1 mrg program test_nearest 11042 1.1 mrg real :: x, y 11043 1.1 mrg x = nearest(42.0, 1.0) 11044 1.1 mrg y = nearest(42.0, -1.0) 11045 1.1 mrg write (*,"(3(G20.15))") x, y, x - y 11046 1.1 mrg end program test_nearest 11047 1.1 mrg @end smallexample 11048 1.1 mrg @end table 11049 1.1 mrg 11050 1.1 mrg 11051 1.1 mrg 11052 1.1 mrg @node NEW_LINE 11053 1.1 mrg @section @code{NEW_LINE} --- New line character 11054 1.1 mrg @fnindex NEW_LINE 11055 1.1 mrg @cindex newline 11056 1.1 mrg @cindex output, newline 11057 1.1 mrg 11058 1.1 mrg @table @asis 11059 1.1 mrg @item @emph{Description}: 11060 1.1 mrg @code{NEW_LINE(C)} returns the new-line character. 11061 1.1 mrg 11062 1.1 mrg @item @emph{Standard}: 11063 1.1 mrg Fortran 2003 and later 11064 1.1 mrg 11065 1.1 mrg @item @emph{Class}: 11066 1.1 mrg Inquiry function 11067 1.1 mrg 11068 1.1 mrg @item @emph{Syntax}: 11069 1.1 mrg @code{RESULT = NEW_LINE(C)} 11070 1.1 mrg 11071 1.1 mrg @item @emph{Arguments}: 11072 1.1 mrg @multitable @columnfractions .15 .70 11073 1.1 mrg @item @var{C} @tab The argument shall be a scalar or array of the 11074 1.1 mrg type @code{CHARACTER}. 11075 1.1 mrg @end multitable 11076 1.1 mrg 11077 1.1 mrg @item @emph{Return value}: 11078 1.1 mrg Returns a @var{CHARACTER} scalar of length one with the new-line character of 11079 1.1 mrg the same kind as parameter @var{C}. 11080 1.1 mrg 11081 1.1 mrg @item @emph{Example}: 11082 1.1 mrg @smallexample 11083 1.1 mrg program newline 11084 1.1 mrg implicit none 11085 1.1 mrg write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.' 11086 1.1 mrg end program newline 11087 1.1 mrg @end smallexample 11088 1.1 mrg @end table 11089 1.1 mrg 11090 1.1 mrg 11091 1.1 mrg 11092 1.1 mrg @node NINT 11093 1.1 mrg @section @code{NINT} --- Nearest whole number 11094 1.1 mrg @fnindex NINT 11095 1.1 mrg @fnindex IDNINT 11096 1.1 mrg @cindex rounding, nearest whole number 11097 1.1 mrg 11098 1.1 mrg @table @asis 11099 1.1 mrg @item @emph{Description}: 11100 1.1 mrg @code{NINT(A)} rounds its argument to the nearest whole number. 11101 1.1 mrg 11102 1.1 mrg @item @emph{Standard}: 11103 1.1 mrg Fortran 77 and later, with @var{KIND} argument Fortran 90 and later 11104 1.1 mrg 11105 1.1 mrg @item @emph{Class}: 11106 1.1 mrg Elemental function 11107 1.1 mrg 11108 1.1 mrg @item @emph{Syntax}: 11109 1.1 mrg @code{RESULT = NINT(A [, KIND])} 11110 1.1 mrg 11111 1.1 mrg @item @emph{Arguments}: 11112 1.1 mrg @multitable @columnfractions .15 .70 11113 1.1 mrg @item @var{A} @tab The type of the argument shall be @code{REAL}. 11114 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 11115 1.1 mrg expression indicating the kind parameter of the result. 11116 1.1 mrg @end multitable 11117 1.1 mrg 11118 1.1 mrg @item @emph{Return value}: 11119 1.1 mrg Returns @var{A} with the fractional portion of its magnitude eliminated by 11120 1.1 mrg rounding to the nearest whole number and with its sign preserved, 11121 1.1 mrg converted to an @code{INTEGER} of the default kind. 11122 1.1 mrg 11123 1.1 mrg @item @emph{Example}: 11124 1.1 mrg @smallexample 11125 1.1 mrg program test_nint 11126 1.1 mrg real(4) x4 11127 1.1 mrg real(8) x8 11128 1.1 mrg x4 = 1.234E0_4 11129 1.1 mrg x8 = 4.321_8 11130 1.1 mrg print *, nint(x4), idnint(x8) 11131 1.1 mrg end program test_nint 11132 1.1 mrg @end smallexample 11133 1.1 mrg 11134 1.1 mrg @item @emph{Specific names}: 11135 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 11136 1.1.1.3 mrg @headitem Name @tab Argument @tab Return Type @tab Standard 11137 1.1.1.2 mrg @item @code{NINT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later 11138 1.1.1.2 mrg @item @code{IDNINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later 11139 1.1 mrg @end multitable 11140 1.1 mrg 11141 1.1 mrg @item @emph{See also}: 11142 1.1.1.2 mrg @ref{CEILING}, @gol 11143 1.1.1.2 mrg @ref{FLOOR} 11144 1.1 mrg @end table 11145 1.1 mrg 11146 1.1 mrg 11147 1.1 mrg 11148 1.1 mrg @node NORM2 11149 1.1 mrg @section @code{NORM2} --- Euclidean vector norms 11150 1.1 mrg @fnindex NORM2 11151 1.1 mrg @cindex Euclidean vector norm 11152 1.1 mrg @cindex L2 vector norm 11153 1.1 mrg @cindex norm, Euclidean 11154 1.1 mrg 11155 1.1 mrg @table @asis 11156 1.1 mrg @item @emph{Description}: 11157 1.1.1.3 mrg Calculates the Euclidean vector norm (@math{L_2} norm) 11158 1.1 mrg of @var{ARRAY} along dimension @var{DIM}. 11159 1.1 mrg 11160 1.1 mrg @item @emph{Standard}: 11161 1.1 mrg Fortran 2008 and later 11162 1.1 mrg 11163 1.1 mrg @item @emph{Class}: 11164 1.1 mrg Transformational function 11165 1.1 mrg 11166 1.1 mrg @item @emph{Syntax}: 11167 1.1 mrg @multitable @columnfractions .80 11168 1.1 mrg @item @code{RESULT = NORM2(ARRAY[, DIM])} 11169 1.1 mrg @end multitable 11170 1.1 mrg 11171 1.1 mrg @item @emph{Arguments}: 11172 1.1 mrg @multitable @columnfractions .15 .70 11173 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{REAL} 11174 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type 11175 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n 11176 1.1 mrg equals the rank of @var{ARRAY}. 11177 1.1 mrg @end multitable 11178 1.1 mrg 11179 1.1 mrg @item @emph{Return value}: 11180 1.1 mrg The result is of the same type as @var{ARRAY}. 11181 1.1 mrg 11182 1.1 mrg If @var{DIM} is absent, a scalar with the square root of the sum of all 11183 1.1 mrg elements in @var{ARRAY} squared is returned. Otherwise, an array of 11184 1.1 mrg rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a 11185 1.1 mrg shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped 11186 1.1 mrg is returned. 11187 1.1 mrg 11188 1.1 mrg @item @emph{Example}: 11189 1.1 mrg @smallexample 11190 1.1 mrg PROGRAM test_sum 11191 1.1 mrg REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ] 11192 1.1 mrg print *, NORM2(x) ! = sqrt(55.) ~ 7.416 11193 1.1 mrg END PROGRAM 11194 1.1 mrg @end smallexample 11195 1.1 mrg @end table 11196 1.1 mrg 11197 1.1 mrg 11198 1.1 mrg 11199 1.1 mrg @node NOT 11200 1.1 mrg @section @code{NOT} --- Logical negation 11201 1.1 mrg @fnindex NOT 11202 1.1 mrg @fnindex BNOT 11203 1.1 mrg @fnindex INOT 11204 1.1 mrg @fnindex JNOT 11205 1.1 mrg @fnindex KNOT 11206 1.1 mrg @cindex bits, negate 11207 1.1 mrg @cindex bitwise logical not 11208 1.1 mrg @cindex logical not, bitwise 11209 1.1 mrg 11210 1.1 mrg @table @asis 11211 1.1 mrg @item @emph{Description}: 11212 1.1 mrg @code{NOT} returns the bitwise Boolean inverse of @var{I}. 11213 1.1 mrg 11214 1.1 mrg @item @emph{Standard}: 11215 1.1.1.2 mrg Fortran 90 and later, has overloads that are GNU extensions 11216 1.1 mrg 11217 1.1 mrg @item @emph{Class}: 11218 1.1 mrg Elemental function 11219 1.1 mrg 11220 1.1 mrg @item @emph{Syntax}: 11221 1.1 mrg @code{RESULT = NOT(I)} 11222 1.1 mrg 11223 1.1 mrg @item @emph{Arguments}: 11224 1.1 mrg @multitable @columnfractions .15 .70 11225 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 11226 1.1 mrg @end multitable 11227 1.1 mrg 11228 1.1 mrg @item @emph{Return value}: 11229 1.1 mrg The return type is @code{INTEGER}, of the same kind as the 11230 1.1 mrg argument. 11231 1.1 mrg 11232 1.1 mrg @item @emph{Specific names}: 11233 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 11234 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 11235 1.1 mrg @item @code{NOT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later 11236 1.1 mrg @item @code{BNOT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension 11237 1.1 mrg @item @code{INOT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension 11238 1.1 mrg @item @code{JNOT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension 11239 1.1 mrg @item @code{KNOT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension 11240 1.1 mrg @end multitable 11241 1.1 mrg 11242 1.1 mrg @item @emph{See also}: 11243 1.1.1.2 mrg @ref{IAND}, @gol 11244 1.1.1.2 mrg @ref{IEOR}, @gol 11245 1.1.1.2 mrg @ref{IOR}, @gol 11246 1.1.1.2 mrg @ref{IBITS}, @gol 11247 1.1.1.2 mrg @ref{IBSET}, @gol 11248 1.1.1.2 mrg @ref{IBCLR} 11249 1.1 mrg @end table 11250 1.1 mrg 11251 1.1 mrg 11252 1.1 mrg 11253 1.1 mrg @node NULL 11254 1.1 mrg @section @code{NULL} --- Function that returns an disassociated pointer 11255 1.1 mrg @fnindex NULL 11256 1.1 mrg @cindex pointer, status 11257 1.1 mrg @cindex pointer, disassociated 11258 1.1 mrg 11259 1.1 mrg @table @asis 11260 1.1 mrg @item @emph{Description}: 11261 1.1 mrg Returns a disassociated pointer. 11262 1.1 mrg 11263 1.1 mrg If @var{MOLD} is present, a disassociated pointer of the same type is 11264 1.1 mrg returned, otherwise the type is determined by context. 11265 1.1 mrg 11266 1.1 mrg In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003 11267 1.1 mrg includes cases where it is required. 11268 1.1 mrg 11269 1.1 mrg @item @emph{Standard}: 11270 1.1 mrg Fortran 95 and later 11271 1.1 mrg 11272 1.1 mrg @item @emph{Class}: 11273 1.1 mrg Transformational function 11274 1.1 mrg 11275 1.1 mrg @item @emph{Syntax}: 11276 1.1 mrg @code{PTR => NULL([MOLD])} 11277 1.1 mrg 11278 1.1 mrg @item @emph{Arguments}: 11279 1.1 mrg @multitable @columnfractions .15 .70 11280 1.1 mrg @item @var{MOLD} @tab (Optional) shall be a pointer of any association 11281 1.1 mrg status and of any type. 11282 1.1 mrg @end multitable 11283 1.1 mrg 11284 1.1 mrg @item @emph{Return value}: 11285 1.1 mrg A disassociated pointer. 11286 1.1 mrg 11287 1.1 mrg @item @emph{Example}: 11288 1.1 mrg @smallexample 11289 1.1 mrg REAL, POINTER, DIMENSION(:) :: VEC => NULL () 11290 1.1 mrg @end smallexample 11291 1.1 mrg 11292 1.1 mrg @item @emph{See also}: 11293 1.1 mrg @ref{ASSOCIATED} 11294 1.1 mrg @end table 11295 1.1 mrg 11296 1.1 mrg 11297 1.1 mrg 11298 1.1 mrg @node NUM_IMAGES 11299 1.1 mrg @section @code{NUM_IMAGES} --- Function that returns the number of images 11300 1.1 mrg @fnindex NUM_IMAGES 11301 1.1 mrg @cindex coarray, @code{NUM_IMAGES} 11302 1.1 mrg @cindex images, number of 11303 1.1 mrg 11304 1.1 mrg @table @asis 11305 1.1 mrg @item @emph{Description}: 11306 1.1 mrg Returns the number of images. 11307 1.1 mrg 11308 1.1 mrg @item @emph{Standard}: 11309 1.1 mrg Fortran 2008 and later. With @var{DISTANCE} or @var{FAILED} argument, 11310 1.1 mrg Technical Specification (TS) 18508 or later 11311 1.1 mrg 11312 1.1 mrg 11313 1.1 mrg @item @emph{Class}: 11314 1.1 mrg Transformational function 11315 1.1 mrg 11316 1.1 mrg @item @emph{Syntax}: 11317 1.1 mrg @code{RESULT = NUM_IMAGES(DISTANCE, FAILED)} 11318 1.1 mrg 11319 1.1 mrg @item @emph{Arguments}: 11320 1.1 mrg @multitable @columnfractions .15 .70 11321 1.1 mrg @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer 11322 1.1 mrg @item @var{FAILED} @tab (optional, intent(in)) Scalar logical expression 11323 1.1 mrg @end multitable 11324 1.1 mrg 11325 1.1 mrg @item @emph{Return value}: 11326 1.1 mrg Scalar default-kind integer. If @var{DISTANCE} is not present or has value 0, 11327 1.1 mrg the number of images in the current team is returned. For values smaller or 11328 1.1 mrg equal distance to the initial team, it returns the number of images index 11329 1.1 mrg on the ancestor team which has a distance of @var{DISTANCE} from the invoking 11330 1.1 mrg team. If @var{DISTANCE} is larger than the distance to the initial team, the 11331 1.1 mrg number of images of the initial team is returned. If @var{FAILED} is not present 11332 1.1 mrg the total number of images is returned; if it has the value @code{.TRUE.}, 11333 1.1 mrg the number of failed images is returned, otherwise, the number of images which 11334 1.1 mrg do have not the failed status. 11335 1.1 mrg 11336 1.1 mrg @item @emph{Example}: 11337 1.1 mrg @smallexample 11338 1.1 mrg INTEGER :: value[*] 11339 1.1 mrg INTEGER :: i 11340 1.1 mrg value = THIS_IMAGE() 11341 1.1 mrg SYNC ALL 11342 1.1 mrg IF (THIS_IMAGE() == 1) THEN 11343 1.1 mrg DO i = 1, NUM_IMAGES() 11344 1.1 mrg WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i] 11345 1.1 mrg END DO 11346 1.1 mrg END IF 11347 1.1 mrg @end smallexample 11348 1.1 mrg 11349 1.1 mrg @item @emph{See also}: 11350 1.1.1.2 mrg @ref{THIS_IMAGE}, @gol 11351 1.1.1.2 mrg @ref{IMAGE_INDEX} 11352 1.1 mrg @end table 11353 1.1 mrg 11354 1.1 mrg 11355 1.1 mrg 11356 1.1 mrg @node OR 11357 1.1 mrg @section @code{OR} --- Bitwise logical OR 11358 1.1 mrg @fnindex OR 11359 1.1 mrg @cindex bitwise logical or 11360 1.1 mrg @cindex logical or, bitwise 11361 1.1 mrg 11362 1.1 mrg @table @asis 11363 1.1 mrg @item @emph{Description}: 11364 1.1 mrg Bitwise logical @code{OR}. 11365 1.1 mrg 11366 1.1 mrg This intrinsic routine is provided for backwards compatibility with 11367 1.1 mrg GNU Fortran 77. For integer arguments, programmers should consider 11368 1.1 mrg the use of the @ref{IOR} intrinsic defined by the Fortran standard. 11369 1.1 mrg 11370 1.1 mrg @item @emph{Standard}: 11371 1.1 mrg GNU extension 11372 1.1 mrg 11373 1.1 mrg @item @emph{Class}: 11374 1.1 mrg Function 11375 1.1 mrg 11376 1.1 mrg @item @emph{Syntax}: 11377 1.1 mrg @code{RESULT = OR(I, J)} 11378 1.1 mrg 11379 1.1 mrg @item @emph{Arguments}: 11380 1.1 mrg @multitable @columnfractions .15 .70 11381 1.1 mrg @item @var{I} @tab The type shall be either a scalar @code{INTEGER} 11382 1.1 mrg type or a scalar @code{LOGICAL} type or a boz-literal-constant. 11383 1.1 mrg @item @var{J} @tab The type shall be the same as the type of @var{I} or 11384 1.1 mrg a boz-literal-constant. @var{I} and @var{J} shall not both be 11385 1.1 mrg boz-literal-constants. If either @var{I} and @var{J} is a 11386 1.1 mrg boz-literal-constant, then the other argument must be a scalar @code{INTEGER}. 11387 1.1 mrg @end multitable 11388 1.1 mrg 11389 1.1 mrg @item @emph{Return value}: 11390 1.1 mrg The return type is either a scalar @code{INTEGER} or a scalar 11391 1.1 mrg @code{LOGICAL}. If the kind type parameters differ, then the 11392 1.1 mrg smaller kind type is implicitly converted to larger kind, and the 11393 1.1 mrg return has the larger kind. A boz-literal-constant is 11394 1.1 mrg converted to an @code{INTEGER} with the kind type parameter of 11395 1.1 mrg the other argument as-if a call to @ref{INT} occurred. 11396 1.1 mrg 11397 1.1 mrg @item @emph{Example}: 11398 1.1 mrg @smallexample 11399 1.1 mrg PROGRAM test_or 11400 1.1 mrg LOGICAL :: T = .TRUE., F = .FALSE. 11401 1.1 mrg INTEGER :: a, b 11402 1.1 mrg DATA a / Z'F' /, b / Z'3' / 11403 1.1 mrg 11404 1.1 mrg WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F) 11405 1.1 mrg WRITE (*,*) OR(a, b) 11406 1.1 mrg END PROGRAM 11407 1.1 mrg @end smallexample 11408 1.1 mrg 11409 1.1 mrg @item @emph{See also}: 11410 1.1.1.2 mrg Fortran 95 elemental function: @gol 11411 1.1.1.2 mrg @ref{IOR} 11412 1.1 mrg @end table 11413 1.1 mrg 11414 1.1 mrg 11415 1.1 mrg 11416 1.1 mrg @node PACK 11417 1.1 mrg @section @code{PACK} --- Pack an array into an array of rank one 11418 1.1 mrg @fnindex PACK 11419 1.1 mrg @cindex array, packing 11420 1.1 mrg @cindex array, reduce dimension 11421 1.1 mrg @cindex array, gather elements 11422 1.1 mrg 11423 1.1 mrg @table @asis 11424 1.1 mrg @item @emph{Description}: 11425 1.1 mrg Stores the elements of @var{ARRAY} in an array of rank one. 11426 1.1 mrg 11427 1.1 mrg The beginning of the resulting array is made up of elements whose @var{MASK} 11428 1.1 mrg equals @code{TRUE}. Afterwards, positions are filled with elements taken from 11429 1.1 mrg @var{VECTOR}. 11430 1.1 mrg 11431 1.1 mrg @item @emph{Standard}: 11432 1.1.1.2 mrg Fortran 90 and later 11433 1.1 mrg 11434 1.1 mrg @item @emph{Class}: 11435 1.1 mrg Transformational function 11436 1.1 mrg 11437 1.1 mrg @item @emph{Syntax}: 11438 1.1 mrg @code{RESULT = PACK(ARRAY, MASK[,VECTOR])} 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{ARRAY} @tab Shall be an array of any type. 11443 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and 11444 1.1 mrg of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} 11445 1.1 mrg scalar. 11446 1.1 mrg @item @var{VECTOR} @tab (Optional) shall be an array of the same type 11447 1.1 mrg as @var{ARRAY} and of rank one. If present, the number of elements in 11448 1.1 mrg @var{VECTOR} shall be equal to or greater than the number of true elements 11449 1.1 mrg in @var{MASK}. If @var{MASK} is scalar, the number of elements in 11450 1.1 mrg @var{VECTOR} shall be equal to or greater than the number of elements in 11451 1.1 mrg @var{ARRAY}. 11452 1.1 mrg @end multitable 11453 1.1 mrg 11454 1.1 mrg @item @emph{Return value}: 11455 1.1 mrg The result is an array of rank one and the same type as that of @var{ARRAY}. 11456 1.1 mrg If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the 11457 1.1 mrg number of @code{TRUE} values in @var{MASK} otherwise. 11458 1.1 mrg 11459 1.1 mrg @item @emph{Example}: 11460 1.1 mrg Gathering nonzero elements from an array: 11461 1.1 mrg @smallexample 11462 1.1 mrg PROGRAM test_pack_1 11463 1.1 mrg INTEGER :: m(6) 11464 1.1 mrg m = (/ 1, 0, 0, 0, 5, 0 /) 11465 1.1 mrg WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5" 11466 1.1 mrg END PROGRAM 11467 1.1 mrg @end smallexample 11468 1.1 mrg 11469 1.1 mrg Gathering nonzero elements from an array and appending elements from @var{VECTOR}: 11470 1.1 mrg @smallexample 11471 1.1 mrg PROGRAM test_pack_2 11472 1.1 mrg INTEGER :: m(4) 11473 1.1 mrg m = (/ 1, 0, 0, 2 /) 11474 1.1.1.2 mrg ! The following results in "1 2 3 4" 11475 1.1.1.2 mrg WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) 11476 1.1 mrg END PROGRAM 11477 1.1 mrg @end smallexample 11478 1.1 mrg 11479 1.1 mrg @item @emph{See also}: 11480 1.1 mrg @ref{UNPACK} 11481 1.1 mrg @end table 11482 1.1 mrg 11483 1.1 mrg 11484 1.1 mrg 11485 1.1 mrg @node PARITY 11486 1.1 mrg @section @code{PARITY} --- Reduction with exclusive OR 11487 1.1 mrg @fnindex PARITY 11488 1.1 mrg @cindex Parity 11489 1.1 mrg @cindex Reduction, XOR 11490 1.1 mrg @cindex XOR reduction 11491 1.1 mrg 11492 1.1 mrg @table @asis 11493 1.1 mrg @item @emph{Description}: 11494 1.1 mrg Calculates the parity, i.e. the reduction using @code{.XOR.}, 11495 1.1 mrg of @var{MASK} along dimension @var{DIM}. 11496 1.1 mrg 11497 1.1 mrg @item @emph{Standard}: 11498 1.1 mrg Fortran 2008 and later 11499 1.1 mrg 11500 1.1 mrg @item @emph{Class}: 11501 1.1 mrg Transformational function 11502 1.1 mrg 11503 1.1 mrg @item @emph{Syntax}: 11504 1.1 mrg @multitable @columnfractions .80 11505 1.1 mrg @item @code{RESULT = PARITY(MASK[, DIM])} 11506 1.1 mrg @end multitable 11507 1.1 mrg 11508 1.1 mrg @item @emph{Arguments}: 11509 1.1 mrg @multitable @columnfractions .15 .70 11510 1.1.1.3 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} 11511 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type 11512 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n 11513 1.1 mrg equals the rank of @var{MASK}. 11514 1.1 mrg @end multitable 11515 1.1 mrg 11516 1.1 mrg @item @emph{Return value}: 11517 1.1 mrg The result is of the same type as @var{MASK}. 11518 1.1 mrg 11519 1.1 mrg If @var{DIM} is absent, a scalar with the parity of all elements in 11520 1.1 mrg @var{MASK} is returned, i.e. true if an odd number of elements is 11521 1.1 mrg @code{.true.} and false otherwise. If @var{DIM} is present, an array 11522 1.1 mrg of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, 11523 1.1 mrg and a shape similar to that of @var{MASK} with dimension @var{DIM} 11524 1.1 mrg dropped is returned. 11525 1.1 mrg 11526 1.1 mrg @item @emph{Example}: 11527 1.1 mrg @smallexample 11528 1.1 mrg PROGRAM test_sum 11529 1.1 mrg LOGICAL :: x(2) = [ .true., .false. ] 11530 1.1 mrg print *, PARITY(x) ! prints "T" (true). 11531 1.1 mrg END PROGRAM 11532 1.1 mrg @end smallexample 11533 1.1 mrg @end table 11534 1.1 mrg 11535 1.1 mrg 11536 1.1 mrg 11537 1.1 mrg @node PERROR 11538 1.1 mrg @section @code{PERROR} --- Print system error message 11539 1.1 mrg @fnindex PERROR 11540 1.1 mrg @cindex system, error handling 11541 1.1 mrg 11542 1.1 mrg @table @asis 11543 1.1 mrg @item @emph{Description}: 11544 1.1 mrg Prints (on the C @code{stderr} stream) a newline-terminated error 11545 1.1 mrg message corresponding to the last system error. This is prefixed by 11546 1.1 mrg @var{STRING}, a colon and a space. See @code{perror(3)}. 11547 1.1 mrg 11548 1.1 mrg @item @emph{Standard}: 11549 1.1 mrg GNU extension 11550 1.1 mrg 11551 1.1 mrg @item @emph{Class}: 11552 1.1 mrg Subroutine 11553 1.1 mrg 11554 1.1 mrg @item @emph{Syntax}: 11555 1.1 mrg @code{CALL PERROR(STRING)} 11556 1.1 mrg 11557 1.1 mrg @item @emph{Arguments}: 11558 1.1 mrg @multitable @columnfractions .15 .70 11559 1.1 mrg @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the 11560 1.1 mrg default kind. 11561 1.1 mrg @end multitable 11562 1.1 mrg 11563 1.1 mrg @item @emph{See also}: 11564 1.1 mrg @ref{IERRNO} 11565 1.1 mrg @end table 11566 1.1 mrg 11567 1.1 mrg 11568 1.1 mrg 11569 1.1 mrg @node POPCNT 11570 1.1 mrg @section @code{POPCNT} --- Number of bits set 11571 1.1 mrg @fnindex POPCNT 11572 1.1 mrg @cindex binary representation 11573 1.1 mrg @cindex bits set 11574 1.1 mrg 11575 1.1 mrg @table @asis 11576 1.1 mrg @item @emph{Description}: 11577 1.1 mrg @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary 11578 1.1 mrg representation of @code{I}. 11579 1.1 mrg 11580 1.1 mrg @item @emph{Standard}: 11581 1.1 mrg Fortran 2008 and later 11582 1.1 mrg 11583 1.1 mrg @item @emph{Class}: 11584 1.1 mrg Elemental function 11585 1.1 mrg 11586 1.1 mrg @item @emph{Syntax}: 11587 1.1 mrg @code{RESULT = POPCNT(I)} 11588 1.1 mrg 11589 1.1 mrg @item @emph{Arguments}: 11590 1.1 mrg @multitable @columnfractions .15 .70 11591 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}. 11592 1.1 mrg @end multitable 11593 1.1 mrg 11594 1.1 mrg @item @emph{Return value}: 11595 1.1 mrg The return value is of type @code{INTEGER} and of the default integer 11596 1.1 mrg kind. 11597 1.1 mrg 11598 1.1 mrg @item @emph{Example}: 11599 1.1 mrg @smallexample 11600 1.1 mrg program test_population 11601 1.1 mrg print *, popcnt(127), poppar(127) 11602 1.1 mrg print *, popcnt(huge(0_4)), poppar(huge(0_4)) 11603 1.1 mrg print *, popcnt(huge(0_8)), poppar(huge(0_8)) 11604 1.1 mrg end program test_population 11605 1.1 mrg @end smallexample 11606 1.1.1.2 mrg @item @emph{See also}: 11607 1.1.1.2 mrg @ref{POPPAR}, @gol 11608 1.1.1.2 mrg @ref{LEADZ}, @gol 11609 1.1.1.2 mrg @ref{TRAILZ} 11610 1.1 mrg @end table 11611 1.1 mrg 11612 1.1 mrg 11613 1.1.1.2 mrg 11614 1.1 mrg @node POPPAR 11615 1.1 mrg @section @code{POPPAR} --- Parity of the number of bits set 11616 1.1 mrg @fnindex POPPAR 11617 1.1 mrg @cindex binary representation 11618 1.1 mrg @cindex parity 11619 1.1 mrg 11620 1.1 mrg @table @asis 11621 1.1 mrg @item @emph{Description}: 11622 1.1 mrg @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity 11623 1.1 mrg of the number of bits set ('1' bits) in the binary representation of 11624 1.1 mrg @code{I}. It is equal to 0 if @code{I} has an even number of bits set, 11625 1.1 mrg and 1 for an odd number of '1' bits. 11626 1.1 mrg 11627 1.1 mrg @item @emph{Standard}: 11628 1.1 mrg Fortran 2008 and later 11629 1.1 mrg 11630 1.1 mrg @item @emph{Class}: 11631 1.1 mrg Elemental function 11632 1.1 mrg 11633 1.1 mrg @item @emph{Syntax}: 11634 1.1 mrg @code{RESULT = POPPAR(I)} 11635 1.1 mrg 11636 1.1 mrg @item @emph{Arguments}: 11637 1.1 mrg @multitable @columnfractions .15 .70 11638 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}. 11639 1.1 mrg @end multitable 11640 1.1 mrg 11641 1.1 mrg @item @emph{Return value}: 11642 1.1 mrg The return value is of type @code{INTEGER} and of the default integer 11643 1.1 mrg kind. 11644 1.1 mrg 11645 1.1 mrg @item @emph{Example}: 11646 1.1 mrg @smallexample 11647 1.1 mrg program test_population 11648 1.1 mrg print *, popcnt(127), poppar(127) 11649 1.1 mrg print *, popcnt(huge(0_4)), poppar(huge(0_4)) 11650 1.1 mrg print *, popcnt(huge(0_8)), poppar(huge(0_8)) 11651 1.1 mrg end program test_population 11652 1.1 mrg @end smallexample 11653 1.1.1.2 mrg @item @emph{See also}: 11654 1.1.1.2 mrg @ref{POPCNT}, @gol 11655 1.1.1.2 mrg @ref{LEADZ}, @gol 11656 1.1.1.2 mrg @ref{TRAILZ} 11657 1.1 mrg @end table 11658 1.1 mrg 11659 1.1 mrg 11660 1.1 mrg 11661 1.1 mrg @node PRECISION 11662 1.1 mrg @section @code{PRECISION} --- Decimal precision of a real kind 11663 1.1 mrg @fnindex PRECISION 11664 1.1 mrg @cindex model representation, precision 11665 1.1 mrg 11666 1.1 mrg @table @asis 11667 1.1 mrg @item @emph{Description}: 11668 1.1 mrg @code{PRECISION(X)} returns the decimal precision in the model of the 11669 1.1 mrg type of @code{X}. 11670 1.1 mrg 11671 1.1 mrg @item @emph{Standard}: 11672 1.1.1.2 mrg Fortran 90 and later 11673 1.1 mrg 11674 1.1 mrg @item @emph{Class}: 11675 1.1 mrg Inquiry function 11676 1.1 mrg 11677 1.1 mrg @item @emph{Syntax}: 11678 1.1 mrg @code{RESULT = PRECISION(X)} 11679 1.1 mrg 11680 1.1 mrg @item @emph{Arguments}: 11681 1.1 mrg @multitable @columnfractions .15 .70 11682 1.1.1.2 mrg @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}. It may 11683 1.1.1.2 mrg be scalar or valued. 11684 1.1 mrg @end multitable 11685 1.1 mrg 11686 1.1 mrg @item @emph{Return value}: 11687 1.1 mrg The return value is of type @code{INTEGER} and of the default integer 11688 1.1 mrg kind. 11689 1.1 mrg 11690 1.1 mrg @item @emph{Example}: 11691 1.1 mrg @smallexample 11692 1.1 mrg program prec_and_range 11693 1.1 mrg real(kind=4) :: x(2) 11694 1.1 mrg complex(kind=8) :: y 11695 1.1 mrg 11696 1.1 mrg print *, precision(x), range(x) 11697 1.1 mrg print *, precision(y), range(y) 11698 1.1 mrg end program prec_and_range 11699 1.1 mrg @end smallexample 11700 1.1.1.2 mrg @item @emph{See also}: 11701 1.1.1.2 mrg @ref{SELECTED_REAL_KIND}, @gol 11702 1.1.1.2 mrg @ref{RANGE} 11703 1.1 mrg @end table 11704 1.1 mrg 11705 1.1 mrg 11706 1.1 mrg 11707 1.1 mrg @node PRESENT 11708 1.1 mrg @section @code{PRESENT} --- Determine whether an optional dummy argument is specified 11709 1.1 mrg @fnindex PRESENT 11710 1.1 mrg 11711 1.1 mrg @table @asis 11712 1.1 mrg @item @emph{Description}: 11713 1.1 mrg Determines whether an optional dummy argument is present. 11714 1.1 mrg 11715 1.1 mrg @item @emph{Standard}: 11716 1.1.1.2 mrg Fortran 90 and later 11717 1.1 mrg 11718 1.1 mrg @item @emph{Class}: 11719 1.1 mrg Inquiry function 11720 1.1 mrg 11721 1.1 mrg @item @emph{Syntax}: 11722 1.1 mrg @code{RESULT = PRESENT(A)} 11723 1.1 mrg 11724 1.1 mrg @item @emph{Arguments}: 11725 1.1 mrg @multitable @columnfractions .15 .70 11726 1.1 mrg @item @var{A} @tab May be of any type and may be a pointer, scalar or array 11727 1.1 mrg value, or a dummy procedure. It shall be the name of an optional dummy argument 11728 1.1 mrg accessible within the current subroutine or function. 11729 1.1 mrg @end multitable 11730 1.1 mrg 11731 1.1 mrg @item @emph{Return value}: 11732 1.1 mrg Returns either @code{TRUE} if the optional argument @var{A} is present, or 11733 1.1 mrg @code{FALSE} otherwise. 11734 1.1 mrg 11735 1.1 mrg @item @emph{Example}: 11736 1.1 mrg @smallexample 11737 1.1 mrg PROGRAM test_present 11738 1.1 mrg WRITE(*,*) f(), f(42) ! "F T" 11739 1.1 mrg CONTAINS 11740 1.1 mrg LOGICAL FUNCTION f(x) 11741 1.1 mrg INTEGER, INTENT(IN), OPTIONAL :: x 11742 1.1 mrg f = PRESENT(x) 11743 1.1 mrg END FUNCTION 11744 1.1 mrg END PROGRAM 11745 1.1 mrg @end smallexample 11746 1.1 mrg @end table 11747 1.1 mrg 11748 1.1 mrg 11749 1.1 mrg 11750 1.1 mrg @node PRODUCT 11751 1.1 mrg @section @code{PRODUCT} --- Product of array elements 11752 1.1 mrg @fnindex PRODUCT 11753 1.1 mrg @cindex array, product 11754 1.1 mrg @cindex array, multiply elements 11755 1.1 mrg @cindex array, conditionally multiply elements 11756 1.1 mrg @cindex multiply array elements 11757 1.1 mrg 11758 1.1 mrg @table @asis 11759 1.1 mrg @item @emph{Description}: 11760 1.1 mrg Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if 11761 1.1 mrg the corresponding element in @var{MASK} is @code{TRUE}. 11762 1.1 mrg 11763 1.1 mrg @item @emph{Standard}: 11764 1.1.1.2 mrg Fortran 90 and later 11765 1.1 mrg 11766 1.1 mrg @item @emph{Class}: 11767 1.1 mrg Transformational function 11768 1.1 mrg 11769 1.1 mrg @item @emph{Syntax}: 11770 1.1 mrg @multitable @columnfractions .80 11771 1.1 mrg @item @code{RESULT = PRODUCT(ARRAY[, MASK])} 11772 1.1 mrg @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])} 11773 1.1 mrg @end multitable 11774 1.1 mrg 11775 1.1 mrg @item @emph{Arguments}: 11776 1.1 mrg @multitable @columnfractions .15 .70 11777 1.1 mrg @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 11778 1.1 mrg @code{REAL} or @code{COMPLEX}. 11779 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type 11780 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n 11781 1.1 mrg equals the rank of @var{ARRAY}. 11782 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} 11783 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}. 11784 1.1 mrg @end multitable 11785 1.1 mrg 11786 1.1 mrg @item @emph{Return value}: 11787 1.1 mrg The result is of the same type as @var{ARRAY}. 11788 1.1 mrg 11789 1.1 mrg If @var{DIM} is absent, a scalar with the product of all elements in 11790 1.1 mrg @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 11791 1.1 mrg the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 11792 1.1 mrg dimension @var{DIM} dropped is returned. 11793 1.1 mrg 11794 1.1 mrg 11795 1.1 mrg @item @emph{Example}: 11796 1.1 mrg @smallexample 11797 1.1 mrg PROGRAM test_product 11798 1.1 mrg INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /) 11799 1.1 mrg print *, PRODUCT(x) ! all elements, product = 120 11800 1.1 mrg print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15 11801 1.1 mrg END PROGRAM 11802 1.1 mrg @end smallexample 11803 1.1 mrg 11804 1.1 mrg @item @emph{See also}: 11805 1.1 mrg @ref{SUM} 11806 1.1 mrg @end table 11807 1.1 mrg 11808 1.1 mrg 11809 1.1 mrg 11810 1.1 mrg @node RADIX 11811 1.1 mrg @section @code{RADIX} --- Base of a model number 11812 1.1 mrg @fnindex RADIX 11813 1.1 mrg @cindex model representation, base 11814 1.1 mrg @cindex model representation, radix 11815 1.1 mrg 11816 1.1 mrg @table @asis 11817 1.1 mrg @item @emph{Description}: 11818 1.1 mrg @code{RADIX(X)} returns the base of the model representing the entity @var{X}. 11819 1.1 mrg 11820 1.1 mrg @item @emph{Standard}: 11821 1.1.1.2 mrg Fortran 90 and later 11822 1.1 mrg 11823 1.1 mrg @item @emph{Class}: 11824 1.1 mrg Inquiry function 11825 1.1 mrg 11826 1.1 mrg @item @emph{Syntax}: 11827 1.1 mrg @code{RESULT = RADIX(X)} 11828 1.1 mrg 11829 1.1 mrg @item @emph{Arguments}: 11830 1.1 mrg @multitable @columnfractions .15 .70 11831 1.1 mrg @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL} 11832 1.1 mrg @end multitable 11833 1.1 mrg 11834 1.1 mrg @item @emph{Return value}: 11835 1.1 mrg The return value is a scalar of type @code{INTEGER} and of the default 11836 1.1 mrg integer kind. 11837 1.1 mrg 11838 1.1 mrg @item @emph{Example}: 11839 1.1 mrg @smallexample 11840 1.1 mrg program test_radix 11841 1.1 mrg print *, "The radix for the default integer kind is", radix(0) 11842 1.1 mrg print *, "The radix for the default real kind is", radix(0.0) 11843 1.1 mrg end program test_radix 11844 1.1 mrg @end smallexample 11845 1.1.1.2 mrg @item @emph{See also}: 11846 1.1.1.2 mrg @ref{SELECTED_REAL_KIND} 11847 1.1 mrg @end table 11848 1.1 mrg 11849 1.1 mrg 11850 1.1 mrg 11851 1.1 mrg @node RAN 11852 1.1 mrg @section @code{RAN} --- Real pseudo-random number 11853 1.1 mrg @fnindex RAN 11854 1.1 mrg @cindex random number generation 11855 1.1 mrg 11856 1.1 mrg @table @asis 11857 1.1 mrg @item @emph{Description}: 11858 1.1 mrg For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is 11859 1.1 mrg provided as an alias for @code{RAND}. See @ref{RAND} for complete 11860 1.1 mrg documentation. 11861 1.1 mrg 11862 1.1 mrg @item @emph{Standard}: 11863 1.1 mrg GNU extension 11864 1.1 mrg 11865 1.1 mrg @item @emph{Class}: 11866 1.1 mrg Function 11867 1.1 mrg 11868 1.1 mrg @item @emph{See also}: 11869 1.1.1.2 mrg @ref{RAND}, @gol 11870 1.1.1.2 mrg @ref{RANDOM_NUMBER} 11871 1.1 mrg @end table 11872 1.1 mrg 11873 1.1 mrg 11874 1.1 mrg 11875 1.1 mrg @node RAND 11876 1.1 mrg @section @code{RAND} --- Real pseudo-random number 11877 1.1 mrg @fnindex RAND 11878 1.1 mrg @cindex random number generation 11879 1.1 mrg 11880 1.1 mrg @table @asis 11881 1.1 mrg @item @emph{Description}: 11882 1.1 mrg @code{RAND(FLAG)} returns a pseudo-random number from a uniform 11883 1.1 mrg distribution between 0 and 1. If @var{FLAG} is 0, the next number 11884 1.1 mrg in the current sequence is returned; if @var{FLAG} is 1, the generator 11885 1.1 mrg is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value, 11886 1.1 mrg it is used as a new seed with @code{SRAND}. 11887 1.1 mrg 11888 1.1 mrg This intrinsic routine is provided for backwards compatibility with 11889 1.1 mrg GNU Fortran 77. It implements a simple modulo generator as provided 11890 1.1 mrg by @command{g77}. For new code, one should consider the use of 11891 1.1 mrg @ref{RANDOM_NUMBER} as it implements a superior algorithm. 11892 1.1 mrg 11893 1.1 mrg @item @emph{Standard}: 11894 1.1 mrg GNU extension 11895 1.1 mrg 11896 1.1 mrg @item @emph{Class}: 11897 1.1 mrg Function 11898 1.1 mrg 11899 1.1 mrg @item @emph{Syntax}: 11900 1.1 mrg @code{RESULT = RAND(I)} 11901 1.1 mrg 11902 1.1 mrg @item @emph{Arguments}: 11903 1.1 mrg @multitable @columnfractions .15 .70 11904 1.1 mrg @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4. 11905 1.1 mrg @end multitable 11906 1.1 mrg 11907 1.1 mrg @item @emph{Return value}: 11908 1.1 mrg The return value is of @code{REAL} type and the default kind. 11909 1.1 mrg 11910 1.1 mrg @item @emph{Example}: 11911 1.1 mrg @smallexample 11912 1.1 mrg program test_rand 11913 1.1 mrg integer,parameter :: seed = 86456 11914 1.1 mrg 11915 1.1 mrg call srand(seed) 11916 1.1 mrg print *, rand(), rand(), rand(), rand() 11917 1.1 mrg print *, rand(seed), rand(), rand(), rand() 11918 1.1 mrg end program test_rand 11919 1.1 mrg @end smallexample 11920 1.1 mrg 11921 1.1 mrg @item @emph{See also}: 11922 1.1.1.2 mrg @ref{SRAND}, @gol 11923 1.1.1.2 mrg @ref{RANDOM_NUMBER} 11924 1.1 mrg 11925 1.1 mrg @end table 11926 1.1 mrg 11927 1.1 mrg 11928 1.1 mrg @node RANDOM_INIT 11929 1.1 mrg @section @code{RANDOM_INIT} --- Initialize a pseudo-random number generator 11930 1.1 mrg @fnindex RANDOM_INIT 11931 1.1 mrg @cindex random number generation, initialization 11932 1.1 mrg 11933 1.1 mrg @table @asis 11934 1.1 mrg @item @emph{Description}: 11935 1.1 mrg Initializes the state of the pseudorandom number generator used by 11936 1.1 mrg @code{RANDOM_NUMBER}. 11937 1.1 mrg 11938 1.1 mrg @item @emph{Standard}: 11939 1.1 mrg Fortran 2018 11940 1.1 mrg 11941 1.1 mrg @item @emph{Class}: 11942 1.1 mrg Subroutine 11943 1.1 mrg 11944 1.1 mrg @item @emph{Syntax}: 11945 1.1 mrg @code{CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)} 11946 1.1 mrg 11947 1.1 mrg @item @emph{Arguments}: 11948 1.1.1.2 mrg @multitable @columnfractions .25 .70 11949 1.1 mrg @item @var{REPEATABLE} @tab Shall be a scalar with a @code{LOGICAL} type, 11950 1.1 mrg and it is @code{INTENT(IN)}. If it is @code{.true.}, the seed is set to 11951 1.1 mrg a processor-dependent value that is the same each time @code{RANDOM_INIT} 11952 1.1 mrg is called from the same image. The term ``same image'' means a single 11953 1.1 mrg instance of program execution. The sequence of random numbers is different 11954 1.1 mrg for repeated execution of the program. If it is @code{.false.}, the seed 11955 1.1 mrg is set to a processor-dependent value. 11956 1.1 mrg @item @var{IMAGE_DISTINCT} @tab Shall be a scalar with a 11957 1.1 mrg @code{LOGICAL} type, and it is @code{INTENT(IN)}. If it is @code{.true.}, 11958 1.1 mrg the seed is set to a processor-dependent value that is distinct from th 11959 1.1 mrg seed set by a call to @code{RANDOM_INIT} in another image. If it is 11960 1.1.1.3 mrg @code{.false.}, the seed is set to a value that does depend which image called 11961 1.1 mrg @code{RANDOM_INIT}. 11962 1.1 mrg @end multitable 11963 1.1 mrg 11964 1.1 mrg @item @emph{Example}: 11965 1.1 mrg @smallexample 11966 1.1 mrg program test_random_seed 11967 1.1 mrg implicit none 11968 1.1 mrg real x(3), y(3) 11969 1.1 mrg call random_init(.true., .true.) 11970 1.1 mrg call random_number(x) 11971 1.1 mrg call random_init(.true., .true.) 11972 1.1 mrg call random_number(y) 11973 1.1 mrg ! x and y are the same sequence 11974 1.1 mrg if (any(x /= y)) call abort 11975 1.1 mrg end program test_random_seed 11976 1.1 mrg @end smallexample 11977 1.1 mrg 11978 1.1 mrg @item @emph{See also}: 11979 1.1.1.2 mrg @ref{RANDOM_NUMBER}, @gol 11980 1.1.1.2 mrg @ref{RANDOM_SEED} 11981 1.1 mrg @end table 11982 1.1 mrg 11983 1.1 mrg 11984 1.1 mrg @node RANDOM_NUMBER 11985 1.1 mrg @section @code{RANDOM_NUMBER} --- Pseudo-random number 11986 1.1 mrg @fnindex RANDOM_NUMBER 11987 1.1 mrg @cindex random number generation 11988 1.1 mrg 11989 1.1 mrg @table @asis 11990 1.1 mrg @item @emph{Description}: 11991 1.1 mrg Returns a single pseudorandom number or an array of pseudorandom numbers 11992 1.1 mrg from the uniform distribution over the range @math{ 0 \leq x < 1}. 11993 1.1 mrg 11994 1.1.1.2 mrg The runtime-library implements the xoshiro256** pseudorandom number 11995 1.1.1.2 mrg generator (PRNG). This generator has a period of @math{2^{256} - 1}, 11996 1.1.1.2 mrg and when using multiple threads up to @math{2^{128}} threads can each 11997 1.1.1.2 mrg generate @math{2^{128}} random numbers before any aliasing occurs. 11998 1.1 mrg 11999 1.1 mrg Note that in a multi-threaded program (e.g. using OpenMP directives), 12000 1.1 mrg each thread will have its own random number state. For details of the 12001 1.1 mrg seeding procedure, see the documentation for the @code{RANDOM_SEED} 12002 1.1 mrg intrinsic. 12003 1.1 mrg 12004 1.1 mrg 12005 1.1 mrg @item @emph{Standard}: 12006 1.1.1.2 mrg Fortran 90 and later 12007 1.1 mrg 12008 1.1 mrg @item @emph{Class}: 12009 1.1 mrg Subroutine 12010 1.1 mrg 12011 1.1 mrg @item @emph{Syntax}: 12012 1.1.1.3 mrg @code{CALL RANDOM_NUMBER(HARVEST)} 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{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}. 12017 1.1 mrg @end multitable 12018 1.1 mrg 12019 1.1 mrg @item @emph{Example}: 12020 1.1 mrg @smallexample 12021 1.1 mrg program test_random_number 12022 1.1 mrg REAL :: r(5,5) 12023 1.1 mrg CALL RANDOM_NUMBER(r) 12024 1.1 mrg end program 12025 1.1 mrg @end smallexample 12026 1.1 mrg 12027 1.1 mrg @item @emph{See also}: 12028 1.1.1.2 mrg @ref{RANDOM_SEED}, @gol 12029 1.1.1.2 mrg @ref{RANDOM_INIT} 12030 1.1 mrg @end table 12031 1.1 mrg 12032 1.1 mrg 12033 1.1 mrg 12034 1.1 mrg @node RANDOM_SEED 12035 1.1 mrg @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence 12036 1.1 mrg @fnindex RANDOM_SEED 12037 1.1 mrg @cindex random number generation, seeding 12038 1.1 mrg @cindex seeding a random number generator 12039 1.1 mrg 12040 1.1 mrg @table @asis 12041 1.1 mrg @item @emph{Description}: 12042 1.1 mrg Restarts or queries the state of the pseudorandom number generator used by 12043 1.1 mrg @code{RANDOM_NUMBER}. 12044 1.1 mrg 12045 1.1 mrg If @code{RANDOM_SEED} is called without arguments, it is seeded with 12046 1.1 mrg random data retrieved from the operating system. 12047 1.1 mrg 12048 1.1 mrg As an extension to the Fortran standard, the GFortran 12049 1.1 mrg @code{RANDOM_NUMBER} supports multiple threads. Each thread in a 12050 1.1 mrg multi-threaded program has its own seed. When @code{RANDOM_SEED} is 12051 1.1 mrg called either without arguments or with the @var{PUT} argument, the 12052 1.1 mrg given seed is copied into a master seed as well as the seed of the 12053 1.1 mrg current thread. When a new thread uses @code{RANDOM_NUMBER} for the 12054 1.1 mrg first time, the seed is copied from the master seed, and forwarded 12055 1.1.1.2 mrg @math{N * 2^{128}} steps to guarantee that the random stream does not 12056 1.1 mrg alias any other stream in the system, where @var{N} is the number of 12057 1.1 mrg threads that have used @code{RANDOM_NUMBER} so far during the program 12058 1.1 mrg execution. 12059 1.1 mrg 12060 1.1 mrg @item @emph{Standard}: 12061 1.1.1.2 mrg Fortran 90 and later 12062 1.1 mrg 12063 1.1 mrg @item @emph{Class}: 12064 1.1 mrg Subroutine 12065 1.1 mrg 12066 1.1 mrg @item @emph{Syntax}: 12067 1.1 mrg @code{CALL RANDOM_SEED([SIZE, PUT, GET])} 12068 1.1 mrg 12069 1.1 mrg @item @emph{Arguments}: 12070 1.1 mrg @multitable @columnfractions .15 .70 12071 1.1 mrg @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default 12072 1.1 mrg @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size 12073 1.1 mrg of the arrays used with the @var{PUT} and @var{GET} arguments. 12074 1.1 mrg @item @var{PUT} @tab (Optional) Shall be an array of type default 12075 1.1 mrg @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of 12076 1.1 mrg the array must be larger than or equal to the number returned by the 12077 1.1 mrg @var{SIZE} argument. 12078 1.1 mrg @item @var{GET} @tab (Optional) Shall be an array of type default 12079 1.1 mrg @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size 12080 1.1 mrg of the array must be larger than or equal to the number returned by 12081 1.1 mrg the @var{SIZE} argument. 12082 1.1 mrg @end multitable 12083 1.1 mrg 12084 1.1 mrg @item @emph{Example}: 12085 1.1 mrg @smallexample 12086 1.1 mrg program test_random_seed 12087 1.1 mrg implicit none 12088 1.1 mrg integer, allocatable :: seed(:) 12089 1.1 mrg integer :: n 12090 1.1 mrg 12091 1.1 mrg call random_seed(size = n) 12092 1.1 mrg allocate(seed(n)) 12093 1.1 mrg call random_seed(get=seed) 12094 1.1 mrg write (*, *) seed 12095 1.1 mrg end program test_random_seed 12096 1.1 mrg @end smallexample 12097 1.1 mrg 12098 1.1 mrg @item @emph{See also}: 12099 1.1.1.2 mrg @ref{RANDOM_NUMBER}, @gol 12100 1.1.1.2 mrg @ref{RANDOM_INIT} 12101 1.1 mrg @end table 12102 1.1 mrg 12103 1.1 mrg 12104 1.1 mrg 12105 1.1 mrg @node RANGE 12106 1.1 mrg @section @code{RANGE} --- Decimal exponent range 12107 1.1 mrg @fnindex RANGE 12108 1.1 mrg @cindex model representation, range 12109 1.1 mrg 12110 1.1 mrg @table @asis 12111 1.1 mrg @item @emph{Description}: 12112 1.1 mrg @code{RANGE(X)} returns the decimal exponent range in the model of the 12113 1.1 mrg type of @code{X}. 12114 1.1 mrg 12115 1.1 mrg @item @emph{Standard}: 12116 1.1.1.2 mrg Fortran 90 and later 12117 1.1 mrg 12118 1.1 mrg @item @emph{Class}: 12119 1.1 mrg Inquiry function 12120 1.1 mrg 12121 1.1 mrg @item @emph{Syntax}: 12122 1.1 mrg @code{RESULT = RANGE(X)} 12123 1.1 mrg 12124 1.1 mrg @item @emph{Arguments}: 12125 1.1 mrg @multitable @columnfractions .15 .70 12126 1.1 mrg @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL} 12127 1.1 mrg or @code{COMPLEX}. 12128 1.1 mrg @end multitable 12129 1.1 mrg 12130 1.1 mrg @item @emph{Return value}: 12131 1.1 mrg The return value is of type @code{INTEGER} and of the default integer 12132 1.1 mrg kind. 12133 1.1 mrg 12134 1.1 mrg @item @emph{Example}: 12135 1.1 mrg See @code{PRECISION} for an example. 12136 1.1.1.2 mrg @item @emph{See also}: 12137 1.1.1.2 mrg @ref{SELECTED_REAL_KIND}, @gol 12138 1.1.1.2 mrg @ref{PRECISION} 12139 1.1 mrg @end table 12140 1.1 mrg 12141 1.1 mrg 12142 1.1 mrg 12143 1.1 mrg @node RANK 12144 1.1 mrg @section @code{RANK} --- Rank of a data object 12145 1.1 mrg @fnindex RANK 12146 1.1 mrg @cindex rank 12147 1.1 mrg 12148 1.1 mrg @table @asis 12149 1.1 mrg @item @emph{Description}: 12150 1.1 mrg @code{RANK(A)} returns the rank of a scalar or array data object. 12151 1.1 mrg 12152 1.1 mrg @item @emph{Standard}: 12153 1.1 mrg Technical Specification (TS) 29113 12154 1.1 mrg 12155 1.1 mrg @item @emph{Class}: 12156 1.1 mrg Inquiry function 12157 1.1 mrg 12158 1.1 mrg @item @emph{Syntax}: 12159 1.1 mrg @code{RESULT = RANK(A)} 12160 1.1 mrg 12161 1.1 mrg @item @emph{Arguments}: 12162 1.1 mrg @multitable @columnfractions .15 .70 12163 1.1 mrg @item @var{A} @tab can be of any type 12164 1.1 mrg @end multitable 12165 1.1 mrg 12166 1.1 mrg @item @emph{Return value}: 12167 1.1 mrg The return value is of type @code{INTEGER} and of the default integer 12168 1.1 mrg kind. For arrays, their rank is returned; for scalars zero is returned. 12169 1.1 mrg 12170 1.1 mrg @item @emph{Example}: 12171 1.1 mrg @smallexample 12172 1.1 mrg program test_rank 12173 1.1 mrg integer :: a 12174 1.1 mrg real, allocatable :: b(:,:) 12175 1.1 mrg 12176 1.1 mrg print *, rank(a), rank(b) ! Prints: 0 2 12177 1.1 mrg end program test_rank 12178 1.1 mrg @end smallexample 12179 1.1 mrg 12180 1.1 mrg @end table 12181 1.1 mrg 12182 1.1 mrg 12183 1.1 mrg 12184 1.1 mrg @node REAL 12185 1.1 mrg @section @code{REAL} --- Convert to real type 12186 1.1 mrg @fnindex REAL 12187 1.1 mrg @fnindex REALPART 12188 1.1 mrg @fnindex FLOAT 12189 1.1 mrg @fnindex DFLOAT 12190 1.1 mrg @fnindex FLOATI 12191 1.1 mrg @fnindex FLOATJ 12192 1.1 mrg @fnindex FLOATK 12193 1.1 mrg @fnindex SNGL 12194 1.1 mrg @cindex conversion, to real 12195 1.1 mrg @cindex complex numbers, real part 12196 1.1 mrg 12197 1.1 mrg @table @asis 12198 1.1 mrg @item @emph{Description}: 12199 1.1 mrg @code{REAL(A [, KIND])} converts its argument @var{A} to a real type. The 12200 1.1 mrg @code{REALPART} function is provided for compatibility with @command{g77}, 12201 1.1 mrg and its use is strongly discouraged. 12202 1.1 mrg 12203 1.1 mrg @item @emph{Standard}: 12204 1.1.1.2 mrg Fortran 77 and later, with @var{KIND} argument Fortran 90 and later, has GNU extensions 12205 1.1 mrg 12206 1.1 mrg @item @emph{Class}: 12207 1.1 mrg Elemental function 12208 1.1 mrg 12209 1.1 mrg @item @emph{Syntax}: 12210 1.1 mrg @multitable @columnfractions .80 12211 1.1 mrg @item @code{RESULT = REAL(A [, KIND])} 12212 1.1 mrg @item @code{RESULT = REALPART(Z)} 12213 1.1 mrg @end multitable 12214 1.1 mrg 12215 1.1 mrg @item @emph{Arguments}: 12216 1.1 mrg @multitable @columnfractions .15 .70 12217 1.1 mrg @item @var{A} @tab Shall be @code{INTEGER}, @code{REAL}, or 12218 1.1 mrg @code{COMPLEX}. 12219 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 12220 1.1 mrg expression indicating the kind parameter of the result. 12221 1.1 mrg @end multitable 12222 1.1 mrg 12223 1.1 mrg @item @emph{Return value}: 12224 1.1 mrg These functions return a @code{REAL} variable or array under 12225 1.1 mrg the following rules: 12226 1.1 mrg 12227 1.1 mrg @table @asis 12228 1.1 mrg @item (A) 12229 1.1 mrg @code{REAL(A)} is converted to a default real type if @var{A} is an 12230 1.1 mrg integer or real variable. 12231 1.1 mrg @item (B) 12232 1.1 mrg @code{REAL(A)} is converted to a real type with the kind type parameter 12233 1.1 mrg of @var{A} if @var{A} is a complex variable. 12234 1.1 mrg @item (C) 12235 1.1 mrg @code{REAL(A, KIND)} is converted to a real type with kind type 12236 1.1 mrg parameter @var{KIND} if @var{A} is a complex, integer, or real 12237 1.1 mrg variable. 12238 1.1 mrg @end table 12239 1.1 mrg 12240 1.1 mrg @item @emph{Example}: 12241 1.1 mrg @smallexample 12242 1.1 mrg program test_real 12243 1.1 mrg complex :: x = (1.0, 2.0) 12244 1.1 mrg print *, real(x), real(x,8), realpart(x) 12245 1.1 mrg end program test_real 12246 1.1 mrg @end smallexample 12247 1.1 mrg 12248 1.1 mrg @item @emph{Specific names}: 12249 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 12250 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 12251 1.1.1.3 mrg @item @code{FLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab Fortran 77 and later 12252 1.1 mrg @item @code{DFLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(8)} @tab GNU extension 12253 1.1.1.3 mrg @item @code{FLOATI(A)} @tab @code{INTEGER(2)} @tab @code{REAL(4)} @tab GNU extension (-fdec) 12254 1.1.1.3 mrg @item @code{FLOATJ(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab GNU extension (-fdec) 12255 1.1.1.3 mrg @item @code{FLOATK(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab GNU extension (-fdec) 12256 1.1.1.3 mrg @item @code{SNGL(A)} @tab @code{REAL(8)} @tab @code{REAL(4)} @tab Fortran 77 and later 12257 1.1 mrg @end multitable 12258 1.1 mrg 12259 1.1 mrg 12260 1.1 mrg @item @emph{See also}: 12261 1.1 mrg @ref{DBLE} 12262 1.1 mrg 12263 1.1 mrg @end table 12264 1.1 mrg 12265 1.1 mrg 12266 1.1 mrg 12267 1.1 mrg @node RENAME 12268 1.1 mrg @section @code{RENAME} --- Rename a file 12269 1.1 mrg @fnindex RENAME 12270 1.1 mrg @cindex file system, rename file 12271 1.1 mrg 12272 1.1 mrg @table @asis 12273 1.1 mrg @item @emph{Description}: 12274 1.1 mrg Renames a file from file @var{PATH1} to @var{PATH2}. A null 12275 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in 12276 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file 12277 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it 12278 1.1 mrg contains 0 on success or a nonzero error code upon return; see 12279 1.1 mrg @code{rename(2)}. 12280 1.1 mrg 12281 1.1 mrg This intrinsic is provided in both subroutine and function forms; 12282 1.1 mrg however, only one form can be used in any given program unit. 12283 1.1 mrg 12284 1.1 mrg @item @emph{Standard}: 12285 1.1 mrg GNU extension 12286 1.1 mrg 12287 1.1 mrg @item @emph{Class}: 12288 1.1 mrg Subroutine, function 12289 1.1 mrg 12290 1.1 mrg @item @emph{Syntax}: 12291 1.1 mrg @multitable @columnfractions .80 12292 1.1 mrg @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])} 12293 1.1 mrg @item @code{STATUS = RENAME(PATH1, PATH2)} 12294 1.1 mrg @end multitable 12295 1.1 mrg 12296 1.1 mrg @item @emph{Arguments}: 12297 1.1 mrg @multitable @columnfractions .15 .70 12298 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type. 12299 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type. 12300 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. 12301 1.1 mrg @end multitable 12302 1.1 mrg 12303 1.1 mrg @item @emph{See also}: 12304 1.1 mrg @ref{LINK} 12305 1.1 mrg 12306 1.1 mrg @end table 12307 1.1 mrg 12308 1.1 mrg 12309 1.1 mrg 12310 1.1 mrg @node REPEAT 12311 1.1 mrg @section @code{REPEAT} --- Repeated string concatenation 12312 1.1 mrg @fnindex REPEAT 12313 1.1 mrg @cindex string, repeat 12314 1.1 mrg @cindex string, concatenate 12315 1.1 mrg 12316 1.1 mrg @table @asis 12317 1.1 mrg @item @emph{Description}: 12318 1.1 mrg Concatenates @var{NCOPIES} copies of a string. 12319 1.1 mrg 12320 1.1 mrg @item @emph{Standard}: 12321 1.1.1.2 mrg Fortran 90 and later 12322 1.1 mrg 12323 1.1 mrg @item @emph{Class}: 12324 1.1 mrg Transformational function 12325 1.1 mrg 12326 1.1 mrg @item @emph{Syntax}: 12327 1.1 mrg @code{RESULT = REPEAT(STRING, NCOPIES)} 12328 1.1 mrg 12329 1.1 mrg @item @emph{Arguments}: 12330 1.1 mrg @multitable @columnfractions .15 .70 12331 1.1 mrg @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}. 12332 1.1 mrg @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}. 12333 1.1 mrg @end multitable 12334 1.1 mrg 12335 1.1 mrg @item @emph{Return value}: 12336 1.1 mrg A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies 12337 1.1 mrg of @var{STRING}. 12338 1.1 mrg 12339 1.1 mrg @item @emph{Example}: 12340 1.1 mrg @smallexample 12341 1.1 mrg program test_repeat 12342 1.1 mrg write(*,*) repeat("x", 5) ! "xxxxx" 12343 1.1 mrg end program 12344 1.1 mrg @end smallexample 12345 1.1 mrg @end table 12346 1.1 mrg 12347 1.1 mrg 12348 1.1 mrg 12349 1.1 mrg @node RESHAPE 12350 1.1 mrg @section @code{RESHAPE} --- Function to reshape an array 12351 1.1 mrg @fnindex RESHAPE 12352 1.1 mrg @cindex array, change dimensions 12353 1.1 mrg @cindex array, transmogrify 12354 1.1 mrg 12355 1.1 mrg @table @asis 12356 1.1 mrg @item @emph{Description}: 12357 1.1 mrg Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary, 12358 1.1 mrg the new array may be padded with elements from @var{PAD} or permuted 12359 1.1 mrg as defined by @var{ORDER}. 12360 1.1 mrg 12361 1.1 mrg @item @emph{Standard}: 12362 1.1.1.2 mrg Fortran 90 and later 12363 1.1 mrg 12364 1.1 mrg @item @emph{Class}: 12365 1.1 mrg Transformational function 12366 1.1 mrg 12367 1.1 mrg @item @emph{Syntax}: 12368 1.1 mrg @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])} 12369 1.1 mrg 12370 1.1 mrg @item @emph{Arguments}: 12371 1.1 mrg @multitable @columnfractions .15 .70 12372 1.1 mrg @item @var{SOURCE} @tab Shall be an array of any type. 12373 1.1 mrg @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an 12374 1.1 mrg array of rank one. Its values must be positive or zero. 12375 1.1 mrg @item @var{PAD} @tab (Optional) shall be an array of the same 12376 1.1 mrg type as @var{SOURCE}. 12377 1.1 mrg @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER} 12378 1.1 mrg and an array of the same shape as @var{SHAPE}. Its values shall 12379 1.1 mrg be a permutation of the numbers from 1 to n, where n is the size of 12380 1.1 mrg @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall 12381 1.1 mrg be assumed. 12382 1.1 mrg @end multitable 12383 1.1 mrg 12384 1.1 mrg @item @emph{Return value}: 12385 1.1 mrg The result is an array of shape @var{SHAPE} with the same type as 12386 1.1 mrg @var{SOURCE}. 12387 1.1 mrg 12388 1.1 mrg @item @emph{Example}: 12389 1.1 mrg @smallexample 12390 1.1 mrg PROGRAM test_reshape 12391 1.1 mrg INTEGER, DIMENSION(4) :: x 12392 1.1 mrg WRITE(*,*) SHAPE(x) ! prints "4" 12393 1.1 mrg WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2" 12394 1.1 mrg END PROGRAM 12395 1.1 mrg @end smallexample 12396 1.1 mrg 12397 1.1 mrg @item @emph{See also}: 12398 1.1 mrg @ref{SHAPE} 12399 1.1 mrg @end table 12400 1.1 mrg 12401 1.1 mrg 12402 1.1 mrg 12403 1.1 mrg @node RRSPACING 12404 1.1 mrg @section @code{RRSPACING} --- Reciprocal of the relative spacing 12405 1.1 mrg @fnindex RRSPACING 12406 1.1 mrg @cindex real number, relative spacing 12407 1.1 mrg @cindex floating point, relative spacing 12408 1.1 mrg 12409 1.1 mrg 12410 1.1 mrg @table @asis 12411 1.1 mrg @item @emph{Description}: 12412 1.1 mrg @code{RRSPACING(X)} returns the reciprocal of the relative spacing of 12413 1.1 mrg model numbers near @var{X}. 12414 1.1 mrg 12415 1.1 mrg @item @emph{Standard}: 12416 1.1.1.2 mrg Fortran 90 and later 12417 1.1 mrg 12418 1.1 mrg @item @emph{Class}: 12419 1.1 mrg Elemental function 12420 1.1 mrg 12421 1.1 mrg @item @emph{Syntax}: 12422 1.1 mrg @code{RESULT = RRSPACING(X)} 12423 1.1 mrg 12424 1.1 mrg @item @emph{Arguments}: 12425 1.1 mrg @multitable @columnfractions .15 .70 12426 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}. 12427 1.1 mrg @end multitable 12428 1.1 mrg 12429 1.1 mrg @item @emph{Return value}: 12430 1.1 mrg The return value is of the same type and kind as @var{X}. 12431 1.1 mrg The value returned is equal to 12432 1.1 mrg @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}. 12433 1.1 mrg 12434 1.1 mrg @item @emph{See also}: 12435 1.1 mrg @ref{SPACING} 12436 1.1 mrg @end table 12437 1.1 mrg 12438 1.1 mrg 12439 1.1 mrg 12440 1.1 mrg @node RSHIFT 12441 1.1 mrg @section @code{RSHIFT} --- Right shift bits 12442 1.1 mrg @fnindex RSHIFT 12443 1.1 mrg @cindex bits, shift right 12444 1.1 mrg 12445 1.1 mrg @table @asis 12446 1.1 mrg @item @emph{Description}: 12447 1.1 mrg @code{RSHIFT} returns a value corresponding to @var{I} with all of the 12448 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be 12449 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise 12450 1.1 mrg the result value is undefined. Bits shifted out from the right end 12451 1.1 mrg are lost. The fill is arithmetic: the bits shifted in from the left 12452 1.1 mrg end are equal to the leftmost bit, which in two's complement 12453 1.1 mrg representation is the sign bit. 12454 1.1 mrg 12455 1.1 mrg This function has been superseded by the @code{SHIFTA} intrinsic, which 12456 1.1 mrg is standard in Fortran 2008 and later. 12457 1.1 mrg 12458 1.1 mrg @item @emph{Standard}: 12459 1.1 mrg GNU extension 12460 1.1 mrg 12461 1.1 mrg @item @emph{Class}: 12462 1.1 mrg Elemental function 12463 1.1 mrg 12464 1.1 mrg @item @emph{Syntax}: 12465 1.1 mrg @code{RESULT = RSHIFT(I, SHIFT)} 12466 1.1 mrg 12467 1.1 mrg @item @emph{Arguments}: 12468 1.1 mrg @multitable @columnfractions .15 .70 12469 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 12470 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 12471 1.1 mrg @end multitable 12472 1.1 mrg 12473 1.1 mrg @item @emph{Return value}: 12474 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 12475 1.1 mrg @var{I}. 12476 1.1 mrg 12477 1.1 mrg @item @emph{See also}: 12478 1.1.1.2 mrg @ref{ISHFT}, @gol 12479 1.1.1.2 mrg @ref{ISHFTC}, @gol 12480 1.1.1.2 mrg @ref{LSHIFT}, @gol 12481 1.1.1.2 mrg @ref{SHIFTA}, @gol 12482 1.1.1.2 mrg @ref{SHIFTR}, @gol 12483 1.1 mrg @ref{SHIFTL} 12484 1.1 mrg 12485 1.1 mrg @end table 12486 1.1 mrg 12487 1.1 mrg 12488 1.1 mrg 12489 1.1 mrg @node SAME_TYPE_AS 12490 1.1 mrg @section @code{SAME_TYPE_AS} --- Query dynamic types for equality 12491 1.1 mrg @fnindex SAME_TYPE_AS 12492 1.1 mrg 12493 1.1 mrg @table @asis 12494 1.1 mrg @item @emph{Description}: 12495 1.1 mrg Query dynamic types for equality. 12496 1.1 mrg 12497 1.1 mrg @item @emph{Standard}: 12498 1.1 mrg Fortran 2003 and later 12499 1.1 mrg 12500 1.1 mrg @item @emph{Class}: 12501 1.1 mrg Inquiry function 12502 1.1 mrg 12503 1.1 mrg @item @emph{Syntax}: 12504 1.1 mrg @code{RESULT = SAME_TYPE_AS(A, B)} 12505 1.1 mrg 12506 1.1 mrg @item @emph{Arguments}: 12507 1.1 mrg @multitable @columnfractions .15 .70 12508 1.1 mrg @item @var{A} @tab Shall be an object of extensible declared type or 12509 1.1 mrg unlimited polymorphic. 12510 1.1 mrg @item @var{B} @tab Shall be an object of extensible declared type or 12511 1.1 mrg unlimited polymorphic. 12512 1.1 mrg @end multitable 12513 1.1 mrg 12514 1.1 mrg @item @emph{Return value}: 12515 1.1 mrg The return value is a scalar of type default logical. It is true if and 12516 1.1 mrg only if the dynamic type of A is the same as the dynamic type of B. 12517 1.1 mrg 12518 1.1 mrg @item @emph{See also}: 12519 1.1 mrg @ref{EXTENDS_TYPE_OF} 12520 1.1 mrg 12521 1.1 mrg @end table 12522 1.1 mrg 12523 1.1 mrg 12524 1.1 mrg 12525 1.1 mrg @node SCALE 12526 1.1 mrg @section @code{SCALE} --- Scale a real value 12527 1.1 mrg @fnindex SCALE 12528 1.1 mrg @cindex real number, scale 12529 1.1 mrg @cindex floating point, scale 12530 1.1 mrg 12531 1.1 mrg @table @asis 12532 1.1 mrg @item @emph{Description}: 12533 1.1 mrg @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}. 12534 1.1 mrg 12535 1.1 mrg @item @emph{Standard}: 12536 1.1.1.2 mrg Fortran 90 and later 12537 1.1 mrg 12538 1.1 mrg @item @emph{Class}: 12539 1.1 mrg Elemental function 12540 1.1 mrg 12541 1.1 mrg @item @emph{Syntax}: 12542 1.1 mrg @code{RESULT = SCALE(X, I)} 12543 1.1 mrg 12544 1.1 mrg @item @emph{Arguments}: 12545 1.1 mrg @multitable @columnfractions .15 .70 12546 1.1 mrg @item @var{X} @tab The type of the argument shall be a @code{REAL}. 12547 1.1 mrg @item @var{I} @tab The type of the argument shall be a @code{INTEGER}. 12548 1.1 mrg @end multitable 12549 1.1 mrg 12550 1.1 mrg @item @emph{Return value}: 12551 1.1 mrg The return value is of the same type and kind as @var{X}. 12552 1.1 mrg Its value is @code{X * RADIX(X)**I}. 12553 1.1 mrg 12554 1.1 mrg @item @emph{Example}: 12555 1.1 mrg @smallexample 12556 1.1 mrg program test_scale 12557 1.1 mrg real :: x = 178.1387e-4 12558 1.1 mrg integer :: i = 5 12559 1.1 mrg print *, scale(x,i), x*radix(x)**i 12560 1.1 mrg end program test_scale 12561 1.1 mrg @end smallexample 12562 1.1 mrg 12563 1.1 mrg @end table 12564 1.1 mrg 12565 1.1 mrg 12566 1.1 mrg 12567 1.1 mrg @node SCAN 12568 1.1 mrg @section @code{SCAN} --- Scan a string for the presence of a set of characters 12569 1.1 mrg @fnindex SCAN 12570 1.1 mrg @cindex string, find subset 12571 1.1 mrg 12572 1.1 mrg @table @asis 12573 1.1 mrg @item @emph{Description}: 12574 1.1 mrg Scans a @var{STRING} for any of the characters in a @var{SET} 12575 1.1 mrg of characters. 12576 1.1 mrg 12577 1.1 mrg If @var{BACK} is either absent or equals @code{FALSE}, this function 12578 1.1 mrg returns the position of the leftmost character of @var{STRING} that is 12579 1.1 mrg in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position 12580 1.1 mrg is returned. If no character of @var{SET} is found in @var{STRING}, the 12581 1.1 mrg result is zero. 12582 1.1 mrg 12583 1.1 mrg @item @emph{Standard}: 12584 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later 12585 1.1 mrg 12586 1.1 mrg @item @emph{Class}: 12587 1.1 mrg Elemental function 12588 1.1 mrg 12589 1.1 mrg @item @emph{Syntax}: 12590 1.1 mrg @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])} 12591 1.1 mrg 12592 1.1 mrg @item @emph{Arguments}: 12593 1.1 mrg @multitable @columnfractions .15 .70 12594 1.1 mrg @item @var{STRING} @tab Shall be of type @code{CHARACTER}. 12595 1.1 mrg @item @var{SET} @tab Shall be of type @code{CHARACTER}. 12596 1.1 mrg @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}. 12597 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 12598 1.1 mrg expression indicating the kind parameter of the result. 12599 1.1 mrg @end multitable 12600 1.1 mrg 12601 1.1 mrg @item @emph{Return value}: 12602 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 12603 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 12604 1.1 mrg 12605 1.1 mrg @item @emph{Example}: 12606 1.1 mrg @smallexample 12607 1.1 mrg PROGRAM test_scan 12608 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O' 12609 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A' 12610 1.1 mrg WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none 12611 1.1 mrg END PROGRAM 12612 1.1 mrg @end smallexample 12613 1.1 mrg 12614 1.1 mrg @item @emph{See also}: 12615 1.1.1.2 mrg @ref{INDEX intrinsic}, @gol 12616 1.1.1.2 mrg @ref{VERIFY} 12617 1.1 mrg @end table 12618 1.1 mrg 12619 1.1 mrg 12620 1.1 mrg 12621 1.1 mrg @node SECNDS 12622 1.1 mrg @section @code{SECNDS} --- Time function 12623 1.1 mrg @fnindex SECNDS 12624 1.1 mrg @cindex time, elapsed 12625 1.1 mrg @cindex elapsed time 12626 1.1 mrg 12627 1.1 mrg @table @asis 12628 1.1 mrg @item @emph{Description}: 12629 1.1 mrg @code{SECNDS(X)} gets the time in seconds from the real-time system clock. 12630 1.1 mrg @var{X} is a reference time, also in seconds. If this is zero, the time in 12631 1.1 mrg seconds from midnight is returned. This function is non-standard and its 12632 1.1 mrg use is discouraged. 12633 1.1 mrg 12634 1.1 mrg @item @emph{Standard}: 12635 1.1 mrg GNU extension 12636 1.1 mrg 12637 1.1 mrg @item @emph{Class}: 12638 1.1 mrg Function 12639 1.1 mrg 12640 1.1 mrg @item @emph{Syntax}: 12641 1.1 mrg @code{RESULT = SECNDS (X)} 12642 1.1 mrg 12643 1.1 mrg @item @emph{Arguments}: 12644 1.1 mrg @multitable @columnfractions .15 .70 12645 1.1 mrg @item @var{T} @tab Shall be of type @code{REAL(4)}. 12646 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL(4)}. 12647 1.1 mrg @end multitable 12648 1.1 mrg 12649 1.1 mrg @item @emph{Return value}: 12650 1.1 mrg None 12651 1.1 mrg 12652 1.1 mrg @item @emph{Example}: 12653 1.1 mrg @smallexample 12654 1.1 mrg program test_secnds 12655 1.1 mrg integer :: i 12656 1.1 mrg real(4) :: t1, t2 12657 1.1 mrg print *, secnds (0.0) ! seconds since midnight 12658 1.1 mrg t1 = secnds (0.0) ! reference time 12659 1.1 mrg do i = 1, 10000000 ! do something 12660 1.1 mrg end do 12661 1.1 mrg t2 = secnds (t1) ! elapsed time 12662 1.1 mrg print *, "Something took ", t2, " seconds." 12663 1.1 mrg end program test_secnds 12664 1.1 mrg @end smallexample 12665 1.1 mrg @end table 12666 1.1 mrg 12667 1.1 mrg 12668 1.1 mrg 12669 1.1 mrg @node SECOND 12670 1.1 mrg @section @code{SECOND} --- CPU time function 12671 1.1 mrg @fnindex SECOND 12672 1.1 mrg @cindex time, elapsed 12673 1.1 mrg @cindex elapsed time 12674 1.1 mrg 12675 1.1 mrg @table @asis 12676 1.1 mrg @item @emph{Description}: 12677 1.1 mrg Returns a @code{REAL(4)} value representing the elapsed CPU time in 12678 1.1 mrg seconds. This provides the same functionality as the standard 12679 1.1 mrg @code{CPU_TIME} intrinsic, and is only included for backwards 12680 1.1 mrg compatibility. 12681 1.1 mrg 12682 1.1 mrg This intrinsic is provided in both subroutine and function forms; 12683 1.1 mrg however, only one form can be used in any given program unit. 12684 1.1 mrg 12685 1.1 mrg @item @emph{Standard}: 12686 1.1 mrg GNU extension 12687 1.1 mrg 12688 1.1 mrg @item @emph{Class}: 12689 1.1 mrg Subroutine, function 12690 1.1 mrg 12691 1.1 mrg @item @emph{Syntax}: 12692 1.1 mrg @multitable @columnfractions .80 12693 1.1 mrg @item @code{CALL SECOND(TIME)} 12694 1.1 mrg @item @code{TIME = SECOND()} 12695 1.1 mrg @end multitable 12696 1.1 mrg 12697 1.1 mrg @item @emph{Arguments}: 12698 1.1 mrg @multitable @columnfractions .15 .70 12699 1.1 mrg @item @var{TIME} @tab Shall be of type @code{REAL(4)}. 12700 1.1 mrg @end multitable 12701 1.1 mrg 12702 1.1 mrg @item @emph{Return value}: 12703 1.1 mrg In either syntax, @var{TIME} is set to the process's current runtime in 12704 1.1 mrg seconds. 12705 1.1 mrg 12706 1.1 mrg @item @emph{See also}: 12707 1.1 mrg @ref{CPU_TIME} 12708 1.1 mrg 12709 1.1 mrg @end table 12710 1.1 mrg 12711 1.1 mrg 12712 1.1 mrg 12713 1.1 mrg @node SELECTED_CHAR_KIND 12714 1.1 mrg @section @code{SELECTED_CHAR_KIND} --- Choose character kind 12715 1.1 mrg @fnindex SELECTED_CHAR_KIND 12716 1.1 mrg @cindex character kind 12717 1.1 mrg @cindex kind, character 12718 1.1 mrg 12719 1.1 mrg @table @asis 12720 1.1 mrg @item @emph{Description}: 12721 1.1 mrg 12722 1.1 mrg @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character 12723 1.1 mrg set named @var{NAME}, if a character set with such a name is supported, 12724 1.1 mrg or @math{-1} otherwise. Currently, supported character sets include 12725 1.1 mrg ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646'' 12726 1.1 mrg (Universal Character Set, UCS-4) which is commonly known as Unicode. 12727 1.1 mrg 12728 1.1 mrg @item @emph{Standard}: 12729 1.1 mrg Fortran 2003 and later 12730 1.1 mrg 12731 1.1 mrg @item @emph{Class}: 12732 1.1 mrg Transformational function 12733 1.1 mrg 12734 1.1 mrg @item @emph{Syntax}: 12735 1.1 mrg @code{RESULT = SELECTED_CHAR_KIND(NAME)} 12736 1.1 mrg 12737 1.1 mrg @item @emph{Arguments}: 12738 1.1 mrg @multitable @columnfractions .15 .70 12739 1.1 mrg @item @var{NAME} @tab Shall be a scalar and of the default character type. 12740 1.1 mrg @end multitable 12741 1.1 mrg 12742 1.1 mrg @item @emph{Example}: 12743 1.1 mrg @smallexample 12744 1.1 mrg program character_kind 12745 1.1 mrg use iso_fortran_env 12746 1.1 mrg implicit none 12747 1.1 mrg integer, parameter :: ascii = selected_char_kind ("ascii") 12748 1.1 mrg integer, parameter :: ucs4 = selected_char_kind ('ISO_10646') 12749 1.1 mrg 12750 1.1 mrg character(kind=ascii, len=26) :: alphabet 12751 1.1 mrg character(kind=ucs4, len=30) :: hello_world 12752 1.1 mrg 12753 1.1 mrg alphabet = ascii_"abcdefghijklmnopqrstuvwxyz" 12754 1.1 mrg hello_world = ucs4_'Hello World and Ni Hao -- ' & 12755 1.1 mrg // char (int (z'4F60'), ucs4) & 12756 1.1 mrg // char (int (z'597D'), ucs4) 12757 1.1 mrg 12758 1.1 mrg write (*,*) alphabet 12759 1.1 mrg 12760 1.1 mrg open (output_unit, encoding='UTF-8') 12761 1.1 mrg write (*,*) trim (hello_world) 12762 1.1 mrg end program character_kind 12763 1.1 mrg @end smallexample 12764 1.1 mrg @end table 12765 1.1 mrg 12766 1.1 mrg 12767 1.1 mrg 12768 1.1 mrg @node SELECTED_INT_KIND 12769 1.1 mrg @section @code{SELECTED_INT_KIND} --- Choose integer kind 12770 1.1 mrg @fnindex SELECTED_INT_KIND 12771 1.1 mrg @cindex integer kind 12772 1.1 mrg @cindex kind, integer 12773 1.1 mrg 12774 1.1 mrg @table @asis 12775 1.1 mrg @item @emph{Description}: 12776 1.1 mrg @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer 12777 1.1 mrg type that can represent all values ranging from @math{-10^R} (exclusive) 12778 1.1 mrg to @math{10^R} (exclusive). If there is no integer kind that accommodates 12779 1.1 mrg this range, @code{SELECTED_INT_KIND} returns @math{-1}. 12780 1.1 mrg 12781 1.1 mrg @item @emph{Standard}: 12782 1.1.1.2 mrg Fortran 90 and later 12783 1.1 mrg 12784 1.1 mrg @item @emph{Class}: 12785 1.1 mrg Transformational function 12786 1.1 mrg 12787 1.1 mrg @item @emph{Syntax}: 12788 1.1 mrg @code{RESULT = SELECTED_INT_KIND(R)} 12789 1.1 mrg 12790 1.1 mrg @item @emph{Arguments}: 12791 1.1 mrg @multitable @columnfractions .15 .70 12792 1.1 mrg @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}. 12793 1.1 mrg @end multitable 12794 1.1 mrg 12795 1.1 mrg @item @emph{Example}: 12796 1.1 mrg @smallexample 12797 1.1 mrg program large_integers 12798 1.1 mrg integer,parameter :: k5 = selected_int_kind(5) 12799 1.1 mrg integer,parameter :: k15 = selected_int_kind(15) 12800 1.1 mrg integer(kind=k5) :: i5 12801 1.1 mrg integer(kind=k15) :: i15 12802 1.1 mrg 12803 1.1 mrg print *, huge(i5), huge(i15) 12804 1.1 mrg 12805 1.1 mrg ! The following inequalities are always true 12806 1.1 mrg print *, huge(i5) >= 10_k5**5-1 12807 1.1 mrg print *, huge(i15) >= 10_k15**15-1 12808 1.1 mrg end program large_integers 12809 1.1 mrg @end smallexample 12810 1.1 mrg @end table 12811 1.1 mrg 12812 1.1 mrg 12813 1.1 mrg 12814 1.1 mrg @node SELECTED_REAL_KIND 12815 1.1 mrg @section @code{SELECTED_REAL_KIND} --- Choose real kind 12816 1.1 mrg @fnindex SELECTED_REAL_KIND 12817 1.1 mrg @cindex real kind 12818 1.1 mrg @cindex kind, real 12819 1.1 mrg @cindex radix, real 12820 1.1 mrg 12821 1.1 mrg @table @asis 12822 1.1 mrg @item @emph{Description}: 12823 1.1 mrg @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type 12824 1.1 mrg with decimal precision of at least @code{P} digits, exponent range of 12825 1.1 mrg at least @code{R}, and with a radix of @code{RADIX}. 12826 1.1 mrg 12827 1.1 mrg @item @emph{Standard}: 12828 1.1.1.2 mrg Fortran 90 and later, with @code{RADIX} Fortran 2008 or later 12829 1.1 mrg 12830 1.1 mrg @item @emph{Class}: 12831 1.1 mrg Transformational function 12832 1.1 mrg 12833 1.1 mrg @item @emph{Syntax}: 12834 1.1 mrg @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])} 12835 1.1 mrg 12836 1.1 mrg @item @emph{Arguments}: 12837 1.1 mrg @multitable @columnfractions .15 .70 12838 1.1 mrg @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}. 12839 1.1 mrg @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}. 12840 1.1 mrg @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}. 12841 1.1 mrg @end multitable 12842 1.1 mrg Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall 12843 1.1 mrg be present; since Fortran 2008, they are assumed to be zero if absent. 12844 1.1 mrg 12845 1.1 mrg @item @emph{Return value}: 12846 1.1 mrg 12847 1.1 mrg @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of 12848 1.1 mrg a real data type with decimal precision of at least @code{P} digits, a 12849 1.1 mrg decimal exponent range of at least @code{R}, and with the requested 12850 1.1 mrg @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with 12851 1.1 mrg any radix can be returned. If more than one real data type meet the 12852 1.1 mrg criteria, the kind of the data type with the smallest decimal precision 12853 1.1 mrg is returned. If no real data type matches the criteria, the result is 12854 1.1 mrg @table @asis 12855 1.1 mrg @item -1 if the processor does not support a real data type with a 12856 1.1 mrg precision greater than or equal to @code{P}, but the @code{R} and 12857 1.1 mrg @code{RADIX} requirements can be fulfilled 12858 1.1 mrg @item -2 if the processor does not support a real type with an exponent 12859 1.1 mrg range greater than or equal to @code{R}, but @code{P} and @code{RADIX} 12860 1.1 mrg are fulfillable 12861 1.1 mrg @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements 12862 1.1 mrg are fulfillable 12863 1.1 mrg @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements 12864 1.1 mrg are fulfillable 12865 1.1 mrg @item -5 if there is no real type with the given @code{RADIX} 12866 1.1 mrg @end table 12867 1.1 mrg 12868 1.1 mrg @item @emph{Example}: 12869 1.1 mrg @smallexample 12870 1.1 mrg program real_kinds 12871 1.1 mrg integer,parameter :: p6 = selected_real_kind(6) 12872 1.1 mrg integer,parameter :: p10r100 = selected_real_kind(10,100) 12873 1.1 mrg integer,parameter :: r400 = selected_real_kind(r=400) 12874 1.1 mrg real(kind=p6) :: x 12875 1.1 mrg real(kind=p10r100) :: y 12876 1.1 mrg real(kind=r400) :: z 12877 1.1 mrg 12878 1.1 mrg print *, precision(x), range(x) 12879 1.1 mrg print *, precision(y), range(y) 12880 1.1 mrg print *, precision(z), range(z) 12881 1.1 mrg end program real_kinds 12882 1.1 mrg @end smallexample 12883 1.1.1.2 mrg @item @emph{See also}: 12884 1.1.1.2 mrg @ref{PRECISION}, @gol 12885 1.1.1.2 mrg @ref{RANGE}, @gol 12886 1.1.1.2 mrg @ref{RADIX} 12887 1.1 mrg @end table 12888 1.1 mrg 12889 1.1 mrg 12890 1.1 mrg 12891 1.1 mrg @node SET_EXPONENT 12892 1.1 mrg @section @code{SET_EXPONENT} --- Set the exponent of the model 12893 1.1 mrg @fnindex SET_EXPONENT 12894 1.1 mrg @cindex real number, set exponent 12895 1.1 mrg @cindex floating point, set exponent 12896 1.1 mrg 12897 1.1 mrg @table @asis 12898 1.1 mrg @item @emph{Description}: 12899 1.1 mrg @code{SET_EXPONENT(X, I)} returns the real number whose fractional part 12900 1.1.1.3 mrg is that of @var{X} and whose exponent part is @var{I}. 12901 1.1 mrg 12902 1.1 mrg @item @emph{Standard}: 12903 1.1.1.2 mrg Fortran 90 and later 12904 1.1 mrg 12905 1.1 mrg @item @emph{Class}: 12906 1.1 mrg Elemental function 12907 1.1 mrg 12908 1.1 mrg @item @emph{Syntax}: 12909 1.1 mrg @code{RESULT = SET_EXPONENT(X, I)} 12910 1.1 mrg 12911 1.1 mrg @item @emph{Arguments}: 12912 1.1 mrg @multitable @columnfractions .15 .70 12913 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}. 12914 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}. 12915 1.1 mrg @end multitable 12916 1.1 mrg 12917 1.1 mrg @item @emph{Return value}: 12918 1.1 mrg The return value is of the same type and kind as @var{X}. 12919 1.1 mrg The real number whose fractional part 12920 1.1.1.3 mrg is that of @var{X} and whose exponent part if @var{I} is returned; 12921 1.1 mrg it is @code{FRACTION(X) * RADIX(X)**I}. 12922 1.1 mrg 12923 1.1 mrg @item @emph{Example}: 12924 1.1 mrg @smallexample 12925 1.1 mrg PROGRAM test_setexp 12926 1.1 mrg REAL :: x = 178.1387e-4 12927 1.1 mrg INTEGER :: i = 17 12928 1.1 mrg PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i 12929 1.1 mrg END PROGRAM 12930 1.1 mrg @end smallexample 12931 1.1 mrg 12932 1.1 mrg @end table 12933 1.1 mrg 12934 1.1 mrg 12935 1.1 mrg 12936 1.1 mrg @node SHAPE 12937 1.1 mrg @section @code{SHAPE} --- Determine the shape of an array 12938 1.1 mrg @fnindex SHAPE 12939 1.1 mrg @cindex array, shape 12940 1.1 mrg 12941 1.1 mrg @table @asis 12942 1.1 mrg @item @emph{Description}: 12943 1.1 mrg Determines the shape of an array. 12944 1.1 mrg 12945 1.1 mrg @item @emph{Standard}: 12946 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later 12947 1.1 mrg 12948 1.1 mrg @item @emph{Class}: 12949 1.1 mrg Inquiry function 12950 1.1 mrg 12951 1.1 mrg @item @emph{Syntax}: 12952 1.1 mrg @code{RESULT = SHAPE(SOURCE [, KIND])} 12953 1.1 mrg 12954 1.1 mrg @item @emph{Arguments}: 12955 1.1 mrg @multitable @columnfractions .15 .70 12956 1.1 mrg @item @var{SOURCE} @tab Shall be an array or scalar of any type. 12957 1.1 mrg If @var{SOURCE} is a pointer it must be associated and allocatable 12958 1.1 mrg arrays must be allocated. 12959 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 12960 1.1 mrg expression indicating the kind parameter of the result. 12961 1.1 mrg @end multitable 12962 1.1 mrg 12963 1.1 mrg @item @emph{Return value}: 12964 1.1 mrg An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} 12965 1.1 mrg has dimensions. The elements of the resulting array correspond to the extend 12966 1.1 mrg of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar, 12967 1.1 mrg the result is the rank one array of size zero. If @var{KIND} is absent, the 12968 1.1 mrg return value has the default integer kind otherwise the specified kind. 12969 1.1 mrg 12970 1.1 mrg @item @emph{Example}: 12971 1.1 mrg @smallexample 12972 1.1 mrg PROGRAM test_shape 12973 1.1 mrg INTEGER, DIMENSION(-1:1, -1:2) :: A 12974 1.1 mrg WRITE(*,*) SHAPE(A) ! (/ 3, 4 /) 12975 1.1 mrg WRITE(*,*) SIZE(SHAPE(42)) ! (/ /) 12976 1.1 mrg END PROGRAM 12977 1.1 mrg @end smallexample 12978 1.1 mrg 12979 1.1 mrg @item @emph{See also}: 12980 1.1.1.2 mrg @ref{RESHAPE}, @gol 12981 1.1.1.2 mrg @ref{SIZE} 12982 1.1 mrg @end table 12983 1.1 mrg 12984 1.1 mrg 12985 1.1 mrg 12986 1.1 mrg @node SHIFTA 12987 1.1 mrg @section @code{SHIFTA} --- Right shift with fill 12988 1.1 mrg @fnindex SHIFTA 12989 1.1 mrg @cindex bits, shift right 12990 1.1 mrg @cindex shift, right with fill 12991 1.1 mrg 12992 1.1 mrg @table @asis 12993 1.1 mrg @item @emph{Description}: 12994 1.1 mrg @code{SHIFTA} returns a value corresponding to @var{I} with all of the 12995 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} that be 12996 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise 12997 1.1 mrg the result value is undefined. Bits shifted out from the right end 12998 1.1 mrg are lost. The fill is arithmetic: the bits shifted in from the left 12999 1.1 mrg end are equal to the leftmost bit, which in two's complement 13000 1.1 mrg representation is the sign bit. 13001 1.1 mrg 13002 1.1 mrg @item @emph{Standard}: 13003 1.1 mrg Fortran 2008 and later 13004 1.1 mrg 13005 1.1 mrg @item @emph{Class}: 13006 1.1 mrg Elemental function 13007 1.1 mrg 13008 1.1 mrg @item @emph{Syntax}: 13009 1.1 mrg @code{RESULT = SHIFTA(I, SHIFT)} 13010 1.1 mrg 13011 1.1 mrg @item @emph{Arguments}: 13012 1.1 mrg @multitable @columnfractions .15 .70 13013 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 13014 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 13015 1.1 mrg @end multitable 13016 1.1 mrg 13017 1.1 mrg @item @emph{Return value}: 13018 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 13019 1.1 mrg @var{I}. 13020 1.1 mrg 13021 1.1 mrg @item @emph{See also}: 13022 1.1.1.2 mrg @ref{SHIFTL}, @gol 13023 1.1.1.2 mrg @ref{SHIFTR} 13024 1.1 mrg @end table 13025 1.1 mrg 13026 1.1 mrg 13027 1.1 mrg 13028 1.1 mrg @node SHIFTL 13029 1.1 mrg @section @code{SHIFTL} --- Left shift 13030 1.1 mrg @fnindex SHIFTL 13031 1.1 mrg @cindex bits, shift left 13032 1.1 mrg @cindex shift, left 13033 1.1 mrg 13034 1.1 mrg @table @asis 13035 1.1 mrg @item @emph{Description}: 13036 1.1 mrg @code{SHIFTL} returns a value corresponding to @var{I} with all of the 13037 1.1 mrg bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be 13038 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise 13039 1.1 mrg the result value is undefined. Bits shifted out from the left end are 13040 1.1 mrg lost, and bits shifted in from the right end are set to 0. 13041 1.1 mrg 13042 1.1 mrg @item @emph{Standard}: 13043 1.1 mrg Fortran 2008 and later 13044 1.1 mrg 13045 1.1 mrg @item @emph{Class}: 13046 1.1 mrg Elemental function 13047 1.1 mrg 13048 1.1 mrg @item @emph{Syntax}: 13049 1.1 mrg @code{RESULT = SHIFTL(I, SHIFT)} 13050 1.1 mrg 13051 1.1 mrg @item @emph{Arguments}: 13052 1.1 mrg @multitable @columnfractions .15 .70 13053 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 13054 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 13055 1.1 mrg @end multitable 13056 1.1 mrg 13057 1.1 mrg @item @emph{Return value}: 13058 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 13059 1.1 mrg @var{I}. 13060 1.1 mrg 13061 1.1 mrg @item @emph{See also}: 13062 1.1.1.2 mrg @ref{SHIFTA}, @gol 13063 1.1.1.2 mrg @ref{SHIFTR} 13064 1.1 mrg @end table 13065 1.1 mrg 13066 1.1 mrg 13067 1.1 mrg 13068 1.1 mrg @node SHIFTR 13069 1.1 mrg @section @code{SHIFTR} --- Right shift 13070 1.1 mrg @fnindex SHIFTR 13071 1.1 mrg @cindex bits, shift right 13072 1.1 mrg @cindex shift, right 13073 1.1 mrg 13074 1.1 mrg @table @asis 13075 1.1 mrg @item @emph{Description}: 13076 1.1 mrg @code{SHIFTR} returns a value corresponding to @var{I} with all of the 13077 1.1 mrg bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be 13078 1.1 mrg nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise 13079 1.1 mrg the result value is undefined. Bits shifted out from the right end 13080 1.1 mrg are lost, and bits shifted in from the left end are set to 0. 13081 1.1 mrg 13082 1.1 mrg @item @emph{Standard}: 13083 1.1 mrg Fortran 2008 and later 13084 1.1 mrg 13085 1.1 mrg @item @emph{Class}: 13086 1.1 mrg Elemental function 13087 1.1 mrg 13088 1.1 mrg @item @emph{Syntax}: 13089 1.1 mrg @code{RESULT = SHIFTR(I, SHIFT)} 13090 1.1 mrg 13091 1.1 mrg @item @emph{Arguments}: 13092 1.1 mrg @multitable @columnfractions .15 .70 13093 1.1 mrg @item @var{I} @tab The type shall be @code{INTEGER}. 13094 1.1 mrg @item @var{SHIFT} @tab The type shall be @code{INTEGER}. 13095 1.1 mrg @end multitable 13096 1.1 mrg 13097 1.1 mrg @item @emph{Return value}: 13098 1.1 mrg The return value is of type @code{INTEGER} and of the same kind as 13099 1.1 mrg @var{I}. 13100 1.1 mrg 13101 1.1 mrg @item @emph{See also}: 13102 1.1.1.2 mrg @ref{SHIFTA}, @gol 13103 1.1.1.2 mrg @ref{SHIFTL} 13104 1.1 mrg @end table 13105 1.1 mrg 13106 1.1 mrg 13107 1.1 mrg 13108 1.1 mrg @node SIGN 13109 1.1 mrg @section @code{SIGN} --- Sign copying function 13110 1.1 mrg @fnindex SIGN 13111 1.1 mrg @fnindex ISIGN 13112 1.1 mrg @fnindex DSIGN 13113 1.1 mrg @cindex sign copying 13114 1.1 mrg 13115 1.1 mrg @table @asis 13116 1.1 mrg @item @emph{Description}: 13117 1.1 mrg @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}. 13118 1.1 mrg 13119 1.1 mrg @item @emph{Standard}: 13120 1.1 mrg Fortran 77 and later 13121 1.1 mrg 13122 1.1 mrg @item @emph{Class}: 13123 1.1 mrg Elemental function 13124 1.1 mrg 13125 1.1 mrg @item @emph{Syntax}: 13126 1.1 mrg @code{RESULT = SIGN(A, B)} 13127 1.1 mrg 13128 1.1 mrg @item @emph{Arguments}: 13129 1.1 mrg @multitable @columnfractions .15 .70 13130 1.1 mrg @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL} 13131 1.1.1.2 mrg @item @var{B} @tab Shall be of the same type and kind as @var{A}. 13132 1.1 mrg @end multitable 13133 1.1 mrg 13134 1.1 mrg @item @emph{Return value}: 13135 1.1 mrg The kind of the return value is that of @var{A} and @var{B}. 13136 1.1.1.3 mrg If @math{B \ge 0} then the result is @code{ABS(A)}, else 13137 1.1 mrg it is @code{-ABS(A)}. 13138 1.1 mrg 13139 1.1 mrg @item @emph{Example}: 13140 1.1 mrg @smallexample 13141 1.1 mrg program test_sign 13142 1.1 mrg print *, sign(-12,1) 13143 1.1 mrg print *, sign(-12,0) 13144 1.1 mrg print *, sign(-12,-1) 13145 1.1 mrg 13146 1.1 mrg print *, sign(-12.,1.) 13147 1.1 mrg print *, sign(-12.,0.) 13148 1.1 mrg print *, sign(-12.,-1.) 13149 1.1 mrg end program test_sign 13150 1.1 mrg @end smallexample 13151 1.1 mrg 13152 1.1 mrg @item @emph{Specific names}: 13153 1.1.1.3 mrg @multitable @columnfractions .20 .26 .20 .30 13154 1.1.1.3 mrg @headitem Name @tab Arguments @tab Return type @tab Standard 13155 1.1.1.2 mrg @item @code{SIGN(A,B)} @tab @code{REAL(4) A, B} @tab @code{REAL(4)} @tab Fortran 77 and later 13156 1.1.1.2 mrg @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab Fortran 77 and later 13157 1.1.1.2 mrg @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B} @tab @code{REAL(8)} @tab Fortran 77 and later 13158 1.1 mrg @end multitable 13159 1.1 mrg @end table 13160 1.1 mrg 13161 1.1 mrg 13162 1.1 mrg 13163 1.1 mrg @node SIGNAL 13164 1.1 mrg @section @code{SIGNAL} --- Signal handling subroutine (or function) 13165 1.1 mrg @fnindex SIGNAL 13166 1.1 mrg @cindex system, signal handling 13167 1.1 mrg 13168 1.1 mrg @table @asis 13169 1.1 mrg @item @emph{Description}: 13170 1.1 mrg @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine 13171 1.1 mrg @var{HANDLER} to be executed with a single integer argument when signal 13172 1.1 mrg @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to 13173 1.1 mrg turn off handling of signal @var{NUMBER} or revert to its default 13174 1.1 mrg action. See @code{signal(2)}. 13175 1.1 mrg 13176 1.1 mrg If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument 13177 1.1 mrg is supplied, it is set to the value returned by @code{signal(2)}. 13178 1.1 mrg 13179 1.1 mrg @item @emph{Standard}: 13180 1.1 mrg GNU extension 13181 1.1 mrg 13182 1.1 mrg @item @emph{Class}: 13183 1.1 mrg Subroutine, function 13184 1.1 mrg 13185 1.1 mrg @item @emph{Syntax}: 13186 1.1 mrg @multitable @columnfractions .80 13187 1.1 mrg @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])} 13188 1.1 mrg @item @code{STATUS = SIGNAL(NUMBER, HANDLER)} 13189 1.1 mrg @end multitable 13190 1.1 mrg 13191 1.1 mrg @item @emph{Arguments}: 13192 1.1 mrg @multitable @columnfractions .15 .70 13193 1.1 mrg @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)} 13194 1.1 mrg @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or 13195 1.1 mrg @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. 13196 1.1 mrg @code{INTEGER}. It is @code{INTENT(IN)}. 13197 1.1 mrg @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar 13198 1.1 mrg integer. It has @code{INTENT(OUT)}. 13199 1.1 mrg @end multitable 13200 1.1 mrg @c TODO: What should the interface of the handler be? Does it take arguments? 13201 1.1 mrg 13202 1.1 mrg @item @emph{Return value}: 13203 1.1 mrg The @code{SIGNAL} function returns the value returned by @code{signal(2)}. 13204 1.1 mrg 13205 1.1 mrg @item @emph{Example}: 13206 1.1 mrg @smallexample 13207 1.1 mrg program test_signal 13208 1.1 mrg intrinsic signal 13209 1.1 mrg external handler_print 13210 1.1 mrg 13211 1.1 mrg call signal (12, handler_print) 13212 1.1 mrg call signal (10, 1) 13213 1.1 mrg 13214 1.1 mrg call sleep (30) 13215 1.1 mrg end program test_signal 13216 1.1 mrg @end smallexample 13217 1.1 mrg @end table 13218 1.1 mrg 13219 1.1 mrg 13220 1.1 mrg 13221 1.1 mrg @node SIN 13222 1.1 mrg @section @code{SIN} --- Sine function 13223 1.1 mrg @fnindex SIN 13224 1.1 mrg @fnindex DSIN 13225 1.1 mrg @fnindex CSIN 13226 1.1 mrg @fnindex ZSIN 13227 1.1 mrg @fnindex CDSIN 13228 1.1 mrg @cindex trigonometric function, sine 13229 1.1 mrg @cindex sine 13230 1.1 mrg 13231 1.1 mrg @table @asis 13232 1.1 mrg @item @emph{Description}: 13233 1.1 mrg @code{SIN(X)} computes the sine of @var{X}. 13234 1.1 mrg 13235 1.1 mrg @item @emph{Standard}: 13236 1.1 mrg Fortran 77 and later 13237 1.1 mrg 13238 1.1 mrg @item @emph{Class}: 13239 1.1 mrg Elemental function 13240 1.1 mrg 13241 1.1 mrg @item @emph{Syntax}: 13242 1.1 mrg @code{RESULT = SIN(X)} 13243 1.1 mrg 13244 1.1 mrg @item @emph{Arguments}: 13245 1.1 mrg @multitable @columnfractions .15 .70 13246 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or 13247 1.1 mrg @code{COMPLEX}. 13248 1.1 mrg @end multitable 13249 1.1 mrg 13250 1.1 mrg @item @emph{Return value}: 13251 1.1 mrg The return value has same type and kind as @var{X}. 13252 1.1 mrg 13253 1.1 mrg @item @emph{Example}: 13254 1.1 mrg @smallexample 13255 1.1 mrg program test_sin 13256 1.1 mrg real :: x = 0.0 13257 1.1 mrg x = sin(x) 13258 1.1 mrg end program test_sin 13259 1.1 mrg @end smallexample 13260 1.1 mrg 13261 1.1 mrg @item @emph{Specific names}: 13262 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 13263 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 13264 1.1.1.2 mrg @item @code{SIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 13265 1.1.1.2 mrg @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 13266 1.1.1.2 mrg @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later 13267 1.1.1.2 mrg @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 13268 1.1.1.2 mrg @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 13269 1.1 mrg @end multitable 13270 1.1 mrg 13271 1.1 mrg @item @emph{See also}: 13272 1.1.1.2 mrg Inverse function: @gol 13273 1.1.1.2 mrg @ref{ASIN} @gol 13274 1.1.1.2 mrg Degrees function: @gol 13275 1.1.1.2 mrg @ref{SIND} 13276 1.1 mrg @end table 13277 1.1 mrg 13278 1.1 mrg 13279 1.1 mrg 13280 1.1 mrg @node SIND 13281 1.1 mrg @section @code{SIND} --- Sine function, degrees 13282 1.1 mrg @fnindex SIND 13283 1.1 mrg @fnindex DSIND 13284 1.1 mrg @fnindex CSIND 13285 1.1 mrg @fnindex ZSIND 13286 1.1 mrg @fnindex CDSIND 13287 1.1 mrg @cindex trigonometric function, sine, degrees 13288 1.1 mrg @cindex sine, degrees 13289 1.1 mrg 13290 1.1 mrg @table @asis 13291 1.1 mrg @item @emph{Description}: 13292 1.1 mrg @code{SIND(X)} computes the sine of @var{X} in degrees. 13293 1.1 mrg 13294 1.1 mrg This function is for compatibility only and should be avoided in favor of 13295 1.1 mrg standard constructs wherever possible. 13296 1.1 mrg 13297 1.1 mrg @item @emph{Standard}: 13298 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}. 13299 1.1 mrg 13300 1.1 mrg @item @emph{Class}: 13301 1.1 mrg Elemental function 13302 1.1 mrg 13303 1.1 mrg @item @emph{Syntax}: 13304 1.1 mrg @code{RESULT = SIND(X)} 13305 1.1 mrg 13306 1.1 mrg @item @emph{Arguments}: 13307 1.1 mrg @multitable @columnfractions .15 .70 13308 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or 13309 1.1 mrg @code{COMPLEX}. 13310 1.1 mrg @end multitable 13311 1.1 mrg 13312 1.1 mrg @item @emph{Return value}: 13313 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees. 13314 1.1 mrg 13315 1.1 mrg @item @emph{Example}: 13316 1.1 mrg @smallexample 13317 1.1 mrg program test_sind 13318 1.1 mrg real :: x = 0.0 13319 1.1 mrg x = sind(x) 13320 1.1 mrg end program test_sind 13321 1.1 mrg @end smallexample 13322 1.1 mrg 13323 1.1 mrg @item @emph{Specific names}: 13324 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 13325 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 13326 1.1.1.2 mrg @item @code{SIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 13327 1.1.1.2 mrg @item @code{DSIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 13328 1.1.1.2 mrg @item @code{CSIND(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension 13329 1.1.1.2 mrg @item @code{ZSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 13330 1.1.1.2 mrg @item @code{CDSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 13331 1.1 mrg @end multitable 13332 1.1 mrg 13333 1.1 mrg @item @emph{See also}: 13334 1.1.1.2 mrg Inverse function: @gol 13335 1.1.1.2 mrg @ref{ASIND} @gol 13336 1.1.1.2 mrg Radians function: @gol 13337 1.1.1.2 mrg @ref{SIN} @gol 13338 1.1 mrg @end table 13339 1.1 mrg 13340 1.1 mrg 13341 1.1 mrg 13342 1.1 mrg @node SINH 13343 1.1 mrg @section @code{SINH} --- Hyperbolic sine function 13344 1.1 mrg @fnindex SINH 13345 1.1 mrg @fnindex DSINH 13346 1.1 mrg @cindex hyperbolic sine 13347 1.1 mrg @cindex hyperbolic function, sine 13348 1.1 mrg @cindex sine, hyperbolic 13349 1.1 mrg 13350 1.1 mrg @table @asis 13351 1.1 mrg @item @emph{Description}: 13352 1.1 mrg @code{SINH(X)} computes the hyperbolic sine of @var{X}. 13353 1.1 mrg 13354 1.1 mrg @item @emph{Standard}: 13355 1.1.1.2 mrg Fortran 90 and later, for a complex argument Fortran 2008 or later, has 13356 1.1.1.2 mrg a GNU extension 13357 1.1 mrg 13358 1.1 mrg @item @emph{Class}: 13359 1.1 mrg Elemental function 13360 1.1 mrg 13361 1.1 mrg @item @emph{Syntax}: 13362 1.1 mrg @code{RESULT = SINH(X)} 13363 1.1 mrg 13364 1.1 mrg @item @emph{Arguments}: 13365 1.1 mrg @multitable @columnfractions .15 .70 13366 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 13367 1.1 mrg @end multitable 13368 1.1 mrg 13369 1.1 mrg @item @emph{Return value}: 13370 1.1 mrg The return value has same type and kind as @var{X}. 13371 1.1 mrg 13372 1.1 mrg @item @emph{Example}: 13373 1.1 mrg @smallexample 13374 1.1 mrg program test_sinh 13375 1.1 mrg real(8) :: x = - 1.0_8 13376 1.1 mrg x = sinh(x) 13377 1.1 mrg end program test_sinh 13378 1.1 mrg @end smallexample 13379 1.1 mrg 13380 1.1 mrg @item @emph{Specific names}: 13381 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 13382 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 13383 1.1.1.2 mrg @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 90 and later 13384 1.1 mrg @end multitable 13385 1.1 mrg 13386 1.1 mrg @item @emph{See also}: 13387 1.1 mrg @ref{ASINH} 13388 1.1 mrg @end table 13389 1.1 mrg 13390 1.1 mrg 13391 1.1 mrg 13392 1.1 mrg @node SIZE 13393 1.1 mrg @section @code{SIZE} --- Determine the size of an array 13394 1.1 mrg @fnindex SIZE 13395 1.1 mrg @cindex array, size 13396 1.1 mrg @cindex array, number of elements 13397 1.1 mrg @cindex array, count elements 13398 1.1 mrg 13399 1.1 mrg @table @asis 13400 1.1 mrg @item @emph{Description}: 13401 1.1 mrg Determine the extent of @var{ARRAY} along a specified dimension @var{DIM}, 13402 1.1 mrg or the total number of elements in @var{ARRAY} if @var{DIM} is absent. 13403 1.1 mrg 13404 1.1 mrg @item @emph{Standard}: 13405 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later 13406 1.1 mrg 13407 1.1 mrg @item @emph{Class}: 13408 1.1 mrg Inquiry function 13409 1.1 mrg 13410 1.1 mrg @item @emph{Syntax}: 13411 1.1 mrg @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])} 13412 1.1 mrg 13413 1.1 mrg @item @emph{Arguments}: 13414 1.1 mrg @multitable @columnfractions .15 .70 13415 1.1 mrg @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is 13416 1.1 mrg a pointer it must be associated and allocatable arrays must be allocated. 13417 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER} 13418 1.1 mrg and its value shall be in the range from 1 to n, where n equals the rank 13419 1.1 mrg of @var{ARRAY}. 13420 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 13421 1.1 mrg expression indicating the kind parameter of the result. 13422 1.1 mrg @end multitable 13423 1.1 mrg 13424 1.1 mrg @item @emph{Return value}: 13425 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 13426 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 13427 1.1 mrg 13428 1.1 mrg @item @emph{Example}: 13429 1.1 mrg @smallexample 13430 1.1 mrg PROGRAM test_size 13431 1.1 mrg WRITE(*,*) SIZE((/ 1, 2 /)) ! 2 13432 1.1 mrg END PROGRAM 13433 1.1 mrg @end smallexample 13434 1.1 mrg 13435 1.1 mrg @item @emph{See also}: 13436 1.1.1.2 mrg @ref{SHAPE}, @gol 13437 1.1.1.2 mrg @ref{RESHAPE} 13438 1.1 mrg @end table 13439 1.1 mrg 13440 1.1 mrg 13441 1.1 mrg @node SIZEOF 13442 1.1 mrg @section @code{SIZEOF} --- Size in bytes of an expression 13443 1.1 mrg @fnindex SIZEOF 13444 1.1 mrg @cindex expression size 13445 1.1 mrg @cindex size of an expression 13446 1.1 mrg 13447 1.1 mrg @table @asis 13448 1.1 mrg @item @emph{Description}: 13449 1.1 mrg @code{SIZEOF(X)} calculates the number of bytes of storage the 13450 1.1 mrg expression @code{X} occupies. 13451 1.1 mrg 13452 1.1 mrg @item @emph{Standard}: 13453 1.1 mrg GNU extension 13454 1.1 mrg 13455 1.1 mrg @item @emph{Class}: 13456 1.1 mrg Inquiry function 13457 1.1 mrg 13458 1.1 mrg @item @emph{Syntax}: 13459 1.1 mrg @code{N = SIZEOF(X)} 13460 1.1 mrg 13461 1.1 mrg @item @emph{Arguments}: 13462 1.1 mrg @multitable @columnfractions .15 .70 13463 1.1 mrg @item @var{X} @tab The argument shall be of any type, rank or shape. 13464 1.1 mrg @end multitable 13465 1.1 mrg 13466 1.1 mrg @item @emph{Return value}: 13467 1.1 mrg The return value is of type integer and of the system-dependent kind 13468 1.1 mrg @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the 13469 1.1 mrg number of bytes occupied by the argument. If the argument has the 13470 1.1 mrg @code{POINTER} attribute, the number of bytes of the storage area pointed 13471 1.1 mrg to is returned. If the argument is of a derived type with @code{POINTER} 13472 1.1 mrg or @code{ALLOCATABLE} components, the return value does not account for 13473 1.1 mrg the sizes of the data pointed to by these components. If the argument is 13474 1.1 mrg polymorphic, the size according to the dynamic type is returned. The argument 13475 1.1 mrg may not be a procedure or procedure pointer. Note that the code assumes for 13476 1.1 mrg arrays that those are contiguous; for contiguous arrays, it returns the 13477 1.1 mrg storage or an array element multiplied by the size of the array. 13478 1.1 mrg 13479 1.1 mrg @item @emph{Example}: 13480 1.1 mrg @smallexample 13481 1.1 mrg integer :: i 13482 1.1 mrg real :: r, s(5) 13483 1.1 mrg print *, (sizeof(s)/sizeof(r) == 5) 13484 1.1 mrg end 13485 1.1 mrg @end smallexample 13486 1.1 mrg The example will print @code{.TRUE.} unless you are using a platform 13487 1.1 mrg where default @code{REAL} variables are unusually padded. 13488 1.1 mrg 13489 1.1 mrg @item @emph{See also}: 13490 1.1.1.2 mrg @ref{C_SIZEOF}, @gol 13491 1.1.1.2 mrg @ref{STORAGE_SIZE} 13492 1.1 mrg @end table 13493 1.1 mrg 13494 1.1 mrg 13495 1.1 mrg @node SLEEP 13496 1.1 mrg @section @code{SLEEP} --- Sleep for the specified number of seconds 13497 1.1 mrg @fnindex SLEEP 13498 1.1 mrg @cindex delayed execution 13499 1.1 mrg 13500 1.1 mrg @table @asis 13501 1.1 mrg @item @emph{Description}: 13502 1.1 mrg Calling this subroutine causes the process to pause for @var{SECONDS} seconds. 13503 1.1 mrg 13504 1.1 mrg @item @emph{Standard}: 13505 1.1 mrg GNU extension 13506 1.1 mrg 13507 1.1 mrg @item @emph{Class}: 13508 1.1 mrg Subroutine 13509 1.1 mrg 13510 1.1 mrg @item @emph{Syntax}: 13511 1.1 mrg @code{CALL SLEEP(SECONDS)} 13512 1.1 mrg 13513 1.1 mrg @item @emph{Arguments}: 13514 1.1 mrg @multitable @columnfractions .15 .70 13515 1.1 mrg @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}. 13516 1.1 mrg @end multitable 13517 1.1 mrg 13518 1.1 mrg @item @emph{Example}: 13519 1.1 mrg @smallexample 13520 1.1 mrg program test_sleep 13521 1.1 mrg call sleep(5) 13522 1.1 mrg end 13523 1.1 mrg @end smallexample 13524 1.1 mrg @end table 13525 1.1 mrg 13526 1.1 mrg 13527 1.1 mrg 13528 1.1 mrg @node SPACING 13529 1.1 mrg @section @code{SPACING} --- Smallest distance between two numbers of a given type 13530 1.1 mrg @fnindex SPACING 13531 1.1 mrg @cindex real number, relative spacing 13532 1.1 mrg @cindex floating point, relative spacing 13533 1.1 mrg 13534 1.1 mrg @table @asis 13535 1.1 mrg @item @emph{Description}: 13536 1.1 mrg Determines the distance between the argument @var{X} and the nearest 13537 1.1 mrg adjacent number of the same type. 13538 1.1 mrg 13539 1.1 mrg @item @emph{Standard}: 13540 1.1.1.2 mrg Fortran 90 and later 13541 1.1 mrg 13542 1.1 mrg @item @emph{Class}: 13543 1.1 mrg Elemental function 13544 1.1 mrg 13545 1.1 mrg @item @emph{Syntax}: 13546 1.1 mrg @code{RESULT = SPACING(X)} 13547 1.1 mrg 13548 1.1 mrg @item @emph{Arguments}: 13549 1.1 mrg @multitable @columnfractions .15 .70 13550 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}. 13551 1.1 mrg @end multitable 13552 1.1 mrg 13553 1.1 mrg @item @emph{Return value}: 13554 1.1 mrg The result is of the same type as the input argument @var{X}. 13555 1.1 mrg 13556 1.1 mrg @item @emph{Example}: 13557 1.1 mrg @smallexample 13558 1.1 mrg PROGRAM test_spacing 13559 1.1 mrg INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37) 13560 1.1 mrg INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200) 13561 1.1 mrg 13562 1.1 mrg WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686 13563 1.1 mrg WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686 13564 1.1 mrg END PROGRAM 13565 1.1 mrg @end smallexample 13566 1.1 mrg 13567 1.1 mrg @item @emph{See also}: 13568 1.1 mrg @ref{RRSPACING} 13569 1.1 mrg @end table 13570 1.1 mrg 13571 1.1 mrg 13572 1.1 mrg 13573 1.1 mrg @node SPREAD 13574 1.1 mrg @section @code{SPREAD} --- Add a dimension to an array 13575 1.1 mrg @fnindex SPREAD 13576 1.1 mrg @cindex array, increase dimension 13577 1.1 mrg @cindex array, duplicate elements 13578 1.1 mrg @cindex array, duplicate dimensions 13579 1.1 mrg 13580 1.1 mrg @table @asis 13581 1.1 mrg @item @emph{Description}: 13582 1.1 mrg Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified 13583 1.1 mrg dimension @var{DIM}. 13584 1.1 mrg 13585 1.1 mrg @item @emph{Standard}: 13586 1.1.1.2 mrg Fortran 90 and later 13587 1.1 mrg 13588 1.1 mrg @item @emph{Class}: 13589 1.1 mrg Transformational function 13590 1.1 mrg 13591 1.1 mrg @item @emph{Syntax}: 13592 1.1 mrg @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)} 13593 1.1 mrg 13594 1.1 mrg @item @emph{Arguments}: 13595 1.1 mrg @multitable @columnfractions .15 .70 13596 1.1 mrg @item @var{SOURCE} @tab Shall be a scalar or an array of any type and 13597 1.1 mrg a rank less than seven. 13598 1.1 mrg @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a 13599 1.1 mrg value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}. 13600 1.1 mrg @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}. 13601 1.1 mrg @end multitable 13602 1.1 mrg 13603 1.1 mrg @item @emph{Return value}: 13604 1.1 mrg The result is an array of the same type as @var{SOURCE} and has rank n+1 13605 1.1 mrg where n equals the rank of @var{SOURCE}. 13606 1.1 mrg 13607 1.1 mrg @item @emph{Example}: 13608 1.1 mrg @smallexample 13609 1.1 mrg PROGRAM test_spread 13610 1.1 mrg INTEGER :: a = 1, b(2) = (/ 1, 2 /) 13611 1.1 mrg WRITE(*,*) SPREAD(A, 1, 2) ! "1 1" 13612 1.1 mrg WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2" 13613 1.1 mrg END PROGRAM 13614 1.1 mrg @end smallexample 13615 1.1 mrg 13616 1.1 mrg @item @emph{See also}: 13617 1.1 mrg @ref{UNPACK} 13618 1.1 mrg @end table 13619 1.1 mrg 13620 1.1 mrg 13621 1.1 mrg 13622 1.1 mrg @node SQRT 13623 1.1 mrg @section @code{SQRT} --- Square-root function 13624 1.1 mrg @fnindex SQRT 13625 1.1 mrg @fnindex DSQRT 13626 1.1 mrg @fnindex CSQRT 13627 1.1 mrg @fnindex ZSQRT 13628 1.1 mrg @fnindex CDSQRT 13629 1.1 mrg @cindex root 13630 1.1 mrg @cindex square-root 13631 1.1 mrg 13632 1.1 mrg @table @asis 13633 1.1 mrg @item @emph{Description}: 13634 1.1 mrg @code{SQRT(X)} computes the square root of @var{X}. 13635 1.1 mrg 13636 1.1 mrg @item @emph{Standard}: 13637 1.1 mrg Fortran 77 and later 13638 1.1 mrg 13639 1.1 mrg @item @emph{Class}: 13640 1.1 mrg Elemental function 13641 1.1 mrg 13642 1.1 mrg @item @emph{Syntax}: 13643 1.1 mrg @code{RESULT = SQRT(X)} 13644 1.1 mrg 13645 1.1 mrg @item @emph{Arguments}: 13646 1.1 mrg @multitable @columnfractions .15 .70 13647 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or 13648 1.1 mrg @code{COMPLEX}. 13649 1.1 mrg @end multitable 13650 1.1 mrg 13651 1.1 mrg @item @emph{Return value}: 13652 1.1 mrg The return value is of type @code{REAL} or @code{COMPLEX}. 13653 1.1 mrg The kind type parameter is the same as @var{X}. 13654 1.1 mrg 13655 1.1 mrg @item @emph{Example}: 13656 1.1 mrg @smallexample 13657 1.1 mrg program test_sqrt 13658 1.1 mrg real(8) :: x = 2.0_8 13659 1.1 mrg complex :: z = (1.0, 2.0) 13660 1.1 mrg x = sqrt(x) 13661 1.1 mrg z = sqrt(z) 13662 1.1 mrg end program test_sqrt 13663 1.1 mrg @end smallexample 13664 1.1 mrg 13665 1.1 mrg @item @emph{Specific names}: 13666 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 13667 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 13668 1.1.1.2 mrg @item @code{SQRT(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 13669 1.1.1.2 mrg @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 13670 1.1.1.2 mrg @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later 13671 1.1 mrg @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 13672 1.1 mrg @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension 13673 1.1 mrg @end multitable 13674 1.1 mrg @end table 13675 1.1 mrg 13676 1.1 mrg 13677 1.1 mrg 13678 1.1 mrg @node SRAND 13679 1.1 mrg @section @code{SRAND} --- Reinitialize the random number generator 13680 1.1 mrg @fnindex SRAND 13681 1.1 mrg @cindex random number generation, seeding 13682 1.1 mrg @cindex seeding a random number generator 13683 1.1 mrg 13684 1.1 mrg @table @asis 13685 1.1 mrg @item @emph{Description}: 13686 1.1 mrg @code{SRAND} reinitializes the pseudo-random number generator 13687 1.1 mrg called by @code{RAND} and @code{IRAND}. The new seed used by the 13688 1.1 mrg generator is specified by the required argument @var{SEED}. 13689 1.1 mrg 13690 1.1 mrg @item @emph{Standard}: 13691 1.1 mrg GNU extension 13692 1.1 mrg 13693 1.1 mrg @item @emph{Class}: 13694 1.1 mrg Subroutine 13695 1.1 mrg 13696 1.1 mrg @item @emph{Syntax}: 13697 1.1 mrg @code{CALL SRAND(SEED)} 13698 1.1 mrg 13699 1.1 mrg @item @emph{Arguments}: 13700 1.1 mrg @multitable @columnfractions .15 .70 13701 1.1 mrg @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}. 13702 1.1 mrg @end multitable 13703 1.1 mrg 13704 1.1 mrg @item @emph{Return value}: 13705 1.1 mrg Does not return anything. 13706 1.1 mrg 13707 1.1 mrg @item @emph{Example}: 13708 1.1 mrg See @code{RAND} and @code{IRAND} for examples. 13709 1.1 mrg 13710 1.1 mrg @item @emph{Notes}: 13711 1.1 mrg The Fortran standard specifies the intrinsic subroutines 13712 1.1 mrg @code{RANDOM_SEED} to initialize the pseudo-random number 13713 1.1 mrg generator and @code{RANDOM_NUMBER} to generate pseudo-random numbers. 13714 1.1 mrg These subroutines should be used in new codes. 13715 1.1 mrg 13716 1.1 mrg Please note that in GNU Fortran, these two sets of intrinsics (@code{RAND}, 13717 1.1 mrg @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and 13718 1.1 mrg @code{RANDOM_SEED} on the other hand) access two independent 13719 1.1 mrg pseudo-random number generators. 13720 1.1 mrg 13721 1.1 mrg @item @emph{See also}: 13722 1.1.1.2 mrg @ref{RAND}, @gol 13723 1.1.1.2 mrg @ref{RANDOM_SEED}, @gol 13724 1.1.1.2 mrg @ref{RANDOM_NUMBER} 13725 1.1 mrg @end table 13726 1.1 mrg 13727 1.1 mrg 13728 1.1 mrg 13729 1.1 mrg @node STAT 13730 1.1 mrg @section @code{STAT} --- Get file status 13731 1.1 mrg @fnindex STAT 13732 1.1 mrg @cindex file system, file status 13733 1.1 mrg 13734 1.1 mrg @table @asis 13735 1.1 mrg @item @emph{Description}: 13736 1.1 mrg This function returns information about a file. No permissions are required on 13737 1.1 mrg the file itself, but execute (search) permission is required on all of the 13738 1.1 mrg directories in path that lead to the file. 13739 1.1 mrg 13740 1.1 mrg The elements that are obtained and stored in the array @code{VALUES}: 13741 1.1 mrg @multitable @columnfractions .15 .70 13742 1.1 mrg @item @code{VALUES(1)} @tab Device ID 13743 1.1 mrg @item @code{VALUES(2)} @tab Inode number 13744 1.1 mrg @item @code{VALUES(3)} @tab File mode 13745 1.1 mrg @item @code{VALUES(4)} @tab Number of links 13746 1.1 mrg @item @code{VALUES(5)} @tab Owner's uid 13747 1.1 mrg @item @code{VALUES(6)} @tab Owner's gid 13748 1.1 mrg @item @code{VALUES(7)} @tab ID of device containing directory entry for file (0 if not available) 13749 1.1 mrg @item @code{VALUES(8)} @tab File size (bytes) 13750 1.1 mrg @item @code{VALUES(9)} @tab Last access time 13751 1.1 mrg @item @code{VALUES(10)} @tab Last modification time 13752 1.1 mrg @item @code{VALUES(11)} @tab Last file status change time 13753 1.1 mrg @item @code{VALUES(12)} @tab Preferred I/O block size (-1 if not available) 13754 1.1 mrg @item @code{VALUES(13)} @tab Number of blocks allocated (-1 if not available) 13755 1.1 mrg @end multitable 13756 1.1 mrg 13757 1.1 mrg Not all these elements are relevant on all systems. 13758 1.1 mrg If an element is not relevant, it is returned as 0. 13759 1.1 mrg 13760 1.1 mrg This intrinsic is provided in both subroutine and function forms; however, 13761 1.1 mrg only one form can be used in any given program unit. 13762 1.1 mrg 13763 1.1 mrg @item @emph{Standard}: 13764 1.1 mrg GNU extension 13765 1.1 mrg 13766 1.1 mrg @item @emph{Class}: 13767 1.1 mrg Subroutine, function 13768 1.1 mrg 13769 1.1 mrg @item @emph{Syntax}: 13770 1.1 mrg @multitable @columnfractions .80 13771 1.1 mrg @item @code{CALL STAT(NAME, VALUES [, STATUS])} 13772 1.1 mrg @item @code{STATUS = STAT(NAME, VALUES)} 13773 1.1 mrg @end multitable 13774 1.1 mrg 13775 1.1 mrg @item @emph{Arguments}: 13776 1.1 mrg @multitable @columnfractions .15 .70 13777 1.1 mrg @item @var{NAME} @tab The type shall be @code{CHARACTER}, of the 13778 1.1 mrg default kind and a valid path within the file system. 13779 1.1 mrg @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}. 13780 1.1 mrg @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 13781 1.1 mrg on success and a system specific error code otherwise. 13782 1.1 mrg @end multitable 13783 1.1 mrg 13784 1.1 mrg @item @emph{Example}: 13785 1.1 mrg @smallexample 13786 1.1 mrg PROGRAM test_stat 13787 1.1 mrg INTEGER, DIMENSION(13) :: buff 13788 1.1 mrg INTEGER :: status 13789 1.1 mrg 13790 1.1 mrg CALL STAT("/etc/passwd", buff, status) 13791 1.1 mrg 13792 1.1 mrg IF (status == 0) THEN 13793 1.1 mrg WRITE (*, FMT="('Device ID:', T30, I19)") buff(1) 13794 1.1 mrg WRITE (*, FMT="('Inode number:', T30, I19)") buff(2) 13795 1.1 mrg WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3) 13796 1.1 mrg WRITE (*, FMT="('Number of links:', T30, I19)") buff(4) 13797 1.1 mrg WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5) 13798 1.1 mrg WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6) 13799 1.1 mrg WRITE (*, FMT="('Device where located:', T30, I19)") buff(7) 13800 1.1 mrg WRITE (*, FMT="('File size:', T30, I19)") buff(8) 13801 1.1 mrg WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9)) 13802 1.1 mrg WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10)) 13803 1.1 mrg WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11)) 13804 1.1 mrg WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12) 13805 1.1 mrg WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13) 13806 1.1 mrg END IF 13807 1.1 mrg END PROGRAM 13808 1.1 mrg @end smallexample 13809 1.1 mrg 13810 1.1 mrg @item @emph{See also}: 13811 1.1.1.2 mrg To stat an open file: @gol 13812 1.1.1.2 mrg @ref{FSTAT} @gol 13813 1.1.1.2 mrg To stat a link: @gol 13814 1.1.1.2 mrg @ref{LSTAT} 13815 1.1 mrg @end table 13816 1.1 mrg 13817 1.1 mrg 13818 1.1 mrg 13819 1.1 mrg @node STORAGE_SIZE 13820 1.1 mrg @section @code{STORAGE_SIZE} --- Storage size in bits 13821 1.1 mrg @fnindex STORAGE_SIZE 13822 1.1 mrg @cindex storage size 13823 1.1 mrg 13824 1.1 mrg @table @asis 13825 1.1 mrg @item @emph{Description}: 13826 1.1 mrg Returns the storage size of argument @var{A} in bits. 13827 1.1 mrg @item @emph{Standard}: 13828 1.1 mrg Fortran 2008 and later 13829 1.1 mrg @item @emph{Class}: 13830 1.1 mrg Inquiry function 13831 1.1 mrg @item @emph{Syntax}: 13832 1.1 mrg @code{RESULT = STORAGE_SIZE(A [, KIND])} 13833 1.1 mrg 13834 1.1 mrg @item @emph{Arguments}: 13835 1.1 mrg @multitable @columnfractions .15 .70 13836 1.1 mrg @item @var{A} @tab Shall be a scalar or array of any type. 13837 1.1 mrg @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression. 13838 1.1 mrg @end multitable 13839 1.1 mrg 13840 1.1 mrg @item @emph{Return Value}: 13841 1.1 mrg The result is a scalar integer with the kind type parameter specified by KIND 13842 1.1 mrg (or default integer type if KIND is missing). The result value is the size 13843 1.1 mrg expressed in bits for an element of an array that has the dynamic type and type 13844 1.1 mrg parameters of A. 13845 1.1 mrg 13846 1.1 mrg @item @emph{See also}: 13847 1.1.1.2 mrg @ref{C_SIZEOF}, @gol 13848 1.1.1.2 mrg @ref{SIZEOF} 13849 1.1 mrg @end table 13850 1.1 mrg 13851 1.1 mrg 13852 1.1 mrg 13853 1.1 mrg @node SUM 13854 1.1 mrg @section @code{SUM} --- Sum of array elements 13855 1.1 mrg @fnindex SUM 13856 1.1 mrg @cindex array, sum 13857 1.1 mrg @cindex array, add elements 13858 1.1 mrg @cindex array, conditionally add elements 13859 1.1 mrg @cindex sum array elements 13860 1.1 mrg 13861 1.1 mrg @table @asis 13862 1.1 mrg @item @emph{Description}: 13863 1.1 mrg Adds the elements of @var{ARRAY} along dimension @var{DIM} if 13864 1.1 mrg the corresponding element in @var{MASK} is @code{TRUE}. 13865 1.1 mrg 13866 1.1 mrg @item @emph{Standard}: 13867 1.1.1.2 mrg Fortran 90 and later 13868 1.1 mrg 13869 1.1 mrg @item @emph{Class}: 13870 1.1 mrg Transformational function 13871 1.1 mrg 13872 1.1 mrg @item @emph{Syntax}: 13873 1.1 mrg @multitable @columnfractions .80 13874 1.1 mrg @item @code{RESULT = SUM(ARRAY[, MASK])} 13875 1.1 mrg @item @code{RESULT = SUM(ARRAY, DIM[, MASK])} 13876 1.1 mrg @end multitable 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{ARRAY} @tab Shall be an array of type @code{INTEGER}, 13881 1.1 mrg @code{REAL} or @code{COMPLEX}. 13882 1.1 mrg @item @var{DIM} @tab (Optional) shall be a scalar of type 13883 1.1 mrg @code{INTEGER} with a value in the range from 1 to n, where n 13884 1.1 mrg equals the rank of @var{ARRAY}. 13885 1.1 mrg @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL} 13886 1.1 mrg and either be a scalar or an array of the same shape as @var{ARRAY}. 13887 1.1 mrg @end multitable 13888 1.1 mrg 13889 1.1 mrg @item @emph{Return value}: 13890 1.1 mrg The result is of the same type as @var{ARRAY}. 13891 1.1 mrg 13892 1.1 mrg If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY} 13893 1.1 mrg is returned. Otherwise, an array of rank n-1, where n equals the rank of 13894 1.1 mrg @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM} 13895 1.1 mrg dropped is returned. 13896 1.1 mrg 13897 1.1 mrg @item @emph{Example}: 13898 1.1 mrg @smallexample 13899 1.1 mrg PROGRAM test_sum 13900 1.1 mrg INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /) 13901 1.1 mrg print *, SUM(x) ! all elements, sum = 15 13902 1.1 mrg print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9 13903 1.1 mrg END PROGRAM 13904 1.1 mrg @end smallexample 13905 1.1 mrg 13906 1.1 mrg @item @emph{See also}: 13907 1.1 mrg @ref{PRODUCT} 13908 1.1 mrg @end table 13909 1.1 mrg 13910 1.1 mrg 13911 1.1 mrg 13912 1.1 mrg @node SYMLNK 13913 1.1 mrg @section @code{SYMLNK} --- Create a symbolic link 13914 1.1 mrg @fnindex SYMLNK 13915 1.1 mrg @cindex file system, create link 13916 1.1 mrg @cindex file system, soft link 13917 1.1 mrg 13918 1.1 mrg @table @asis 13919 1.1 mrg @item @emph{Description}: 13920 1.1 mrg Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null 13921 1.1 mrg character (@code{CHAR(0)}) can be used to mark the end of the names in 13922 1.1 mrg @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file 13923 1.1 mrg names are ignored. If the @var{STATUS} argument is supplied, it 13924 1.1 mrg contains 0 on success or a nonzero error code upon return; see 13925 1.1 mrg @code{symlink(2)}. If the system does not supply @code{symlink(2)}, 13926 1.1 mrg @code{ENOSYS} is returned. 13927 1.1 mrg 13928 1.1 mrg This intrinsic is provided in both subroutine and function forms; 13929 1.1 mrg however, only one form can be used in any given program unit. 13930 1.1 mrg 13931 1.1 mrg @item @emph{Standard}: 13932 1.1 mrg GNU extension 13933 1.1 mrg 13934 1.1 mrg @item @emph{Class}: 13935 1.1 mrg Subroutine, function 13936 1.1 mrg 13937 1.1 mrg @item @emph{Syntax}: 13938 1.1 mrg @multitable @columnfractions .80 13939 1.1 mrg @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])} 13940 1.1 mrg @item @code{STATUS = SYMLNK(PATH1, PATH2)} 13941 1.1 mrg @end multitable 13942 1.1 mrg 13943 1.1 mrg @item @emph{Arguments}: 13944 1.1 mrg @multitable @columnfractions .15 .70 13945 1.1 mrg @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type. 13946 1.1 mrg @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type. 13947 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. 13948 1.1 mrg @end multitable 13949 1.1 mrg 13950 1.1 mrg @item @emph{See also}: 13951 1.1.1.2 mrg @ref{LINK}, @gol 13952 1.1.1.2 mrg @ref{UNLINK} 13953 1.1 mrg @end table 13954 1.1 mrg 13955 1.1 mrg 13956 1.1 mrg 13957 1.1 mrg @node SYSTEM 13958 1.1 mrg @section @code{SYSTEM} --- Execute a shell command 13959 1.1 mrg @fnindex SYSTEM 13960 1.1 mrg @cindex system, system call 13961 1.1 mrg 13962 1.1 mrg @table @asis 13963 1.1 mrg @item @emph{Description}: 13964 1.1 mrg Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If 13965 1.1 mrg argument @var{STATUS} is present, it contains the value returned by 13966 1.1 mrg @code{system(3)}, which is presumably 0 if the shell command succeeded. 13967 1.1 mrg Note that which shell is used to invoke the command is system-dependent 13968 1.1 mrg and environment-dependent. 13969 1.1 mrg 13970 1.1 mrg This intrinsic is provided in both subroutine and function forms; 13971 1.1 mrg however, only one form can be used in any given program unit. 13972 1.1 mrg 13973 1.1 mrg Note that the @code{system} function need not be thread-safe. It is 13974 1.1 mrg the responsibility of the user to ensure that @code{system} is not 13975 1.1 mrg called concurrently. 13976 1.1 mrg 13977 1.1 mrg @item @emph{Standard}: 13978 1.1 mrg GNU extension 13979 1.1 mrg 13980 1.1 mrg @item @emph{Class}: 13981 1.1 mrg Subroutine, function 13982 1.1 mrg 13983 1.1 mrg @item @emph{Syntax}: 13984 1.1 mrg @multitable @columnfractions .80 13985 1.1 mrg @item @code{CALL SYSTEM(COMMAND [, STATUS])} 13986 1.1 mrg @item @code{STATUS = SYSTEM(COMMAND)} 13987 1.1 mrg @end multitable 13988 1.1 mrg 13989 1.1 mrg @item @emph{Arguments}: 13990 1.1 mrg @multitable @columnfractions .15 .70 13991 1.1 mrg @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type. 13992 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. 13993 1.1 mrg @end multitable 13994 1.1 mrg 13995 1.1 mrg @item @emph{See also}: 13996 1.1 mrg @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard 13997 1.1 mrg and should considered in new code for future portability. 13998 1.1 mrg @end table 13999 1.1 mrg 14000 1.1 mrg 14001 1.1 mrg 14002 1.1 mrg @node SYSTEM_CLOCK 14003 1.1 mrg @section @code{SYSTEM_CLOCK} --- Time function 14004 1.1 mrg @fnindex SYSTEM_CLOCK 14005 1.1 mrg @cindex time, clock ticks 14006 1.1 mrg @cindex clock ticks 14007 1.1 mrg 14008 1.1 mrg @table @asis 14009 1.1 mrg @item @emph{Description}: 14010 1.1 mrg Determines the @var{COUNT} of a processor clock since an unspecified 14011 1.1 mrg time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines 14012 1.1 mrg the number of clock ticks per second. If the platform supports a 14013 1.1 mrg monotonic clock, that clock is used and can, depending on the platform 14014 1.1 mrg clock implementation, provide up to nanosecond resolution. If a 14015 1.1 mrg monotonic clock is not available, the implementation falls back to a 14016 1.1 mrg realtime clock. 14017 1.1 mrg 14018 1.1 mrg @var{COUNT_RATE} is system dependent and can vary depending on the kind of 14019 1.1 mrg the arguments. For @var{kind=4} arguments (and smaller integer kinds), 14020 1.1 mrg @var{COUNT} represents milliseconds, while for @var{kind=8} arguments (and 14021 1.1 mrg larger integer kinds), @var{COUNT} typically represents micro- or 14022 1.1 mrg nanoseconds depending on resolution of the underlying platform clock. 14023 1.1 mrg @var{COUNT_MAX} usually equals @code{HUGE(COUNT_MAX)}. Note that the 14024 1.1 mrg millisecond resolution of the @var{kind=4} version implies that the 14025 1.1 mrg @var{COUNT} will wrap around in roughly 25 days. In order to avoid issues 14026 1.1 mrg with the wrap around and for more precise timing, please use the 14027 1.1 mrg @var{kind=8} version. 14028 1.1 mrg 14029 1.1 mrg If there is no clock, or querying the clock fails, @var{COUNT} is set 14030 1.1 mrg to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are 14031 1.1 mrg set to zero. 14032 1.1 mrg 14033 1.1 mrg When running on a platform using the GNU C library (glibc) version 14034 1.1 mrg 2.16 or older, or a derivative thereof, the high resolution monotonic 14035 1.1 mrg clock is available only when linking with the @var{rt} library. This 14036 1.1 mrg can be done explicitly by adding the @code{-lrt} flag when linking the 14037 1.1 mrg application, but is also done implicitly when using OpenMP. 14038 1.1 mrg 14039 1.1 mrg On the Windows platform, the version with @var{kind=4} arguments uses 14040 1.1 mrg the @code{GetTickCount} function, whereas the @var{kind=8} version 14041 1.1 mrg uses @code{QueryPerformanceCounter} and 14042 1.1 mrg @code{QueryPerformanceCounterFrequency}. For more information, and 14043 1.1 mrg potential caveats, please see the platform documentation. 14044 1.1 mrg 14045 1.1 mrg @item @emph{Standard}: 14046 1.1.1.2 mrg Fortran 90 and later 14047 1.1 mrg 14048 1.1 mrg @item @emph{Class}: 14049 1.1 mrg Subroutine 14050 1.1 mrg 14051 1.1 mrg @item @emph{Syntax}: 14052 1.1 mrg @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])} 14053 1.1 mrg 14054 1.1 mrg @item @emph{Arguments}: 14055 1.1.1.2 mrg @multitable @columnfractions .20 .65 14056 1.1 mrg @item @var{COUNT} @tab (Optional) shall be a scalar of type 14057 1.1 mrg @code{INTEGER} with @code{INTENT(OUT)}. 14058 1.1 mrg @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type 14059 1.1 mrg @code{INTEGER} or @code{REAL}, with @code{INTENT(OUT)}. 14060 1.1 mrg @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type 14061 1.1 mrg @code{INTEGER} with @code{INTENT(OUT)}. 14062 1.1 mrg @end multitable 14063 1.1 mrg 14064 1.1 mrg @item @emph{Example}: 14065 1.1 mrg @smallexample 14066 1.1 mrg PROGRAM test_system_clock 14067 1.1 mrg INTEGER :: count, count_rate, count_max 14068 1.1 mrg CALL SYSTEM_CLOCK(count, count_rate, count_max) 14069 1.1 mrg WRITE(*,*) count, count_rate, count_max 14070 1.1 mrg END PROGRAM 14071 1.1 mrg @end smallexample 14072 1.1 mrg 14073 1.1 mrg @item @emph{See also}: 14074 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol 14075 1.1.1.2 mrg @ref{CPU_TIME} 14076 1.1 mrg @end table 14077 1.1 mrg 14078 1.1 mrg 14079 1.1 mrg 14080 1.1 mrg @node TAN 14081 1.1 mrg @section @code{TAN} --- Tangent function 14082 1.1 mrg @fnindex TAN 14083 1.1 mrg @fnindex DTAN 14084 1.1 mrg @cindex trigonometric function, tangent 14085 1.1 mrg @cindex tangent 14086 1.1 mrg 14087 1.1 mrg @table @asis 14088 1.1 mrg @item @emph{Description}: 14089 1.1 mrg @code{TAN(X)} computes the tangent of @var{X}. 14090 1.1 mrg 14091 1.1 mrg @item @emph{Standard}: 14092 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later 14093 1.1 mrg 14094 1.1 mrg @item @emph{Class}: 14095 1.1 mrg Elemental function 14096 1.1 mrg 14097 1.1 mrg @item @emph{Syntax}: 14098 1.1 mrg @code{RESULT = TAN(X)} 14099 1.1 mrg 14100 1.1 mrg @item @emph{Arguments}: 14101 1.1 mrg @multitable @columnfractions .15 .70 14102 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 14103 1.1 mrg @end multitable 14104 1.1 mrg 14105 1.1 mrg @item @emph{Return value}: 14106 1.1 mrg The return value has same type and kind as @var{X}, and its value is in radians. 14107 1.1 mrg 14108 1.1 mrg @item @emph{Example}: 14109 1.1 mrg @smallexample 14110 1.1 mrg program test_tan 14111 1.1 mrg real(8) :: x = 0.165_8 14112 1.1 mrg x = tan(x) 14113 1.1 mrg end program test_tan 14114 1.1 mrg @end smallexample 14115 1.1 mrg 14116 1.1 mrg @item @emph{Specific names}: 14117 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 14118 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 14119 1.1.1.2 mrg @item @code{TAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 14120 1.1.1.2 mrg @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 14121 1.1 mrg @end multitable 14122 1.1 mrg 14123 1.1 mrg @item @emph{See also}: 14124 1.1.1.2 mrg Inverse function: @gol 14125 1.1.1.2 mrg @ref{ATAN} @gol 14126 1.1.1.2 mrg Degrees function: @gol 14127 1.1.1.2 mrg @ref{TAND} 14128 1.1 mrg @end table 14129 1.1 mrg 14130 1.1 mrg 14131 1.1 mrg 14132 1.1 mrg @node TAND 14133 1.1 mrg @section @code{TAND} --- Tangent function, degrees 14134 1.1 mrg @fnindex TAND 14135 1.1 mrg @fnindex DTAND 14136 1.1 mrg @cindex trigonometric function, tangent, degrees 14137 1.1 mrg @cindex tangent, degrees 14138 1.1 mrg 14139 1.1 mrg @table @asis 14140 1.1 mrg @item @emph{Description}: 14141 1.1 mrg @code{TAND(X)} computes the tangent of @var{X} in degrees. 14142 1.1 mrg 14143 1.1 mrg This function is for compatibility only and should be avoided in favor of 14144 1.1 mrg standard constructs wherever possible. 14145 1.1 mrg 14146 1.1 mrg @item @emph{Standard}: 14147 1.1.1.2 mrg GNU extension, enabled with @option{-fdec-math}. 14148 1.1 mrg 14149 1.1 mrg @item @emph{Class}: 14150 1.1 mrg Elemental function 14151 1.1 mrg 14152 1.1 mrg @item @emph{Syntax}: 14153 1.1 mrg @code{RESULT = TAND(X)} 14154 1.1 mrg 14155 1.1 mrg @item @emph{Arguments}: 14156 1.1 mrg @multitable @columnfractions .15 .70 14157 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 14158 1.1 mrg @end multitable 14159 1.1 mrg 14160 1.1 mrg @item @emph{Return value}: 14161 1.1 mrg The return value has same type and kind as @var{X}, and its value is in degrees. 14162 1.1 mrg 14163 1.1 mrg @item @emph{Example}: 14164 1.1 mrg @smallexample 14165 1.1 mrg program test_tand 14166 1.1 mrg real(8) :: x = 0.165_8 14167 1.1 mrg x = tand(x) 14168 1.1 mrg end program test_tand 14169 1.1 mrg @end smallexample 14170 1.1 mrg 14171 1.1 mrg @item @emph{Specific names}: 14172 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 14173 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 14174 1.1.1.2 mrg @item @code{TAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension 14175 1.1.1.2 mrg @item @code{DTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension 14176 1.1 mrg @end multitable 14177 1.1 mrg 14178 1.1 mrg @item @emph{See also}: 14179 1.1.1.2 mrg Inverse function: @gol 14180 1.1.1.2 mrg @ref{ATAND} @gol 14181 1.1.1.2 mrg Radians function: @gol 14182 1.1.1.2 mrg @ref{TAN} 14183 1.1 mrg @end table 14184 1.1 mrg 14185 1.1 mrg 14186 1.1 mrg 14187 1.1 mrg @node TANH 14188 1.1 mrg @section @code{TANH} --- Hyperbolic tangent function 14189 1.1 mrg @fnindex TANH 14190 1.1 mrg @fnindex DTANH 14191 1.1 mrg @cindex hyperbolic tangent 14192 1.1 mrg @cindex hyperbolic function, tangent 14193 1.1 mrg @cindex tangent, hyperbolic 14194 1.1 mrg 14195 1.1 mrg @table @asis 14196 1.1 mrg @item @emph{Description}: 14197 1.1 mrg @code{TANH(X)} computes the hyperbolic tangent of @var{X}. 14198 1.1 mrg 14199 1.1 mrg @item @emph{Standard}: 14200 1.1 mrg Fortran 77 and later, for a complex argument Fortran 2008 or later 14201 1.1 mrg 14202 1.1 mrg @item @emph{Class}: 14203 1.1 mrg Elemental function 14204 1.1 mrg 14205 1.1 mrg @item @emph{Syntax}: 14206 1.1 mrg @code{X = TANH(X)} 14207 1.1 mrg 14208 1.1 mrg @item @emph{Arguments}: 14209 1.1 mrg @multitable @columnfractions .15 .70 14210 1.1 mrg @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. 14211 1.1 mrg @end multitable 14212 1.1 mrg 14213 1.1 mrg @item @emph{Return value}: 14214 1.1 mrg The return value has same type and kind as @var{X}. If @var{X} is 14215 1.1 mrg complex, the imaginary part of the result is in radians. If @var{X} 14216 1.1 mrg is @code{REAL}, the return value lies in the range 14217 1.1 mrg @math{ - 1 \leq tanh(x) \leq 1 }. 14218 1.1 mrg 14219 1.1 mrg @item @emph{Example}: 14220 1.1 mrg @smallexample 14221 1.1 mrg program test_tanh 14222 1.1 mrg real(8) :: x = 2.1_8 14223 1.1 mrg x = tanh(x) 14224 1.1 mrg end program test_tanh 14225 1.1 mrg @end smallexample 14226 1.1 mrg 14227 1.1 mrg @item @emph{Specific names}: 14228 1.1.1.3 mrg @multitable @columnfractions .20 .23 .20 .33 14229 1.1.1.3 mrg @headitem Name @tab Argument @tab Return type @tab Standard 14230 1.1.1.2 mrg @item @code{TANH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later 14231 1.1.1.2 mrg @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later 14232 1.1 mrg @end multitable 14233 1.1 mrg 14234 1.1 mrg @item @emph{See also}: 14235 1.1 mrg @ref{ATANH} 14236 1.1 mrg @end table 14237 1.1 mrg 14238 1.1 mrg 14239 1.1 mrg 14240 1.1 mrg @node THIS_IMAGE 14241 1.1 mrg @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image 14242 1.1 mrg @fnindex THIS_IMAGE 14243 1.1 mrg @cindex coarray, @code{THIS_IMAGE} 14244 1.1 mrg @cindex images, index of this image 14245 1.1 mrg 14246 1.1 mrg @table @asis 14247 1.1 mrg @item @emph{Description}: 14248 1.1 mrg Returns the cosubscript for this image. 14249 1.1 mrg 14250 1.1 mrg @item @emph{Standard}: 14251 1.1 mrg Fortran 2008 and later. With @var{DISTANCE} argument, 14252 1.1 mrg Technical Specification (TS) 18508 or later 14253 1.1 mrg 14254 1.1 mrg @item @emph{Class}: 14255 1.1 mrg Transformational function 14256 1.1 mrg 14257 1.1 mrg @item @emph{Syntax}: 14258 1.1 mrg @multitable @columnfractions .80 14259 1.1 mrg @item @code{RESULT = THIS_IMAGE()} 14260 1.1 mrg @item @code{RESULT = THIS_IMAGE(DISTANCE)} 14261 1.1 mrg @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])} 14262 1.1 mrg @end multitable 14263 1.1 mrg 14264 1.1 mrg @item @emph{Arguments}: 14265 1.1 mrg @multitable @columnfractions .15 .70 14266 1.1 mrg @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer 14267 1.1 mrg (not permitted together with @var{COARRAY}). 14268 1.1 mrg @item @var{COARRAY} @tab Coarray of any type (optional; if @var{DIM} 14269 1.1 mrg present, required). 14270 1.1 mrg @item @var{DIM} @tab default integer scalar (optional). If present, 14271 1.1 mrg @var{DIM} shall be between one and the corank of @var{COARRAY}. 14272 1.1 mrg @end multitable 14273 1.1 mrg 14274 1.1 mrg 14275 1.1 mrg @item @emph{Return value}: 14276 1.1 mrg Default integer. If @var{COARRAY} is not present, it is scalar; if 14277 1.1 mrg @var{DISTANCE} is not present or has value 0, its value is the image index on 14278 1.1 mrg the invoking image for the current team, for values smaller or equal 14279 1.1 mrg distance to the initial team, it returns the image index on the ancestor team 14280 1.1 mrg which has a distance of @var{DISTANCE} from the invoking team. If 14281 1.1 mrg @var{DISTANCE} is larger than the distance to the initial team, the image 14282 1.1 mrg index of the initial team is returned. Otherwise when the @var{COARRAY} is 14283 1.1 mrg present, if @var{DIM} is not present, a rank-1 array with corank elements is 14284 1.1 mrg returned, containing the cosubscripts for @var{COARRAY} specifying the invoking 14285 1.1 mrg image. If @var{DIM} is present, a scalar is returned, with the value of 14286 1.1 mrg the @var{DIM} element of @code{THIS_IMAGE(COARRAY)}. 14287 1.1 mrg 14288 1.1 mrg @item @emph{Example}: 14289 1.1 mrg @smallexample 14290 1.1 mrg INTEGER :: value[*] 14291 1.1 mrg INTEGER :: i 14292 1.1 mrg value = THIS_IMAGE() 14293 1.1 mrg SYNC ALL 14294 1.1 mrg IF (THIS_IMAGE() == 1) THEN 14295 1.1 mrg DO i = 1, NUM_IMAGES() 14296 1.1 mrg WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i] 14297 1.1 mrg END DO 14298 1.1 mrg END IF 14299 1.1 mrg 14300 1.1 mrg ! Check whether the current image is the initial image 14301 1.1 mrg IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE()) 14302 1.1 mrg error stop "something is rotten here" 14303 1.1 mrg @end smallexample 14304 1.1 mrg 14305 1.1 mrg @item @emph{See also}: 14306 1.1.1.2 mrg @ref{NUM_IMAGES}, @gol 14307 1.1.1.2 mrg @ref{IMAGE_INDEX} 14308 1.1 mrg @end table 14309 1.1 mrg 14310 1.1 mrg 14311 1.1 mrg 14312 1.1 mrg @node TIME 14313 1.1 mrg @section @code{TIME} --- Time function 14314 1.1 mrg @fnindex TIME 14315 1.1 mrg @cindex time, current 14316 1.1 mrg @cindex current time 14317 1.1 mrg 14318 1.1 mrg @table @asis 14319 1.1 mrg @item @emph{Description}: 14320 1.1 mrg Returns the current time encoded as an integer (in the manner of the 14321 1.1 mrg function @code{time(3)} in the C standard library). This value is 14322 1.1 mrg suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}. 14323 1.1 mrg 14324 1.1 mrg This intrinsic is not fully portable, such as to systems with 32-bit 14325 1.1 mrg @code{INTEGER} types but supporting times wider than 32 bits. Therefore, 14326 1.1 mrg the values returned by this intrinsic might be, or become, negative, or 14327 1.1 mrg numerically less than previous values, during a single run of the 14328 1.1 mrg compiled program. 14329 1.1 mrg 14330 1.1 mrg See @ref{TIME8}, for information on a similar intrinsic that might be 14331 1.1 mrg portable to more GNU Fortran implementations, though to fewer Fortran 14332 1.1 mrg compilers. 14333 1.1 mrg 14334 1.1 mrg @item @emph{Standard}: 14335 1.1 mrg GNU extension 14336 1.1 mrg 14337 1.1 mrg @item @emph{Class}: 14338 1.1 mrg Function 14339 1.1 mrg 14340 1.1 mrg @item @emph{Syntax}: 14341 1.1 mrg @code{RESULT = TIME()} 14342 1.1 mrg 14343 1.1 mrg @item @emph{Return value}: 14344 1.1 mrg The return value is a scalar of type @code{INTEGER(4)}. 14345 1.1 mrg 14346 1.1 mrg @item @emph{See also}: 14347 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol 14348 1.1.1.2 mrg @ref{CTIME}, @gol 14349 1.1.1.2 mrg @ref{GMTIME}, @gol 14350 1.1.1.2 mrg @ref{LTIME}, @gol 14351 1.1.1.2 mrg @ref{MCLOCK}, @gol 14352 1.1.1.2 mrg @ref{TIME8} 14353 1.1 mrg @end table 14354 1.1 mrg 14355 1.1 mrg 14356 1.1 mrg 14357 1.1 mrg @node TIME8 14358 1.1 mrg @section @code{TIME8} --- Time function (64-bit) 14359 1.1 mrg @fnindex TIME8 14360 1.1 mrg @cindex time, current 14361 1.1 mrg @cindex current time 14362 1.1 mrg 14363 1.1 mrg @table @asis 14364 1.1 mrg @item @emph{Description}: 14365 1.1 mrg Returns the current time encoded as an integer (in the manner of the 14366 1.1 mrg function @code{time(3)} in the C standard library). This value is 14367 1.1 mrg suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}. 14368 1.1 mrg 14369 1.1 mrg @emph{Warning:} this intrinsic does not increase the range of the timing 14370 1.1 mrg values over that returned by @code{time(3)}. On a system with a 32-bit 14371 1.1 mrg @code{time(3)}, @code{TIME8} will return a 32-bit value, even though 14372 1.1 mrg it is converted to a 64-bit @code{INTEGER(8)} value. That means 14373 1.1 mrg overflows of the 32-bit value can still occur. Therefore, the values 14374 1.1 mrg returned by this intrinsic might be or become negative or numerically 14375 1.1 mrg less than previous values during a single run of the compiled program. 14376 1.1 mrg 14377 1.1 mrg @item @emph{Standard}: 14378 1.1 mrg GNU extension 14379 1.1 mrg 14380 1.1 mrg @item @emph{Class}: 14381 1.1 mrg Function 14382 1.1 mrg 14383 1.1 mrg @item @emph{Syntax}: 14384 1.1 mrg @code{RESULT = TIME8()} 14385 1.1 mrg 14386 1.1 mrg @item @emph{Return value}: 14387 1.1 mrg The return value is a scalar of type @code{INTEGER(8)}. 14388 1.1 mrg 14389 1.1 mrg @item @emph{See also}: 14390 1.1.1.2 mrg @ref{DATE_AND_TIME}, @gol 14391 1.1.1.2 mrg @ref{CTIME}, @gol 14392 1.1.1.2 mrg @ref{GMTIME}, @gol 14393 1.1.1.2 mrg @ref{LTIME}, @gol 14394 1.1.1.2 mrg @ref{MCLOCK8}, @gol 14395 1.1.1.2 mrg @ref{TIME} 14396 1.1 mrg @end table 14397 1.1 mrg 14398 1.1 mrg 14399 1.1 mrg 14400 1.1 mrg @node TINY 14401 1.1 mrg @section @code{TINY} --- Smallest positive number of a real kind 14402 1.1 mrg @fnindex TINY 14403 1.1 mrg @cindex limits, smallest number 14404 1.1 mrg @cindex model representation, smallest number 14405 1.1 mrg 14406 1.1 mrg @table @asis 14407 1.1 mrg @item @emph{Description}: 14408 1.1 mrg @code{TINY(X)} returns the smallest positive (non zero) number 14409 1.1 mrg in the model of the type of @code{X}. 14410 1.1 mrg 14411 1.1 mrg @item @emph{Standard}: 14412 1.1.1.2 mrg Fortran 90 and later 14413 1.1 mrg 14414 1.1 mrg @item @emph{Class}: 14415 1.1 mrg Inquiry function 14416 1.1 mrg 14417 1.1 mrg @item @emph{Syntax}: 14418 1.1 mrg @code{RESULT = TINY(X)} 14419 1.1 mrg 14420 1.1 mrg @item @emph{Arguments}: 14421 1.1 mrg @multitable @columnfractions .15 .70 14422 1.1 mrg @item @var{X} @tab Shall be of type @code{REAL}. 14423 1.1 mrg @end multitable 14424 1.1 mrg 14425 1.1 mrg @item @emph{Return value}: 14426 1.1 mrg The return value is of the same type and kind as @var{X} 14427 1.1 mrg 14428 1.1 mrg @item @emph{Example}: 14429 1.1 mrg See @code{HUGE} for an example. 14430 1.1 mrg @end table 14431 1.1 mrg 14432 1.1 mrg 14433 1.1 mrg 14434 1.1 mrg @node TRAILZ 14435 1.1 mrg @section @code{TRAILZ} --- Number of trailing zero bits of an integer 14436 1.1 mrg @fnindex TRAILZ 14437 1.1 mrg @cindex zero bits 14438 1.1 mrg 14439 1.1 mrg @table @asis 14440 1.1 mrg @item @emph{Description}: 14441 1.1 mrg @code{TRAILZ} returns the number of trailing zero bits of an integer. 14442 1.1 mrg 14443 1.1 mrg @item @emph{Standard}: 14444 1.1 mrg Fortran 2008 and later 14445 1.1 mrg 14446 1.1 mrg @item @emph{Class}: 14447 1.1 mrg Elemental function 14448 1.1 mrg 14449 1.1 mrg @item @emph{Syntax}: 14450 1.1 mrg @code{RESULT = TRAILZ(I)} 14451 1.1 mrg 14452 1.1 mrg @item @emph{Arguments}: 14453 1.1 mrg @multitable @columnfractions .15 .70 14454 1.1 mrg @item @var{I} @tab Shall be of type @code{INTEGER}. 14455 1.1 mrg @end multitable 14456 1.1 mrg 14457 1.1 mrg @item @emph{Return value}: 14458 1.1 mrg The type of the return value is the default @code{INTEGER}. 14459 1.1 mrg If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}. 14460 1.1 mrg 14461 1.1 mrg @item @emph{Example}: 14462 1.1 mrg @smallexample 14463 1.1 mrg PROGRAM test_trailz 14464 1.1 mrg WRITE (*,*) TRAILZ(8) ! prints 3 14465 1.1 mrg END PROGRAM 14466 1.1 mrg @end smallexample 14467 1.1 mrg 14468 1.1 mrg @item @emph{See also}: 14469 1.1.1.2 mrg @ref{BIT_SIZE}, @gol 14470 1.1.1.2 mrg @ref{LEADZ}, @gol 14471 1.1.1.2 mrg @ref{POPPAR}, @gol 14472 1.1.1.2 mrg @ref{POPCNT} 14473 1.1 mrg @end table 14474 1.1 mrg 14475 1.1 mrg 14476 1.1 mrg 14477 1.1 mrg @node TRANSFER 14478 1.1 mrg @section @code{TRANSFER} --- Transfer bit patterns 14479 1.1 mrg @fnindex TRANSFER 14480 1.1 mrg @cindex bits, move 14481 1.1 mrg @cindex type cast 14482 1.1 mrg 14483 1.1 mrg @table @asis 14484 1.1 mrg @item @emph{Description}: 14485 1.1 mrg Interprets the bitwise representation of @var{SOURCE} in memory as if it 14486 1.1 mrg is the representation of a variable or array of the same type and type 14487 1.1 mrg parameters as @var{MOLD}. 14488 1.1 mrg 14489 1.1 mrg This is approximately equivalent to the C concept of @emph{casting} one 14490 1.1 mrg type to another. 14491 1.1 mrg 14492 1.1 mrg @item @emph{Standard}: 14493 1.1.1.2 mrg Fortran 90 and later 14494 1.1 mrg 14495 1.1 mrg @item @emph{Class}: 14496 1.1 mrg Transformational function 14497 1.1 mrg 14498 1.1 mrg @item @emph{Syntax}: 14499 1.1 mrg @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])} 14500 1.1 mrg 14501 1.1 mrg @item @emph{Arguments}: 14502 1.1 mrg @multitable @columnfractions .15 .70 14503 1.1 mrg @item @var{SOURCE} @tab Shall be a scalar or an array of any type. 14504 1.1 mrg @item @var{MOLD} @tab Shall be a scalar or an array of any type. 14505 1.1 mrg @item @var{SIZE} @tab (Optional) shall be a scalar of type 14506 1.1 mrg @code{INTEGER}. 14507 1.1 mrg @end multitable 14508 1.1 mrg 14509 1.1 mrg @item @emph{Return value}: 14510 1.1 mrg The result has the same type as @var{MOLD}, with the bit level 14511 1.1 mrg representation of @var{SOURCE}. If @var{SIZE} is present, the result is 14512 1.1 mrg a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent 14513 1.1 mrg but @var{MOLD} is an array (of any size or shape), the result is a one- 14514 1.1 mrg dimensional array of the minimum length needed to contain the entirety 14515 1.1 mrg of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent 14516 1.1 mrg and @var{MOLD} is a scalar, the result is a scalar. 14517 1.1 mrg 14518 1.1 mrg If the bitwise representation of the result is longer than that of 14519 1.1 mrg @var{SOURCE}, then the leading bits of the result correspond to those of 14520 1.1 mrg @var{SOURCE} and any trailing bits are filled arbitrarily. 14521 1.1 mrg 14522 1.1 mrg When the resulting bit representation does not correspond to a valid 14523 1.1 mrg representation of a variable of the same type as @var{MOLD}, the results 14524 1.1 mrg are undefined, and subsequent operations on the result cannot be 14525 1.1 mrg guaranteed to produce sensible behavior. For example, it is possible to 14526 1.1 mrg create @code{LOGICAL} variables for which @code{@var{VAR}} and 14527 1.1 mrg @code{.NOT.@var{VAR}} both appear to be true. 14528 1.1 mrg 14529 1.1 mrg @item @emph{Example}: 14530 1.1 mrg @smallexample 14531 1.1 mrg PROGRAM test_transfer 14532 1.1 mrg integer :: x = 2143289344 14533 1.1 mrg print *, transfer(x, 1.0) ! prints "NaN" on i686 14534 1.1 mrg END PROGRAM 14535 1.1 mrg @end smallexample 14536 1.1 mrg @end table 14537 1.1 mrg 14538 1.1 mrg 14539 1.1 mrg 14540 1.1 mrg @node TRANSPOSE 14541 1.1 mrg @section @code{TRANSPOSE} --- Transpose an array of rank two 14542 1.1 mrg @fnindex TRANSPOSE 14543 1.1 mrg @cindex array, transpose 14544 1.1 mrg @cindex matrix, transpose 14545 1.1 mrg @cindex transpose 14546 1.1 mrg 14547 1.1 mrg @table @asis 14548 1.1 mrg @item @emph{Description}: 14549 1.1 mrg Transpose an array of rank two. Element (i, j) of the result has the value 14550 1.1 mrg @code{MATRIX(j, i)}, for all i, j. 14551 1.1 mrg 14552 1.1 mrg @item @emph{Standard}: 14553 1.1.1.2 mrg Fortran 90 and later 14554 1.1 mrg 14555 1.1 mrg @item @emph{Class}: 14556 1.1 mrg Transformational function 14557 1.1 mrg 14558 1.1 mrg @item @emph{Syntax}: 14559 1.1 mrg @code{RESULT = TRANSPOSE(MATRIX)} 14560 1.1 mrg 14561 1.1 mrg @item @emph{Arguments}: 14562 1.1 mrg @multitable @columnfractions .15 .70 14563 1.1 mrg @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two. 14564 1.1 mrg @end multitable 14565 1.1 mrg 14566 1.1 mrg @item @emph{Return value}: 14567 1.1 mrg The result has the same type as @var{MATRIX}, and has shape 14568 1.1 mrg @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}. 14569 1.1 mrg @end table 14570 1.1 mrg 14571 1.1 mrg 14572 1.1 mrg 14573 1.1 mrg @node TRIM 14574 1.1 mrg @section @code{TRIM} --- Remove trailing blank characters of a string 14575 1.1 mrg @fnindex TRIM 14576 1.1 mrg @cindex string, remove trailing whitespace 14577 1.1 mrg 14578 1.1 mrg @table @asis 14579 1.1 mrg @item @emph{Description}: 14580 1.1 mrg Removes trailing blank characters of a string. 14581 1.1 mrg 14582 1.1 mrg @item @emph{Standard}: 14583 1.1.1.2 mrg Fortran 90 and later 14584 1.1 mrg 14585 1.1 mrg @item @emph{Class}: 14586 1.1 mrg Transformational function 14587 1.1 mrg 14588 1.1 mrg @item @emph{Syntax}: 14589 1.1 mrg @code{RESULT = TRIM(STRING)} 14590 1.1 mrg 14591 1.1 mrg @item @emph{Arguments}: 14592 1.1 mrg @multitable @columnfractions .15 .70 14593 1.1 mrg @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}. 14594 1.1 mrg @end multitable 14595 1.1 mrg 14596 1.1 mrg @item @emph{Return value}: 14597 1.1 mrg A scalar of type @code{CHARACTER} which length is that of @var{STRING} 14598 1.1 mrg less the number of trailing blanks. 14599 1.1 mrg 14600 1.1 mrg @item @emph{Example}: 14601 1.1 mrg @smallexample 14602 1.1 mrg PROGRAM test_trim 14603 1.1 mrg CHARACTER(len=10), PARAMETER :: s = "GFORTRAN " 14604 1.1 mrg WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks 14605 1.1 mrg END PROGRAM 14606 1.1 mrg @end smallexample 14607 1.1 mrg 14608 1.1 mrg @item @emph{See also}: 14609 1.1.1.2 mrg @ref{ADJUSTL}, @gol 14610 1.1.1.2 mrg @ref{ADJUSTR} 14611 1.1 mrg @end table 14612 1.1 mrg 14613 1.1 mrg 14614 1.1 mrg 14615 1.1 mrg @node TTYNAM 14616 1.1 mrg @section @code{TTYNAM} --- Get the name of a terminal device. 14617 1.1 mrg @fnindex TTYNAM 14618 1.1 mrg @cindex system, terminal 14619 1.1 mrg 14620 1.1 mrg @table @asis 14621 1.1 mrg @item @emph{Description}: 14622 1.1 mrg Get the name of a terminal device. For more information, 14623 1.1 mrg see @code{ttyname(3)}. 14624 1.1 mrg 14625 1.1 mrg This intrinsic is provided in both subroutine and function forms; 14626 1.1 mrg however, only one form can be used in any given program unit. 14627 1.1 mrg 14628 1.1 mrg @item @emph{Standard}: 14629 1.1 mrg GNU extension 14630 1.1 mrg 14631 1.1 mrg @item @emph{Class}: 14632 1.1 mrg Subroutine, function 14633 1.1 mrg 14634 1.1 mrg @item @emph{Syntax}: 14635 1.1 mrg @multitable @columnfractions .80 14636 1.1 mrg @item @code{CALL TTYNAM(UNIT, NAME)} 14637 1.1 mrg @item @code{NAME = TTYNAM(UNIT)} 14638 1.1 mrg @end multitable 14639 1.1 mrg 14640 1.1 mrg @item @emph{Arguments}: 14641 1.1 mrg @multitable @columnfractions .15 .70 14642 1.1 mrg @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}. 14643 1.1 mrg @item @var{NAME} @tab Shall be of type @code{CHARACTER}. 14644 1.1 mrg @end multitable 14645 1.1 mrg 14646 1.1 mrg @item @emph{Example}: 14647 1.1 mrg @smallexample 14648 1.1 mrg PROGRAM test_ttynam 14649 1.1 mrg INTEGER :: unit 14650 1.1 mrg DO unit = 1, 10 14651 1.1 mrg IF (isatty(unit=unit)) write(*,*) ttynam(unit) 14652 1.1 mrg END DO 14653 1.1 mrg END PROGRAM 14654 1.1 mrg @end smallexample 14655 1.1 mrg 14656 1.1 mrg @item @emph{See also}: 14657 1.1 mrg @ref{ISATTY} 14658 1.1 mrg @end table 14659 1.1 mrg 14660 1.1 mrg 14661 1.1 mrg 14662 1.1 mrg @node UBOUND 14663 1.1 mrg @section @code{UBOUND} --- Upper dimension bounds of an array 14664 1.1 mrg @fnindex UBOUND 14665 1.1 mrg @cindex array, upper bound 14666 1.1 mrg 14667 1.1 mrg @table @asis 14668 1.1 mrg @item @emph{Description}: 14669 1.1 mrg Returns the upper bounds of an array, or a single upper bound 14670 1.1 mrg along the @var{DIM} dimension. 14671 1.1 mrg @item @emph{Standard}: 14672 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later 14673 1.1 mrg 14674 1.1 mrg @item @emph{Class}: 14675 1.1 mrg Inquiry function 14676 1.1 mrg 14677 1.1 mrg @item @emph{Syntax}: 14678 1.1 mrg @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])} 14679 1.1 mrg 14680 1.1 mrg @item @emph{Arguments}: 14681 1.1 mrg @multitable @columnfractions .15 .70 14682 1.1 mrg @item @var{ARRAY} @tab Shall be an array, of any type. 14683 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}. 14684 1.1 mrg @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization 14685 1.1 mrg expression indicating the kind parameter of the result. 14686 1.1 mrg @end multitable 14687 1.1 mrg 14688 1.1 mrg @item @emph{Return value}: 14689 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 14690 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 14691 1.1 mrg If @var{DIM} is absent, the result is an array of the upper bounds of 14692 1.1 mrg @var{ARRAY}. If @var{DIM} is present, the result is a scalar 14693 1.1 mrg corresponding to the upper bound of the array along that dimension. If 14694 1.1 mrg @var{ARRAY} is an expression rather than a whole array or array 14695 1.1 mrg structure component, or if it has a zero extent along the relevant 14696 1.1 mrg dimension, the upper bound is taken to be the number of elements along 14697 1.1 mrg the relevant dimension. 14698 1.1 mrg 14699 1.1 mrg @item @emph{See also}: 14700 1.1.1.2 mrg @ref{LBOUND}, @gol 14701 1.1.1.2 mrg @ref{LCOBOUND} 14702 1.1 mrg @end table 14703 1.1 mrg 14704 1.1 mrg 14705 1.1 mrg 14706 1.1 mrg @node UCOBOUND 14707 1.1 mrg @section @code{UCOBOUND} --- Upper codimension bounds of an array 14708 1.1 mrg @fnindex UCOBOUND 14709 1.1 mrg @cindex coarray, upper bound 14710 1.1 mrg 14711 1.1 mrg @table @asis 14712 1.1 mrg @item @emph{Description}: 14713 1.1 mrg Returns the upper cobounds of a coarray, or a single upper cobound 14714 1.1 mrg along the @var{DIM} codimension. 14715 1.1 mrg @item @emph{Standard}: 14716 1.1 mrg Fortran 2008 and later 14717 1.1 mrg 14718 1.1 mrg @item @emph{Class}: 14719 1.1 mrg Inquiry function 14720 1.1 mrg 14721 1.1 mrg @item @emph{Syntax}: 14722 1.1 mrg @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])} 14723 1.1 mrg 14724 1.1 mrg @item @emph{Arguments}: 14725 1.1 mrg @multitable @columnfractions .15 .70 14726 1.1 mrg @item @var{ARRAY} @tab Shall be an coarray, of any type. 14727 1.1 mrg @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}. 14728 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 14729 1.1 mrg expression indicating the kind parameter of the result. 14730 1.1 mrg @end multitable 14731 1.1 mrg 14732 1.1 mrg @item @emph{Return value}: 14733 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 14734 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 14735 1.1 mrg If @var{DIM} is absent, the result is an array of the lower cobounds of 14736 1.1 mrg @var{COARRAY}. If @var{DIM} is present, the result is a scalar 14737 1.1 mrg corresponding to the lower cobound of the array along that codimension. 14738 1.1 mrg 14739 1.1 mrg @item @emph{See also}: 14740 1.1.1.2 mrg @ref{LCOBOUND}, @gol 14741 1.1.1.2 mrg @ref{LBOUND} 14742 1.1 mrg @end table 14743 1.1 mrg 14744 1.1 mrg 14745 1.1 mrg 14746 1.1 mrg @node UMASK 14747 1.1 mrg @section @code{UMASK} --- Set the file creation mask 14748 1.1 mrg @fnindex UMASK 14749 1.1 mrg @cindex file system, file creation mask 14750 1.1 mrg 14751 1.1 mrg @table @asis 14752 1.1 mrg @item @emph{Description}: 14753 1.1 mrg Sets the file creation mask to @var{MASK}. If called as a function, it 14754 1.1 mrg returns the old value. If called as a subroutine and argument @var{OLD} 14755 1.1 mrg if it is supplied, it is set to the old value. See @code{umask(2)}. 14756 1.1 mrg 14757 1.1 mrg @item @emph{Standard}: 14758 1.1 mrg GNU extension 14759 1.1 mrg 14760 1.1 mrg @item @emph{Class}: 14761 1.1 mrg Subroutine, function 14762 1.1 mrg 14763 1.1 mrg @item @emph{Syntax}: 14764 1.1 mrg @multitable @columnfractions .80 14765 1.1 mrg @item @code{CALL UMASK(MASK [, OLD])} 14766 1.1 mrg @item @code{OLD = UMASK(MASK)} 14767 1.1 mrg @end multitable 14768 1.1 mrg 14769 1.1 mrg @item @emph{Arguments}: 14770 1.1 mrg @multitable @columnfractions .15 .70 14771 1.1 mrg @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}. 14772 1.1 mrg @item @var{OLD} @tab (Optional) Shall be a scalar of type 14773 1.1 mrg @code{INTEGER}. 14774 1.1 mrg @end multitable 14775 1.1 mrg 14776 1.1 mrg @end table 14777 1.1 mrg 14778 1.1 mrg 14779 1.1 mrg 14780 1.1 mrg @node UNLINK 14781 1.1 mrg @section @code{UNLINK} --- Remove a file from the file system 14782 1.1 mrg @fnindex UNLINK 14783 1.1 mrg @cindex file system, remove file 14784 1.1 mrg 14785 1.1 mrg @table @asis 14786 1.1 mrg @item @emph{Description}: 14787 1.1 mrg Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be 14788 1.1 mrg used to mark the end of the name in @var{PATH}; otherwise, trailing 14789 1.1 mrg blanks in the file name are ignored. If the @var{STATUS} argument is 14790 1.1 mrg supplied, it contains 0 on success or a nonzero error code upon return; 14791 1.1 mrg see @code{unlink(2)}. 14792 1.1 mrg 14793 1.1 mrg This intrinsic is provided in both subroutine and function forms; 14794 1.1 mrg however, only one form can be used in any given program unit. 14795 1.1 mrg 14796 1.1 mrg @item @emph{Standard}: 14797 1.1 mrg GNU extension 14798 1.1 mrg 14799 1.1 mrg @item @emph{Class}: 14800 1.1 mrg Subroutine, function 14801 1.1 mrg 14802 1.1 mrg @item @emph{Syntax}: 14803 1.1 mrg @multitable @columnfractions .80 14804 1.1 mrg @item @code{CALL UNLINK(PATH [, STATUS])} 14805 1.1 mrg @item @code{STATUS = UNLINK(PATH)} 14806 1.1 mrg @end multitable 14807 1.1 mrg 14808 1.1 mrg @item @emph{Arguments}: 14809 1.1 mrg @multitable @columnfractions .15 .70 14810 1.1 mrg @item @var{PATH} @tab Shall be of default @code{CHARACTER} type. 14811 1.1 mrg @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type. 14812 1.1 mrg @end multitable 14813 1.1 mrg 14814 1.1 mrg @item @emph{See also}: 14815 1.1.1.2 mrg @ref{LINK}, @gol 14816 1.1.1.2 mrg @ref{SYMLNK} 14817 1.1 mrg @end table 14818 1.1 mrg 14819 1.1 mrg 14820 1.1 mrg 14821 1.1 mrg @node UNPACK 14822 1.1 mrg @section @code{UNPACK} --- Unpack an array of rank one into an array 14823 1.1 mrg @fnindex UNPACK 14824 1.1 mrg @cindex array, unpacking 14825 1.1 mrg @cindex array, increase dimension 14826 1.1 mrg @cindex array, scatter elements 14827 1.1 mrg 14828 1.1 mrg @table @asis 14829 1.1 mrg @item @emph{Description}: 14830 1.1 mrg Store the elements of @var{VECTOR} in an array of higher rank. 14831 1.1 mrg 14832 1.1 mrg @item @emph{Standard}: 14833 1.1.1.2 mrg Fortran 90 and later 14834 1.1 mrg 14835 1.1 mrg @item @emph{Class}: 14836 1.1 mrg Transformational function 14837 1.1 mrg 14838 1.1 mrg @item @emph{Syntax}: 14839 1.1 mrg @code{RESULT = UNPACK(VECTOR, MASK, FIELD)} 14840 1.1 mrg 14841 1.1 mrg @item @emph{Arguments}: 14842 1.1 mrg @multitable @columnfractions .15 .70 14843 1.1 mrg @item @var{VECTOR} @tab Shall be an array of any type and rank one. It 14844 1.1 mrg shall have at least as many elements as @var{MASK} has @code{TRUE} values. 14845 1.1 mrg @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}. 14846 1.1 mrg @item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have 14847 1.1 mrg the same shape as @var{MASK}. 14848 1.1 mrg @end multitable 14849 1.1 mrg 14850 1.1 mrg @item @emph{Return value}: 14851 1.1 mrg The resulting array corresponds to @var{FIELD} with @code{TRUE} elements 14852 1.1 mrg of @var{MASK} replaced by values from @var{VECTOR} in array element order. 14853 1.1 mrg 14854 1.1 mrg @item @emph{Example}: 14855 1.1 mrg @smallexample 14856 1.1 mrg PROGRAM test_unpack 14857 1.1 mrg integer :: vector(2) = (/1,1/) 14858 1.1 mrg logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /) 14859 1.1 mrg integer :: field(2,2) = 0, unity(2,2) 14860 1.1 mrg 14861 1.1 mrg ! result: unity matrix 14862 1.1 mrg unity = unpack(vector, reshape(mask, (/2,2/)), field) 14863 1.1 mrg END PROGRAM 14864 1.1 mrg @end smallexample 14865 1.1 mrg 14866 1.1 mrg @item @emph{See also}: 14867 1.1.1.2 mrg @ref{PACK}, @gol 14868 1.1.1.2 mrg @ref{SPREAD} 14869 1.1 mrg @end table 14870 1.1 mrg 14871 1.1 mrg 14872 1.1 mrg 14873 1.1 mrg @node VERIFY 14874 1.1 mrg @section @code{VERIFY} --- Scan a string for characters not a given set 14875 1.1 mrg @fnindex VERIFY 14876 1.1 mrg @cindex string, find missing set 14877 1.1 mrg 14878 1.1 mrg @table @asis 14879 1.1 mrg @item @emph{Description}: 14880 1.1 mrg Verifies that all the characters in @var{STRING} belong to the set of 14881 1.1 mrg characters in @var{SET}. 14882 1.1 mrg 14883 1.1 mrg If @var{BACK} is either absent or equals @code{FALSE}, this function 14884 1.1 mrg returns the position of the leftmost character of @var{STRING} that is 14885 1.1 mrg not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost 14886 1.1 mrg position is returned. If all characters of @var{STRING} are found in 14887 1.1 mrg @var{SET}, the result is zero. 14888 1.1 mrg 14889 1.1 mrg @item @emph{Standard}: 14890 1.1.1.2 mrg Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later 14891 1.1 mrg 14892 1.1 mrg @item @emph{Class}: 14893 1.1 mrg Elemental function 14894 1.1 mrg 14895 1.1 mrg @item @emph{Syntax}: 14896 1.1 mrg @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])} 14897 1.1 mrg 14898 1.1 mrg @item @emph{Arguments}: 14899 1.1 mrg @multitable @columnfractions .15 .70 14900 1.1 mrg @item @var{STRING} @tab Shall be of type @code{CHARACTER}. 14901 1.1 mrg @item @var{SET} @tab Shall be of type @code{CHARACTER}. 14902 1.1 mrg @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}. 14903 1.1 mrg @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization 14904 1.1 mrg expression indicating the kind parameter of the result. 14905 1.1 mrg @end multitable 14906 1.1 mrg 14907 1.1 mrg @item @emph{Return value}: 14908 1.1 mrg The return value is of type @code{INTEGER} and of kind @var{KIND}. If 14909 1.1 mrg @var{KIND} is absent, the return value is of default integer kind. 14910 1.1 mrg 14911 1.1 mrg @item @emph{Example}: 14912 1.1 mrg @smallexample 14913 1.1 mrg PROGRAM test_verify 14914 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F' 14915 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R' 14916 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F' 14917 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N' 14918 1.1 mrg WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none 14919 1.1 mrg END PROGRAM 14920 1.1 mrg @end smallexample 14921 1.1 mrg 14922 1.1 mrg @item @emph{See also}: 14923 1.1.1.2 mrg @ref{SCAN}, @gol 14924 1.1.1.2 mrg @ref{INDEX intrinsic} 14925 1.1 mrg @end table 14926 1.1 mrg 14927 1.1 mrg 14928 1.1 mrg 14929 1.1 mrg @node XOR 14930 1.1 mrg @section @code{XOR} --- Bitwise logical exclusive OR 14931 1.1 mrg @fnindex XOR 14932 1.1 mrg @cindex bitwise logical exclusive or 14933 1.1 mrg @cindex logical exclusive or, bitwise 14934 1.1 mrg 14935 1.1 mrg @table @asis 14936 1.1 mrg @item @emph{Description}: 14937 1.1 mrg Bitwise logical exclusive or. 14938 1.1 mrg 14939 1.1 mrg This intrinsic routine is provided for backwards compatibility with 14940 1.1 mrg GNU Fortran 77. For integer arguments, programmers should consider 14941 1.1 mrg the use of the @ref{IEOR} intrinsic and for logical arguments the 14942 1.1 mrg @code{.NEQV.} operator, which are both defined by the Fortran standard. 14943 1.1 mrg 14944 1.1 mrg @item @emph{Standard}: 14945 1.1 mrg GNU extension 14946 1.1 mrg 14947 1.1 mrg @item @emph{Class}: 14948 1.1 mrg Function 14949 1.1 mrg 14950 1.1 mrg @item @emph{Syntax}: 14951 1.1 mrg @code{RESULT = XOR(I, J)} 14952 1.1 mrg 14953 1.1 mrg @item @emph{Arguments}: 14954 1.1 mrg @multitable @columnfractions .15 .70 14955 1.1 mrg @item @var{I} @tab The type shall be either a scalar @code{INTEGER} 14956 1.1 mrg type or a scalar @code{LOGICAL} type or a boz-literal-constant. 14957 1.1 mrg @item @var{J} @tab The type shall be the same as the type of @var{I} or 14958 1.1 mrg a boz-literal-constant. @var{I} and @var{J} shall not both be 14959 1.1 mrg boz-literal-constants. If either @var{I} and @var{J} is a 14960 1.1 mrg boz-literal-constant, then the other argument must be a scalar @code{INTEGER}. 14961 1.1 mrg @end multitable 14962 1.1 mrg 14963 1.1 mrg @item @emph{Return value}: 14964 1.1 mrg The return type is either a scalar @code{INTEGER} or a scalar 14965 1.1 mrg @code{LOGICAL}. If the kind type parameters differ, then the 14966 1.1 mrg smaller kind type is implicitly converted to larger kind, and the 14967 1.1 mrg return has the larger kind. A boz-literal-constant is 14968 1.1 mrg converted to an @code{INTEGER} with the kind type parameter of 14969 1.1 mrg the other argument as-if a call to @ref{INT} occurred. 14970 1.1 mrg 14971 1.1 mrg @item @emph{Example}: 14972 1.1 mrg @smallexample 14973 1.1 mrg PROGRAM test_xor 14974 1.1 mrg LOGICAL :: T = .TRUE., F = .FALSE. 14975 1.1 mrg INTEGER :: a, b 14976 1.1 mrg DATA a / Z'F' /, b / Z'3' / 14977 1.1 mrg 14978 1.1 mrg WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F) 14979 1.1 mrg WRITE (*,*) XOR(a, b) 14980 1.1 mrg END PROGRAM 14981 1.1 mrg @end smallexample 14982 1.1 mrg 14983 1.1 mrg @item @emph{See also}: 14984 1.1.1.2 mrg Fortran 95 elemental function: @gol 14985 1.1.1.2 mrg @ref{IEOR} 14986 1.1 mrg @end table 14987 1.1 mrg 14988 1.1 mrg 14989 1.1 mrg 14990 1.1 mrg @node Intrinsic Modules 14991 1.1 mrg @chapter Intrinsic Modules 14992 1.1 mrg @cindex intrinsic Modules 14993 1.1 mrg 14994 1.1 mrg @menu 14995 1.1 mrg * ISO_FORTRAN_ENV:: 14996 1.1 mrg * ISO_C_BINDING:: 14997 1.1 mrg * IEEE modules:: 14998 1.1 mrg * OpenMP Modules OMP_LIB and OMP_LIB_KINDS:: 14999 1.1 mrg * OpenACC Module OPENACC:: 15000 1.1 mrg @end menu 15001 1.1 mrg 15002 1.1 mrg @node ISO_FORTRAN_ENV 15003 1.1 mrg @section @code{ISO_FORTRAN_ENV} 15004 1.1 mrg @table @asis 15005 1.1 mrg @item @emph{Standard}: 15006 1.1 mrg Fortran 2003 and later, except when otherwise noted 15007 1.1 mrg @end table 15008 1.1 mrg 15009 1.1 mrg The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer 15010 1.1 mrg named constants: 15011 1.1 mrg 15012 1.1 mrg @table @asis 15013 1.1 mrg @item @code{ATOMIC_INT_KIND}: 15014 1.1 mrg Default-kind integer constant to be used as kind parameter when defining 15015 1.1 mrg integer variables used in atomic operations. (Fortran 2008 or later.) 15016 1.1 mrg 15017 1.1 mrg @item @code{ATOMIC_LOGICAL_KIND}: 15018 1.1 mrg Default-kind integer constant to be used as kind parameter when defining 15019 1.1 mrg logical variables used in atomic operations. (Fortran 2008 or later.) 15020 1.1 mrg 15021 1.1 mrg @item @code{CHARACTER_KINDS}: 15022 1.1 mrg Default-kind integer constant array of rank one containing the supported kind 15023 1.1 mrg parameters of the @code{CHARACTER} type. (Fortran 2008 or later.) 15024 1.1 mrg 15025 1.1 mrg @item @code{CHARACTER_STORAGE_SIZE}: 15026 1.1 mrg Size in bits of the character storage unit. 15027 1.1 mrg 15028 1.1 mrg @item @code{ERROR_UNIT}: 15029 1.1 mrg Identifies the preconnected unit used for error reporting. 15030 1.1 mrg 15031 1.1 mrg @item @code{FILE_STORAGE_SIZE}: 15032 1.1 mrg Size in bits of the file-storage unit. 15033 1.1 mrg 15034 1.1 mrg @item @code{INPUT_UNIT}: 15035 1.1 mrg Identifies the preconnected unit identified by the asterisk 15036 1.1 mrg (@code{*}) in @code{READ} statement. 15037 1.1 mrg 15038 1.1 mrg @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}: 15039 1.1 mrg Kind type parameters to specify an INTEGER type with a storage 15040 1.1 mrg size of 16, 32, and 64 bits. It is negative if a target platform 15041 1.1 mrg does not support the particular kind. (Fortran 2008 or later.) 15042 1.1 mrg 15043 1.1 mrg @item @code{INTEGER_KINDS}: 15044 1.1 mrg Default-kind integer constant array of rank one containing the supported kind 15045 1.1 mrg parameters of the @code{INTEGER} type. (Fortran 2008 or later.) 15046 1.1 mrg 15047 1.1 mrg @item @code{IOSTAT_END}: 15048 1.1 mrg The value assigned to the variable passed to the @code{IOSTAT=} specifier of 15049 1.1 mrg an input/output statement if an end-of-file condition occurred. 15050 1.1 mrg 15051 1.1 mrg @item @code{IOSTAT_EOR}: 15052 1.1 mrg The value assigned to the variable passed to the @code{IOSTAT=} specifier of 15053 1.1 mrg an input/output statement if an end-of-record condition occurred. 15054 1.1 mrg 15055 1.1 mrg @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}: 15056 1.1 mrg Scalar default-integer constant, used by @code{INQUIRE} for the 15057 1.1 mrg @code{IOSTAT=} specifier to denote an that a unit number identifies an 15058 1.1 mrg internal unit. (Fortran 2008 or later.) 15059 1.1 mrg 15060 1.1 mrg @item @code{NUMERIC_STORAGE_SIZE}: 15061 1.1 mrg The size in bits of the numeric storage unit. 15062 1.1 mrg 15063 1.1 mrg @item @code{LOGICAL_KINDS}: 15064 1.1 mrg Default-kind integer constant array of rank one containing the supported kind 15065 1.1 mrg parameters of the @code{LOGICAL} type. (Fortran 2008 or later.) 15066 1.1 mrg 15067 1.1 mrg @item @code{OUTPUT_UNIT}: 15068 1.1 mrg Identifies the preconnected unit identified by the asterisk 15069 1.1 mrg (@code{*}) in @code{WRITE} statement. 15070 1.1 mrg 15071 1.1 mrg @item @code{REAL32}, @code{REAL64}, @code{REAL128}: 15072 1.1 mrg Kind type parameters to specify a REAL type with a storage 15073 1.1 mrg size of 32, 64, and 128 bits. It is negative if a target platform 15074 1.1 mrg does not support the particular kind. (Fortran 2008 or later.) 15075 1.1 mrg 15076 1.1 mrg @item @code{REAL_KINDS}: 15077 1.1 mrg Default-kind integer constant array of rank one containing the supported kind 15078 1.1 mrg parameters of the @code{REAL} type. (Fortran 2008 or later.) 15079 1.1 mrg 15080 1.1 mrg @item @code{STAT_LOCKED}: 15081 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{LOCK} to 15082 1.1 mrg denote that the lock variable is locked by the executing image. (Fortran 2008 15083 1.1 mrg or later.) 15084 1.1 mrg 15085 1.1 mrg @item @code{STAT_LOCKED_OTHER_IMAGE}: 15086 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to 15087 1.1 mrg denote that the lock variable is locked by another image. (Fortran 2008 or 15088 1.1 mrg later.) 15089 1.1 mrg 15090 1.1 mrg @item @code{STAT_STOPPED_IMAGE}: 15091 1.1 mrg Positive, scalar default-integer constant used as STAT= return value if the 15092 1.1 mrg argument in the statement requires synchronisation with an image, which has 15093 1.1 mrg initiated the termination of the execution. (Fortran 2008 or later.) 15094 1.1 mrg 15095 1.1 mrg @item @code{STAT_FAILED_IMAGE}: 15096 1.1 mrg Positive, scalar default-integer constant used as STAT= return value if the 15097 1.1 mrg argument in the statement requires communication with an image, which has 15098 1.1 mrg is in the failed state. (TS 18508 or later.) 15099 1.1 mrg 15100 1.1 mrg @item @code{STAT_UNLOCKED}: 15101 1.1 mrg Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to 15102 1.1 mrg denote that the lock variable is unlocked. (Fortran 2008 or later.) 15103 1.1 mrg @end table 15104 1.1 mrg 15105 1.1 mrg The module provides the following derived type: 15106 1.1 mrg 15107 1.1 mrg @table @asis 15108 1.1 mrg @item @code{LOCK_TYPE}: 15109 1.1 mrg Derived type with private components to be use with the @code{LOCK} and 15110 1.1 mrg @code{UNLOCK} statement. A variable of its type has to be always declared 15111 1.1 mrg as coarray and may not appear in a variable-definition context. 15112 1.1 mrg (Fortran 2008 or later.) 15113 1.1 mrg @end table 15114 1.1 mrg 15115 1.1 mrg The module also provides the following intrinsic procedures: 15116 1.1 mrg @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}. 15117 1.1 mrg 15118 1.1 mrg 15119 1.1 mrg 15120 1.1 mrg @node ISO_C_BINDING 15121 1.1 mrg @section @code{ISO_C_BINDING} 15122 1.1 mrg @table @asis 15123 1.1 mrg @item @emph{Standard}: 15124 1.1 mrg Fortran 2003 and later, GNU extensions 15125 1.1 mrg @end table 15126 1.1 mrg 15127 1.1 mrg The following intrinsic procedures are provided by the module; their 15128 1.1 mrg definition can be found in the section Intrinsic Procedures of this 15129 1.1 mrg manual. 15130 1.1 mrg 15131 1.1 mrg @table @asis 15132 1.1 mrg @item @code{C_ASSOCIATED} 15133 1.1 mrg @item @code{C_F_POINTER} 15134 1.1 mrg @item @code{C_F_PROCPOINTER} 15135 1.1 mrg @item @code{C_FUNLOC} 15136 1.1 mrg @item @code{C_LOC} 15137 1.1 mrg @item @code{C_SIZEOF} 15138 1.1 mrg @end table 15139 1.1 mrg @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF, 15140 1.1 mrg @c don't really know why. 15141 1.1 mrg 15142 1.1 mrg The @code{ISO_C_BINDING} module provides the following named constants of 15143 1.1 mrg type default integer, which can be used as KIND type parameters. 15144 1.1 mrg 15145 1.1 mrg In addition to the integer named constants required by the Fortran 2003 15146 1.1 mrg standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an 15147 1.1 mrg extension named constants for the 128-bit integer types supported by the 15148 1.1 mrg C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}. 15149 1.1.1.3 mrg Furthermore, if @code{_Float128} is supported in C, the named constants 15150 1.1.1.3 mrg @code{C_FLOAT128} and @code{C_FLOAT128_COMPLEX} are defined. 15151 1.1 mrg 15152 1.1.1.3 mrg @multitable @columnfractions .19 .32 .34 .15 15153 1.1.1.3 mrg @headitem Fortran Type @tab Named constant @tab C type @tab Extension 15154 1.1 mrg @item @code{INTEGER}@tab @code{C_INT} @tab @code{int} 15155 1.1 mrg @item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int} 15156 1.1 mrg @item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int} 15157 1.1 mrg @item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int} 15158 1.1 mrg @item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char} 15159 1.1 mrg @item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t} 15160 1.1 mrg @item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t} 15161 1.1 mrg @item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t} 15162 1.1 mrg @item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t} 15163 1.1 mrg @item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t} 15164 1.1 mrg @item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext. 15165 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t} 15166 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t} 15167 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t} 15168 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t} 15169 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext. 15170 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t} 15171 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t} 15172 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t} 15173 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t} 15174 1.1 mrg @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext. 15175 1.1 mrg @item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t} 15176 1.1 mrg @item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t} 15177 1.1 mrg @item @code{INTEGER}@tab @code{C_PTRDIFF_T} @tab @code{ptrdiff_t} @tab TS 29113 15178 1.1 mrg @item @code{REAL} @tab @code{C_FLOAT} @tab @code{float} 15179 1.1 mrg @item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double} 15180 1.1 mrg @item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double} 15181 1.1.1.3 mrg @item @code{REAL} @tab @code{C_FLOAT128} @tab @code{_Float128} @tab Ext. 15182 1.1 mrg @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex} 15183 1.1 mrg @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex} 15184 1.1 mrg @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex} 15185 1.1.1.3 mrg @item @code{COMPLEX}@tab @code{C_FLOAT128_COMPLEX} @tab @code{_Float128 _Complex} @tab Ext. 15186 1.1 mrg @item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool} 15187 1.1 mrg @item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char} 15188 1.1 mrg @end multitable 15189 1.1 mrg 15190 1.1 mrg Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)} 15191 1.1 mrg are defined. 15192 1.1 mrg 15193 1.1 mrg @multitable @columnfractions .20 .45 .15 15194 1.1.1.3 mrg @headitem Name @tab C definition @tab Value 15195 1.1 mrg @item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'} 15196 1.1 mrg @item @code{C_ALERT} @tab alert @tab @code{'\a'} 15197 1.1 mrg @item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'} 15198 1.1 mrg @item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'} 15199 1.1 mrg @item @code{C_NEW_LINE} @tab new line @tab @code{'\n'} 15200 1.1 mrg @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'} 15201 1.1 mrg @item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'} 15202 1.1 mrg @item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'} 15203 1.1 mrg @end multitable 15204 1.1 mrg 15205 1.1 mrg Moreover, the following two named constants are defined: 15206 1.1 mrg 15207 1.1 mrg @multitable @columnfractions .20 .80 15208 1.1.1.3 mrg @headitem Name @tab Type 15209 1.1 mrg @item @code{C_NULL_PTR} @tab @code{C_PTR} 15210 1.1 mrg @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR} 15211 1.1 mrg @end multitable 15212 1.1 mrg 15213 1.1 mrg Both are equivalent to the value @code{NULL} in C. 15214 1.1 mrg 15215 1.1 mrg 15216 1.1 mrg 15217 1.1 mrg @node IEEE modules 15218 1.1 mrg @section IEEE modules: @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES} 15219 1.1 mrg @table @asis 15220 1.1 mrg @item @emph{Standard}: 15221 1.1 mrg Fortran 2003 and later 15222 1.1 mrg @end table 15223 1.1 mrg 15224 1.1 mrg The @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES} 15225 1.1 mrg intrinsic modules provide support for exceptions and IEEE arithmetic, as 15226 1.1 mrg defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard 15227 1.1 mrg (@emph{Binary floating-point arithmetic for microprocessor systems}). These 15228 1.1 mrg modules are only provided on the following supported platforms: 15229 1.1 mrg 15230 1.1 mrg @itemize @bullet 15231 1.1 mrg @item i386 and x86_64 processors 15232 1.1 mrg @item platforms which use the GNU C Library (glibc) 15233 1.1 mrg @item platforms with support for SysV/386 routines for floating point 15234 1.1 mrg interface (including Solaris and BSDs) 15235 1.1 mrg @item platforms with the AIX OS 15236 1.1 mrg @end itemize 15237 1.1 mrg 15238 1.1 mrg For full compliance with the Fortran standards, code using the 15239 1.1 mrg @code{IEEE_EXCEPTIONS} or @code{IEEE_ARITHMETIC} modules should be compiled 15240 1.1 mrg with the following options: @code{-fno-unsafe-math-optimizations 15241 1.1 mrg -frounding-math -fsignaling-nans}. 15242 1.1 mrg 15243 1.1 mrg 15244 1.1 mrg 15245 1.1 mrg @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS 15246 1.1 mrg @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS} 15247 1.1 mrg @table @asis 15248 1.1 mrg @item @emph{Standard}: 15249 1.1.1.3 mrg OpenMP Application Program Interface v4.5, 15250 1.1.1.3 mrg OpenMP Application Program Interface v5.0 (partially supported) and 15251 1.1.1.3 mrg OpenMP Application Program Interface v5.1 (partially supported). 15252 1.1 mrg @end table 15253 1.1 mrg 15254 1.1 mrg The OpenMP Fortran runtime library routines are provided both in 15255 1.1.1.3 mrg a form of two Fortran modules, named @code{OMP_LIB} and 15256 1.1 mrg @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named 15257 1.1 mrg @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found 15258 1.1 mrg in the @ref{Top,,Introduction,libgomp,GNU Offloading and Multi 15259 1.1 mrg Processing Runtime Library} manual, 15260 1.1 mrg the named constants defined in the modules are listed 15261 1.1 mrg below. 15262 1.1 mrg 15263 1.1 mrg For details refer to the actual 15264 1.1.1.3 mrg @uref{https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf, 15265 1.1.1.3 mrg OpenMP Application Program Interface v4.5} and 15266 1.1.1.3 mrg @uref{https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf, 15267 1.1.1.3 mrg OpenMP Application Program Interface v5.0}. 15268 1.1 mrg 15269 1.1 mrg @code{OMP_LIB_KINDS} provides the following scalar default-integer 15270 1.1 mrg named constants: 15271 1.1 mrg 15272 1.1 mrg @table @asis 15273 1.1.1.3 mrg @item @code{omp_allocator_handle_kind} 15274 1.1.1.3 mrg @item @code{omp_alloctrait_key_kind} 15275 1.1.1.3 mrg @item @code{omp_alloctrait_val_kind} 15276 1.1.1.3 mrg @item @code{omp_depend_kind} 15277 1.1 mrg @item @code{omp_lock_kind} 15278 1.1 mrg @item @code{omp_lock_hint_kind} 15279 1.1 mrg @item @code{omp_nest_lock_kind} 15280 1.1 mrg @item @code{omp_pause_resource_kind} 15281 1.1.1.3 mrg @item @code{omp_memspace_handle_kind} 15282 1.1 mrg @item @code{omp_proc_bind_kind} 15283 1.1 mrg @item @code{omp_sched_kind} 15284 1.1.1.3 mrg @item @code{omp_sync_hint_kind} 15285 1.1 mrg @end table 15286 1.1 mrg 15287 1.1 mrg @code{OMP_LIB} provides the scalar default-integer 15288 1.1 mrg named constant @code{openmp_version} with a value of the form 15289 1.1 mrg @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month 15290 1.1 mrg of the OpenMP version; for OpenMP v4.5 the value is @code{201511}. 15291 1.1 mrg 15292 1.1.1.3 mrg The following derived type: 15293 1.1.1.3 mrg 15294 1.1.1.3 mrg @table @asis 15295 1.1.1.3 mrg @item @code{omp_alloctrait} 15296 1.1.1.3 mrg @end table 15297 1.1.1.3 mrg 15298 1.1 mrg The following scalar integer named constants of the 15299 1.1 mrg kind @code{omp_sched_kind}: 15300 1.1 mrg 15301 1.1 mrg @table @asis 15302 1.1 mrg @item @code{omp_sched_static} 15303 1.1 mrg @item @code{omp_sched_dynamic} 15304 1.1 mrg @item @code{omp_sched_guided} 15305 1.1 mrg @item @code{omp_sched_auto} 15306 1.1 mrg @end table 15307 1.1 mrg 15308 1.1.1.3 mrg And the following scalar integer named constants of the 15309 1.1 mrg kind @code{omp_proc_bind_kind}: 15310 1.1 mrg 15311 1.1 mrg @table @asis 15312 1.1 mrg @item @code{omp_proc_bind_false} 15313 1.1 mrg @item @code{omp_proc_bind_true} 15314 1.1.1.3 mrg @item @code{omp_proc_bind_primary} 15315 1.1 mrg @item @code{omp_proc_bind_master} 15316 1.1 mrg @item @code{omp_proc_bind_close} 15317 1.1 mrg @item @code{omp_proc_bind_spread} 15318 1.1 mrg @end table 15319 1.1 mrg 15320 1.1 mrg The following scalar integer named constants are of the 15321 1.1 mrg kind @code{omp_lock_hint_kind}: 15322 1.1 mrg 15323 1.1 mrg @table @asis 15324 1.1 mrg @item @code{omp_lock_hint_none} 15325 1.1 mrg @item @code{omp_lock_hint_uncontended} 15326 1.1 mrg @item @code{omp_lock_hint_contended} 15327 1.1 mrg @item @code{omp_lock_hint_nonspeculative} 15328 1.1 mrg @item @code{omp_lock_hint_speculative} 15329 1.1.1.3 mrg @item @code{omp_sync_hint_none} 15330 1.1.1.3 mrg @item @code{omp_sync_hint_uncontended} 15331 1.1.1.3 mrg @item @code{omp_sync_hint_contended} 15332 1.1.1.3 mrg @item @code{omp_sync_hint_nonspeculative} 15333 1.1.1.3 mrg @item @code{omp_sync_hint_speculative} 15334 1.1 mrg @end table 15335 1.1 mrg 15336 1.1 mrg And the following two scalar integer named constants are of the 15337 1.1 mrg kind @code{omp_pause_resource_kind}: 15338 1.1 mrg 15339 1.1 mrg @table @asis 15340 1.1 mrg @item @code{omp_pause_soft} 15341 1.1 mrg @item @code{omp_pause_hard} 15342 1.1 mrg @end table 15343 1.1 mrg 15344 1.1.1.3 mrg The following scalar integer named constants are of the kind 15345 1.1.1.3 mrg @code{omp_alloctrait_key_kind}: 15346 1.1.1.3 mrg 15347 1.1.1.3 mrg @table @asis 15348 1.1.1.3 mrg @item @code{omp_atk_sync_hint} 15349 1.1.1.3 mrg @item @code{omp_atk_alignment} 15350 1.1.1.3 mrg @item @code{omp_atk_access} 15351 1.1.1.3 mrg @item @code{omp_atk_pool_size} 15352 1.1.1.3 mrg @item @code{omp_atk_fallback} 15353 1.1.1.3 mrg @item @code{omp_atk_fb_data} 15354 1.1.1.3 mrg @item @code{omp_atk_pinned} 15355 1.1.1.3 mrg @item @code{omp_atk_partition} 15356 1.1.1.3 mrg @end table 15357 1.1.1.3 mrg 15358 1.1.1.3 mrg The following scalar integer named constants are of the kind 15359 1.1.1.3 mrg @code{omp_alloctrait_val_kind}: 15360 1.1.1.3 mrg 15361 1.1.1.3 mrg @table @asis 15362 1.1.1.3 mrg @code{omp_alloctrait_key_kind}: 15363 1.1.1.3 mrg @item @code{omp_atv_default} 15364 1.1.1.3 mrg @item @code{omp_atv_false} 15365 1.1.1.3 mrg @item @code{omp_atv_true} 15366 1.1.1.3 mrg @item @code{omp_atv_contended} 15367 1.1.1.3 mrg @item @code{omp_atv_uncontended} 15368 1.1.1.3 mrg @item @code{omp_atv_serialized} 15369 1.1.1.3 mrg @item @code{omp_atv_sequential} 15370 1.1.1.3 mrg @item @code{omp_atv_private} 15371 1.1.1.3 mrg @item @code{omp_atv_all} 15372 1.1.1.3 mrg @item @code{omp_atv_thread} 15373 1.1.1.3 mrg @item @code{omp_atv_pteam} 15374 1.1.1.3 mrg @item @code{omp_atv_cgroup} 15375 1.1.1.3 mrg @item @code{omp_atv_default_mem_fb} 15376 1.1.1.3 mrg @item @code{omp_atv_null_fb} 15377 1.1.1.3 mrg @item @code{omp_atv_abort_fb} 15378 1.1.1.3 mrg @item @code{omp_atv_allocator_fb} 15379 1.1.1.3 mrg @item @code{omp_atv_environment} 15380 1.1.1.3 mrg @item @code{omp_atv_nearest} 15381 1.1.1.3 mrg @item @code{omp_atv_blocked} 15382 1.1.1.3 mrg @end table 15383 1.1.1.3 mrg 15384 1.1.1.3 mrg The following scalar integer named constants are of the kind 15385 1.1.1.3 mrg @code{omp_allocator_handle_kind}: 15386 1.1.1.3 mrg 15387 1.1.1.3 mrg @table @asis 15388 1.1.1.3 mrg @item @code{omp_null_allocator} 15389 1.1.1.3 mrg @item @code{omp_default_mem_alloc} 15390 1.1.1.3 mrg @item @code{omp_large_cap_mem_alloc} 15391 1.1.1.3 mrg @item @code{omp_const_mem_alloc} 15392 1.1.1.3 mrg @item @code{omp_high_bw_mem_alloc} 15393 1.1.1.3 mrg @item @code{omp_low_lat_mem_alloc} 15394 1.1.1.3 mrg @item @code{omp_cgroup_mem_alloc} 15395 1.1.1.3 mrg @item @code{omp_pteam_mem_alloc} 15396 1.1.1.3 mrg @item @code{omp_thread_mem_alloc} 15397 1.1.1.3 mrg @end table 15398 1.1.1.3 mrg 15399 1.1.1.3 mrg The following scalar integer named constants are of the kind 15400 1.1.1.3 mrg @code{omp_memspace_handle_kind}: 15401 1.1.1.3 mrg 15402 1.1.1.3 mrg @table @asis 15403 1.1.1.3 mrg @item @code{omp_default_mem_space} 15404 1.1.1.3 mrg @item @code{omp_large_cap_mem_space} 15405 1.1.1.3 mrg @item @code{omp_const_mem_space} 15406 1.1.1.3 mrg @item @code{omp_high_bw_mem_space} 15407 1.1.1.3 mrg @item @code{omp_low_lat_mem_space} 15408 1.1.1.3 mrg @end table 15409 1.1.1.3 mrg 15410 1.1.1.3 mrg 15411 1.1 mrg 15412 1.1 mrg @node OpenACC Module OPENACC 15413 1.1 mrg @section OpenACC Module @code{OPENACC} 15414 1.1 mrg @table @asis 15415 1.1 mrg @item @emph{Standard}: 15416 1.1.1.2 mrg OpenACC Application Programming Interface v2.6 15417 1.1 mrg @end table 15418 1.1 mrg 15419 1.1 mrg 15420 1.1 mrg The OpenACC Fortran runtime library routines are provided both in a 15421 1.1 mrg form of a Fortran 90 module, named @code{OPENACC}, and in form of a 15422 1.1 mrg Fortran @code{include} file named @file{openacc_lib.h}. The 15423 1.1 mrg procedures provided by @code{OPENACC} can be found in the 15424 1.1 mrg @ref{Top,,Introduction,libgomp,GNU Offloading and Multi Processing 15425 1.1 mrg Runtime Library} manual, the named constants defined in the modules 15426 1.1 mrg are listed below. 15427 1.1 mrg 15428 1.1 mrg For details refer to the actual 15429 1.1.1.3 mrg @uref{https://www.openacc.org/, 15430 1.1.1.2 mrg OpenACC Application Programming Interface v2.6}. 15431 1.1 mrg 15432 1.1 mrg @code{OPENACC} provides the scalar default-integer 15433 1.1 mrg named constant @code{openacc_version} with a value of the form 15434 1.1 mrg @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month 15435 1.1.1.2 mrg of the OpenACC version; for OpenACC v2.6 the value is @code{201711}. 15436