OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [fortran/] [intrinsic.texi] - Blame information for rev 292

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 285 jeremybenn
@ignore
2
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
3
Free Software Foundation, Inc.
4
This is part of the GNU Fortran manual.
5
For copying conditions, see the file gfortran.texi.
6
 
7
Permission is granted to copy, distribute and/or modify this document
8
under the terms of the GNU Free Documentation License, Version 1.2 or
9
any later version published by the Free Software Foundation; with the
10
Invariant Sections being ``Funding Free Software'', the Front-Cover
11
Texts being (a) (see below), and with the Back-Cover Texts being (b)
12
(see below).  A copy of the license is included in the gfdl(7) man page.
13
 
14
 
15
Some basic guidelines for editing this document:
16
 
17
  (1) The intrinsic procedures are to be listed in alphabetical order.
18
  (2) The generic name is to be used.
19
  (3) The specific names are included in the function index and in a
20
      table at the end of the node (See ABS entry).
21
  (4) Try to maintain the same style for each entry.
22
 
23
 
24
@end ignore
25
 
26
@tex
27
\gdef\acos{\mathop{\rm acos}\nolimits}
28
\gdef\asin{\mathop{\rm asin}\nolimits}
29
\gdef\atan{\mathop{\rm atan}\nolimits}
30
\gdef\acosh{\mathop{\rm acosh}\nolimits}
31
\gdef\asinh{\mathop{\rm asinh}\nolimits}
32
\gdef\atanh{\mathop{\rm atanh}\nolimits}
33
@end tex
34
 
35
 
36
@node Intrinsic Procedures
37
@chapter Intrinsic Procedures
38
@cindex intrinsic procedures
39
 
40
@menu
41
* Introduction:         Introduction to Intrinsics
42
* @code{ABORT}:         ABORT,     Abort the program
43
* @code{ABS}:           ABS,       Absolute value
44
* @code{ACCESS}:        ACCESS,    Checks file access modes
45
* @code{ACHAR}:         ACHAR,     Character in @acronym{ASCII} collating sequence
46
* @code{ACOS}:          ACOS,      Arccosine function
47
* @code{ACOSH}:         ACOSH,     Hyperbolic arccosine function
48
* @code{ADJUSTL}:       ADJUSTL,   Left adjust a string
49
* @code{ADJUSTR}:       ADJUSTR,   Right adjust a string
50
* @code{AIMAG}:         AIMAG,     Imaginary part of complex number
51
* @code{AINT}:          AINT,      Truncate to a whole number
52
* @code{ALARM}:         ALARM,     Set an alarm clock
53
* @code{ALL}:           ALL,       Determine if all values are true
54
* @code{ALLOCATED}:     ALLOCATED, Status of allocatable entity
55
* @code{AND}:           AND,       Bitwise logical AND
56
* @code{ANINT}:         ANINT,     Nearest whole number
57
* @code{ANY}:           ANY,       Determine if any values are true
58
* @code{ASIN}:          ASIN,      Arcsine function
59
* @code{ASINH}:         ASINH,     Hyperbolic arcsine function
60
* @code{ASSOCIATED}:    ASSOCIATED, Status of a pointer or pointer/target pair
61
* @code{ATAN}:          ATAN,      Arctangent function
62
* @code{ATAN2}:         ATAN2,     Arctangent function
63
* @code{ATANH}:         ATANH,     Hyperbolic arctangent function
64
* @code{BESSEL_J0}:     BESSEL_J0, Bessel function of the first kind of order 0
65
* @code{BESSEL_J1}:     BESSEL_J1, Bessel function of the first kind of order 1
66
* @code{BESSEL_JN}:     BESSEL_JN, Bessel function of the first kind
67
* @code{BESSEL_Y0}:     BESSEL_Y0, Bessel function of the second kind of order 0
68
* @code{BESSEL_Y1}:     BESSEL_Y1, Bessel function of the second kind of order 1
69
* @code{BESSEL_YN}:     BESSEL_YN, Bessel function of the second kind
70
* @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
71
* @code{BTEST}:         BTEST,     Bit test function
72
* @code{C_ASSOCIATED}:  C_ASSOCIATED, Status of a C pointer
73
* @code{C_F_POINTER}:   C_F_POINTER, Convert C into Fortran pointer
74
* @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
75
* @code{C_FUNLOC}:      C_FUNLOC,  Obtain the C address of a procedure
76
* @code{C_LOC}:         C_LOC,     Obtain the C address of an object
77
* @code{C_SIZEOF}:      C_SIZEOF,  Size in bytes of an expression
78
* @code{CEILING}:       CEILING,   Integer ceiling function
79
* @code{CHAR}:          CHAR,      Integer-to-character conversion function
80
* @code{CHDIR}:         CHDIR,     Change working directory
81
* @code{CHMOD}:         CHMOD,     Change access permissions of files
82
* @code{CMPLX}:         CMPLX,     Complex conversion function
83
* @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
84
* @code{COMPLEX}:       COMPLEX,   Complex conversion function
85
* @code{CONJG}:         CONJG,     Complex conjugate function
86
* @code{COS}:           COS,       Cosine function
87
* @code{COSH}:          COSH,      Hyperbolic cosine function
88
* @code{COUNT}:         COUNT,     Count occurrences of TRUE in an array
89
* @code{CPU_TIME}:      CPU_TIME,  CPU time subroutine
90
* @code{CSHIFT}:        CSHIFT,    Circular shift elements of an array
91
* @code{CTIME}:         CTIME,     Subroutine (or function) to convert a time into a string
92
* @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
93
* @code{DBLE}:          DBLE,      Double precision conversion function
94
* @code{DCMPLX}:        DCMPLX,    Double complex conversion function
95
* @code{DFLOAT}:        DFLOAT,    Double precision conversion function
96
* @code{DIGITS}:        DIGITS,    Significant digits function
97
* @code{DIM}:           DIM,       Positive difference
98
* @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
99
* @code{DPROD}:         DPROD,     Double product function
100
* @code{DREAL}:         DREAL,     Double real part function
101
* @code{DTIME}:         DTIME,     Execution time subroutine (or function)
102
* @code{EOSHIFT}:       EOSHIFT,   End-off shift elements of an array
103
* @code{EPSILON}:       EPSILON,   Epsilon function
104
* @code{ERF}:           ERF,       Error function
105
* @code{ERFC}:          ERFC,      Complementary error function
106
* @code{ERFC_SCALED}:   ERFC_SCALED, Exponentially-scaled complementary error function
107
* @code{ETIME}:         ETIME,     Execution time subroutine (or function)
108
* @code{EXIT}:          EXIT,      Exit the program with status.
109
* @code{EXP}:           EXP,       Exponential function
110
* @code{EXPONENT}:      EXPONENT,  Exponent function
111
* @code{FDATE}:         FDATE,     Subroutine (or function) to get the current time as a string
112
* @code{FGET}:          FGET,      Read a single character in stream mode from stdin
113
* @code{FGETC}:         FGETC,     Read a single character in stream mode
114
* @code{FLOAT}:         FLOAT,     Convert integer to default real
115
* @code{FLOOR}:         FLOOR,     Integer floor function
116
* @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
117
* @code{FNUM}:          FNUM,      File number function
118
* @code{FPUT}:          FPUT,      Write a single character in stream mode to stdout
119
* @code{FPUTC}:         FPUTC,     Write a single character in stream mode
120
* @code{FRACTION}:      FRACTION,  Fractional part of the model representation
121
* @code{FREE}:          FREE,      Memory de-allocation subroutine
122
* @code{FSEEK}:         FSEEK,     Low level file positioning subroutine
123
* @code{FSTAT}:         FSTAT,     Get file status
124
* @code{FTELL}:         FTELL,     Current stream position
125
* @code{GAMMA}:         GAMMA,     Gamma function
126
* @code{GERROR}:        GERROR,    Get last system error message
127
* @code{GETARG}:        GETARG,    Get command line arguments
128
* @code{GET_COMMAND}:   GET_COMMAND, Get the entire command line
129
* @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
130
* @code{GETCWD}:        GETCWD,    Get current working directory
131
* @code{GETENV}:        GETENV,    Get an environmental variable
132
* @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
133
* @code{GETGID}:        GETGID,    Group ID function
134
* @code{GETLOG}:        GETLOG,    Get login name
135
* @code{GETPID}:        GETPID,    Process ID function
136
* @code{GETUID}:        GETUID,    User ID function
137
* @code{GMTIME}:        GMTIME,    Convert time to GMT info
138
* @code{HOSTNM}:        HOSTNM,    Get system host name
139
* @code{HUGE}:          HUGE,      Largest number of a kind
140
* @code{HYPOT}:         HYPOT,     Euclidian distance function
141
* @code{IACHAR}:        IACHAR,    Code in @acronym{ASCII} collating sequence
142
* @code{IAND}:          IAND,      Bitwise logical and
143
* @code{IARGC}:         IARGC,     Get the number of command line arguments
144
* @code{IBCLR}:         IBCLR,     Clear bit
145
* @code{IBITS}:         IBITS,     Bit extraction
146
* @code{IBSET}:         IBSET,     Set bit
147
* @code{ICHAR}:         ICHAR,     Character-to-integer conversion function
148
* @code{IDATE}:         IDATE,     Current local time (day/month/year)
149
* @code{IEOR}:          IEOR,      Bitwise logical exclusive or
150
* @code{IERRNO}:        IERRNO,    Function to get the last system error number
151
* @code{INDEX}:         INDEX intrinsic, Position of a substring within a string
152
* @code{INT}:           INT,       Convert to integer type
153
* @code{INT2}:          INT2,      Convert to 16-bit integer type
154
* @code{INT8}:          INT8,      Convert to 64-bit integer type
155
* @code{IOR}:           IOR,       Bitwise logical or
156
* @code{IRAND}:         IRAND,     Integer pseudo-random number
157
* @code{IS_IOSTAT_END}:  IS_IOSTAT_END, Test for end-of-file value
158
* @code{IS_IOSTAT_EOR}:  IS_IOSTAT_EOR, Test for end-of-record value
159
* @code{ISATTY}:        ISATTY,    Whether a unit is a terminal device
160
* @code{ISHFT}:         ISHFT,     Shift bits
161
* @code{ISHFTC}:        ISHFTC,    Shift bits circularly
162
* @code{ISNAN}:         ISNAN,     Tests for a NaN
163
* @code{ITIME}:         ITIME,     Current local time (hour/minutes/seconds)
164
* @code{KILL}:          KILL,      Send a signal to a process
165
* @code{KIND}:          KIND,      Kind of an entity
166
* @code{LBOUND}:        LBOUND,    Lower dimension bounds of an array
167
* @code{LEADZ}:         LEADZ,     Number of leading zero bits of an integer
168
* @code{LEN}:           LEN,       Length of a character entity
169
* @code{LEN_TRIM}:      LEN_TRIM,  Length of a character entity without trailing blank characters
170
* @code{LGE}:           LGE,       Lexical greater than or equal
171
* @code{LGT}:           LGT,       Lexical greater than
172
* @code{LINK}:          LINK,      Create a hard link
173
* @code{LLE}:           LLE,       Lexical less than or equal
174
* @code{LLT}:           LLT,       Lexical less than
175
* @code{LNBLNK}:        LNBLNK,    Index of the last non-blank character in a string
176
* @code{LOC}:           LOC,       Returns the address of a variable
177
* @code{LOG}:           LOG,       Logarithm function
178
* @code{LOG10}:         LOG10,     Base 10 logarithm function
179
* @code{LOG_GAMMA}:     LOG_GAMMA, Logarithm of the Gamma function
180
* @code{LOGICAL}:       LOGICAL,   Convert to logical type
181
* @code{LONG}:          LONG,      Convert to integer type
182
* @code{LSHIFT}:        LSHIFT,    Left shift bits
183
* @code{LSTAT}:         LSTAT,     Get file status
184
* @code{LTIME}:         LTIME,     Convert time to local time info
185
* @code{MALLOC}:        MALLOC,    Dynamic memory allocation function
186
* @code{MATMUL}:        MATMUL,    matrix multiplication
187
* @code{MAX}:           MAX,       Maximum value of an argument list
188
* @code{MAXEXPONENT}:   MAXEXPONENT, Maximum exponent of a real kind
189
* @code{MAXLOC}:        MAXLOC,    Location of the maximum value within an array
190
* @code{MAXVAL}:        MAXVAL,    Maximum value of an array
191
* @code{MCLOCK}:        MCLOCK,    Time function
192
* @code{MCLOCK8}:       MCLOCK8,   Time function (64-bit)
193
* @code{MERGE}:         MERGE,     Merge arrays
194
* @code{MIN}:           MIN,       Minimum value of an argument list
195
* @code{MINEXPONENT}:   MINEXPONENT, Minimum exponent of a real kind
196
* @code{MINLOC}:        MINLOC,    Location of the minimum value within an array
197
* @code{MINVAL}:        MINVAL,    Minimum value of an array
198
* @code{MOD}:           MOD,       Remainder function
199
* @code{MODULO}:        MODULO,    Modulo function
200
* @code{MOVE_ALLOC}:    MOVE_ALLOC, Move allocation from one object to another
201
* @code{MVBITS}:        MVBITS,    Move bits from one integer to another
202
* @code{NEAREST}:       NEAREST,   Nearest representable number
203
* @code{NEW_LINE}:      NEW_LINE,  New line character
204
* @code{NINT}:          NINT,      Nearest whole number
205
* @code{NOT}:           NOT,       Logical negation
206
* @code{NULL}:          NULL,      Function that returns an disassociated pointer
207
* @code{OR}:            OR,        Bitwise logical OR
208
* @code{PACK}:          PACK,      Pack an array into an array of rank one
209
* @code{PERROR}:        PERROR,    Print system error message
210
* @code{PRECISION}:     PRECISION, Decimal precision of a real kind
211
* @code{PRESENT}:       PRESENT,   Determine whether an optional dummy argument is specified
212
* @code{PRODUCT}:       PRODUCT,   Product of array elements
213
* @code{RADIX}:         RADIX,     Base of a data model
214
* @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
215
* @code{RANDOM_SEED}:   RANDOM_SEED, Initialize a pseudo-random number sequence
216
* @code{RAND}:          RAND,      Real pseudo-random number
217
* @code{RANGE}:         RANGE,     Decimal exponent range
218
* @code{RAN}:           RAN,       Real pseudo-random number
219
* @code{REAL}:          REAL,      Convert to real type
220
* @code{RENAME}:        RENAME,    Rename a file
221
* @code{REPEAT}:        REPEAT,    Repeated string concatenation
222
* @code{RESHAPE}:       RESHAPE,   Function to reshape an array
223
* @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
224
* @code{RSHIFT}:        RSHIFT,    Right shift bits
225
* @code{SCALE}:         SCALE,     Scale a real value
226
* @code{SCAN}:          SCAN,      Scan a string for the presence of a set of characters
227
* @code{SECNDS}:        SECNDS,    Time function
228
* @code{SECOND}:        SECOND,    CPU time function
229
* @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND,  Choose character kind
230
* @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
231
* @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
232
* @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
233
* @code{SHAPE}:         SHAPE,     Determine the shape of an array
234
* @code{SIGN}:          SIGN,      Sign copying function
235
* @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
236
* @code{SIN}:           SIN,       Sine function
237
* @code{SINH}:          SINH,      Hyperbolic sine function
238
* @code{SIZE}:          SIZE,      Function to determine the size of an array
239
* @code{SIZEOF}:        SIZEOF,    Determine the size in bytes of an expression
240
* @code{SLEEP}:         SLEEP,     Sleep for the specified number of seconds
241
* @code{SNGL}:          SNGL,      Convert double precision real to default real
242
* @code{SPACING}:       SPACING,   Smallest distance between two numbers of a given type
243
* @code{SPREAD}:        SPREAD,    Add a dimension to an array
244
* @code{SQRT}:          SQRT,      Square-root function
245
* @code{SRAND}:         SRAND,     Reinitialize the random number generator
246
* @code{STAT}:          STAT,      Get file status
247
* @code{SUM}:           SUM,       Sum of array elements
248
* @code{SYMLNK}:        SYMLNK,    Create a symbolic link
249
* @code{SYSTEM}:        SYSTEM,    Execute a shell command
250
* @code{SYSTEM_CLOCK}:  SYSTEM_CLOCK, Time function
251
* @code{TAN}:           TAN,       Tangent function
252
* @code{TANH}:          TANH,      Hyperbolic tangent function
253
* @code{TIME}:          TIME,      Time function
254
* @code{TIME8}:         TIME8,     Time function (64-bit)
255
* @code{TINY}:          TINY,      Smallest positive number of a real kind
256
* @code{TRAILZ}:        TRAILZ,    Number of trailing zero bits of an integer
257
* @code{TRANSFER}:      TRANSFER,  Transfer bit patterns
258
* @code{TRANSPOSE}:     TRANSPOSE, Transpose an array of rank two
259
* @code{TRIM}:          TRIM,      Remove trailing blank characters of a string
260
* @code{TTYNAM}:        TTYNAM,    Get the name of a terminal device.
261
* @code{UBOUND}:        UBOUND,    Upper dimension bounds of an array
262
* @code{UMASK}:         UMASK,     Set the file creation mask
263
* @code{UNLINK}:        UNLINK,    Remove a file from the file system
264
* @code{UNPACK}:        UNPACK,    Unpack an array of rank one into an array
265
* @code{VERIFY}:        VERIFY,    Scan a string for the absence of a set of characters
266
* @code{XOR}:           XOR,       Bitwise logical exclusive or
267
@end menu
268
 
269
@node Introduction to Intrinsics
270
@section Introduction to intrinsic procedures
271
 
272
The intrinsic procedures provided by GNU Fortran include all of the
273
intrinsic procedures required by the Fortran 95 standard, a set of
274
intrinsic procedures for backwards compatibility with G77, and a
275
selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
276
standards.  Any conflict between a description here and a description in
277
either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
278
2008 standard is unintentional, and the standard(s) should be considered
279
authoritative.
280
 
281
The enumeration of the @code{KIND} type parameter is processor defined in
282
the Fortran 95 standard.  GNU Fortran defines the default integer type and
283
default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
284
respectively.  The standard mandates that both data types shall have
285
another kind, which have more precision.  On typical target architectures
286
supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
287
Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
288
In the description of generic intrinsic procedures, the kind type parameter
289
will be specified by @code{KIND=*}, and in the description of specific
290
names for an intrinsic procedure the kind type parameter will be explicitly
291
given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
292
brevity the optional @code{KIND=} syntax will be omitted.
293
 
294
Many of the intrinsic procedures take one or more optional arguments.
295
This document follows the convention used in the Fortran 95 standard,
296
and denotes such arguments by square brackets.
297
 
298
GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
299
which can be used to restrict the set of intrinsic procedures to a
300
given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
301
option, and so all intrinsic procedures described here are accepted.  There
302
is one caveat.  For a select group of intrinsic procedures, @command{g77}
303
implemented both a function and a subroutine.  Both classes
304
have been implemented in @command{gfortran} for backwards compatibility
305
with @command{g77}.  It is noted here that these functions and subroutines
306
cannot be intermixed in a given subprogram.  In the descriptions that follow,
307
the applicable standard for each intrinsic procedure is noted.
308
 
309
 
310
 
311
@node ABORT
312
@section @code{ABORT} --- Abort the program
313
@fnindex ABORT
314
@cindex program termination, with core dump
315
@cindex terminate program, with core dump
316
@cindex core, dump
317
 
318
@table @asis
319
@item @emph{Description}:
320
@code{ABORT} causes immediate termination of the program.  On operating
321
systems that support a core dump, @code{ABORT} will produce a core dump even if
322
the option @option{-fno-dump-core} is in effect, which is suitable for debugging
323
purposes.
324
@c TODO: Check if this (with -fno-dump-core) is correct.
325
 
326
@item @emph{Standard}:
327
GNU extension
328
 
329
@item @emph{Class}:
330
Subroutine
331
 
332
@item @emph{Syntax}:
333
@code{CALL ABORT}
334
 
335
@item @emph{Return value}:
336
Does not return.
337
 
338
@item @emph{Example}:
339
@smallexample
340
program test_abort
341
  integer :: i = 1, j = 2
342
  if (i /= j) call abort
343
end program test_abort
344
@end smallexample
345
 
346
@item @emph{See also}:
347
@ref{EXIT}, @ref{KILL}
348
 
349
@end table
350
 
351
 
352
 
353
@node ABS
354
@section @code{ABS} --- Absolute value
355
@fnindex ABS
356
@fnindex CABS
357
@fnindex DABS
358
@fnindex IABS
359
@fnindex ZABS
360
@fnindex CDABS
361
@cindex absolute value
362
 
363
@table @asis
364
@item @emph{Description}:
365
@code{ABS(A)} computes the absolute value of @code{A}.
366
 
367
@item @emph{Standard}:
368
Fortran 77 and later, has overloads that are GNU extensions
369
 
370
@item @emph{Class}:
371
Elemental function
372
 
373
@item @emph{Syntax}:
374
@code{RESULT = ABS(A)}
375
 
376
@item @emph{Arguments}:
377
@multitable @columnfractions .15 .70
378
@item @var{A} @tab The type of the argument shall be an @code{INTEGER},
379
@code{REAL}, or @code{COMPLEX}.
380
@end multitable
381
 
382
@item @emph{Return value}:
383
The return value is of the same type and
384
kind as the argument except the return value is @code{REAL} for a
385
@code{COMPLEX} argument.
386
 
387
@item @emph{Example}:
388
@smallexample
389
program test_abs
390
  integer :: i = -1
391
  real :: x = -1.e0
392
  complex :: z = (-1.e0,0.e0)
393
  i = abs(i)
394
  x = abs(x)
395
  x = abs(z)
396
end program test_abs
397
@end smallexample
398
 
399
@item @emph{Specific names}:
400
@multitable @columnfractions .20 .20 .20 .25
401
@item Name            @tab Argument            @tab Return type       @tab Standard
402
@item @code{CABS(A)}  @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)}    @tab Fortran 77 and later
403
@item @code{DABS(A)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}    @tab Fortran 77 and later
404
@item @code{IABS(A)}  @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab Fortran 77 and later
405
@item @code{ZABS(A)}  @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
406
@item @code{CDABS(A)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
407
@end multitable
408
@end table
409
 
410
 
411
 
412
@node ACCESS
413
@section @code{ACCESS} --- Checks file access modes
414
@fnindex ACCESS
415
@cindex file system, access mode
416
 
417
@table @asis
418
@item @emph{Description}:
419
@code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
420
exists, is readable, writable or executable. Except for the
421
executable check, @code{ACCESS} can be replaced by
422
Fortran 95's @code{INQUIRE}.
423
 
424
@item @emph{Standard}:
425
GNU extension
426
 
427
@item @emph{Class}:
428
Inquiry function
429
 
430
@item @emph{Syntax}:
431
@code{RESULT = ACCESS(NAME, MODE)}
432
 
433
@item @emph{Arguments}:
434
@multitable @columnfractions .15 .70
435
@item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
436
file name. Tailing blank are ignored unless the character @code{achar(0)}
437
is present, then all characters up to and excluding @code{achar(0)} are
438
used as file name.
439
@item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
440
file access mode, may be any concatenation of @code{"r"} (readable),
441
@code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
442
for existence.
443
@end multitable
444
 
445
@item @emph{Return value}:
446
Returns a scalar @code{INTEGER}, which is @code{0} if the file is
447
accessible in the given mode; otherwise or if an invalid argument
448
has been given for @code{MODE} the value @code{1} is returned.
449
 
450
@item @emph{Example}:
451
@smallexample
452
program access_test
453
  implicit none
454
  character(len=*), parameter :: file  = 'test.dat'
455
  character(len=*), parameter :: file2 = 'test.dat  '//achar(0)
456
  if(access(file,' ') == 0) print *, trim(file),' is exists'
457
  if(access(file,'r') == 0) print *, trim(file),' is readable'
458
  if(access(file,'w') == 0) print *, trim(file),' is writable'
459
  if(access(file,'x') == 0) print *, trim(file),' is executable'
460
  if(access(file2,'rwx') == 0) &
461
    print *, trim(file2),' is readable, writable and executable'
462
end program access_test
463
@end smallexample
464
@item @emph{Specific names}:
465
@item @emph{See also}:
466
 
467
@end table
468
 
469
 
470
 
471
@node ACHAR
472
@section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
473
@fnindex ACHAR
474
@cindex @acronym{ASCII} collating sequence
475
@cindex collating sequence, @acronym{ASCII}
476
 
477
@table @asis
478
@item @emph{Description}:
479
@code{ACHAR(I)} returns the character located at position @code{I}
480
in the @acronym{ASCII} collating sequence.
481
 
482
@item @emph{Standard}:
483
Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
484
 
485
@item @emph{Class}:
486
Elemental function
487
 
488
@item @emph{Syntax}:
489
@code{RESULT = ACHAR(I [, KIND])}
490
 
491
@item @emph{Arguments}:
492
@multitable @columnfractions .15 .70
493
@item @var{I}    @tab The type shall be @code{INTEGER}.
494
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
495
expression indicating the kind parameter of the result.
496
@end multitable
497
 
498
@item @emph{Return value}:
499
The return value is of type @code{CHARACTER} with a length of one.
500
If the @var{KIND} argument is present, the return value is of the
501
specified kind and of the default kind otherwise.
502
 
503
@item @emph{Example}:
504
@smallexample
505
program test_achar
506
  character c
507
  c = achar(32)
508
end program test_achar
509
@end smallexample
510
 
511
@item @emph{Note}:
512
See @ref{ICHAR} for a discussion of converting between numerical values
513
and formatted string representations.
514
 
515
@item @emph{See also}:
516
@ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
517
 
518
@end table
519
 
520
 
521
 
522
@node ACOS
523
@section @code{ACOS} --- Arccosine function
524
@fnindex ACOS
525
@fnindex DACOS
526
@cindex trigonometric function, cosine, inverse
527
@cindex cosine, inverse
528
 
529
@table @asis
530
@item @emph{Description}:
531
@code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
532
 
533
@item @emph{Standard}:
534
Fortran 77 and later, for a complex argument Fortran 2008 or later
535
 
536
@item @emph{Class}:
537
Elemental function
538
 
539
@item @emph{Syntax}:
540
@code{RESULT = ACOS(X)}
541
 
542
@item @emph{Arguments}:
543
@multitable @columnfractions .15 .70
544
@item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
545
less than or equal to one - or the type shall be @code{COMPLEX}.
546
@end multitable
547
 
548
@item @emph{Return value}:
549
The return value is of the same type and kind as @var{X}.
550
The real part of the result is in radians and lies in the range
551
@math{0 \leq \Re \acos(x) \leq \pi}.
552
 
553
@item @emph{Example}:
554
@smallexample
555
program test_acos
556
  real(8) :: x = 0.866_8
557
  x = acos(x)
558
end program test_acos
559
@end smallexample
560
 
561
@item @emph{Specific names}:
562
@multitable @columnfractions .20 .20 .20 .25
563
@item Name            @tab Argument          @tab Return type       @tab Standard
564
@item @code{DACOS(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
565
@end multitable
566
 
567
@item @emph{See also}:
568
Inverse function: @ref{COS}
569
 
570
@end table
571
 
572
 
573
 
574
@node ACOSH
575
@section @code{ACOSH} --- Hyperbolic arccosine function
576
@fnindex ACOSH
577
@fnindex DACOSH
578
@cindex area hyperbolic cosine
579
@cindex hyperbolic arccosine
580
@cindex hyperbolic function, cosine, inverse
581
@cindex cosine, hyperbolic, inverse
582
 
583
@table @asis
584
@item @emph{Description}:
585
@code{ACOSH(X)} computes the hyperbolic arccosine of @var{X} (inverse of
586
@code{COSH(X)}).
587
 
588
@item @emph{Standard}:
589
Fortran 2008 and later
590
 
591
@item @emph{Class}:
592
Elemental function
593
 
594
@item @emph{Syntax}:
595
@code{RESULT = ACOSH(X)}
596
 
597
@item @emph{Arguments}:
598
@multitable @columnfractions .15 .70
599
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
600
@end multitable
601
 
602
@item @emph{Return value}:
603
The return value has the same type and kind as @var{X}. If @var{X} is
604
complex, the imaginary part of the result is in radians and lies between
605
@math{ 0 \leq \Im \acosh(x) \leq \pi}.
606
 
607
@item @emph{Example}:
608
@smallexample
609
PROGRAM test_acosh
610
  REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
611
  WRITE (*,*) ACOSH(x)
612
END PROGRAM
613
@end smallexample
614
 
615
@item @emph{Specific names}:
616
@multitable @columnfractions .20 .20 .20 .25
617
@item Name             @tab Argument          @tab Return type       @tab Standard
618
@item @code{DACOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
619
@end multitable
620
 
621
@item @emph{See also}:
622
Inverse function: @ref{COSH}
623
@end table
624
 
625
 
626
 
627
@node ADJUSTL
628
@section @code{ADJUSTL} --- Left adjust a string
629
@fnindex ADJUSTL
630
@cindex string, adjust left
631
@cindex adjust string
632
 
633
@table @asis
634
@item @emph{Description}:
635
@code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
636
Spaces are inserted at the end of the string as needed.
637
 
638
@item @emph{Standard}:
639
Fortran 90 and later
640
 
641
@item @emph{Class}:
642
Elemental function
643
 
644
@item @emph{Syntax}:
645
@code{RESULT = ADJUSTL(STRING)}
646
 
647
@item @emph{Arguments}:
648
@multitable @columnfractions .15 .70
649
@item @var{STRING} @tab The type shall be @code{CHARACTER}.
650
@end multitable
651
 
652
@item @emph{Return value}:
653
The return value is of type @code{CHARACTER} and of the same kind as
654
@var{STRING} where leading spaces are removed and the same number of
655
spaces are inserted on the end of @var{STRING}.
656
 
657
@item @emph{Example}:
658
@smallexample
659
program test_adjustl
660
  character(len=20) :: str = '   gfortran'
661
  str = adjustl(str)
662
  print *, str
663
end program test_adjustl
664
@end smallexample
665
 
666
@item @emph{See also}:
667
@ref{ADJUSTR}, @ref{TRIM}
668
@end table
669
 
670
 
671
 
672
@node ADJUSTR
673
@section @code{ADJUSTR} --- Right adjust a string
674
@fnindex ADJUSTR
675
@cindex string, adjust right
676
@cindex adjust string
677
 
678
@table @asis
679
@item @emph{Description}:
680
@code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
681
Spaces are inserted at the start of the string as needed.
682
 
683
@item @emph{Standard}:
684
Fortran 95 and later
685
 
686
@item @emph{Class}:
687
Elemental function
688
 
689
@item @emph{Syntax}:
690
@code{RESULT = ADJUSTR(STRING)}
691
 
692
@item @emph{Arguments}:
693
@multitable @columnfractions .15 .70
694
@item @var{STR} @tab The type shall be @code{CHARACTER}.
695
@end multitable
696
 
697
@item @emph{Return value}:
698
The return value is of type @code{CHARACTER} and of the same kind as
699
@var{STRING} where trailing spaces are removed and the same number of
700
spaces are inserted at the start of @var{STRING}.
701
 
702
@item @emph{Example}:
703
@smallexample
704
program test_adjustr
705
  character(len=20) :: str = 'gfortran'
706
  str = adjustr(str)
707
  print *, str
708
end program test_adjustr
709
@end smallexample
710
 
711
@item @emph{See also}:
712
@ref{ADJUSTL}, @ref{TRIM}
713
@end table
714
 
715
 
716
 
717
@node AIMAG
718
@section @code{AIMAG} --- Imaginary part of complex number
719
@fnindex AIMAG
720
@fnindex DIMAG
721
@fnindex IMAG
722
@fnindex IMAGPART
723
@cindex complex numbers, imaginary part
724
 
725
@table @asis
726
@item @emph{Description}:
727
@code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
728
The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
729
for compatibility with @command{g77}, and their use in new code is
730
strongly discouraged.
731
 
732
@item @emph{Standard}:
733
Fortran 77 and later, has overloads that are GNU extensions
734
 
735
@item @emph{Class}:
736
Elemental function
737
 
738
@item @emph{Syntax}:
739
@code{RESULT = AIMAG(Z)}
740
 
741
@item @emph{Arguments}:
742
@multitable @columnfractions .15 .70
743
@item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
744
@end multitable
745
 
746
@item @emph{Return value}:
747
The return value is of type @code{REAL} with the
748
kind type parameter of the argument.
749
 
750
@item @emph{Example}:
751
@smallexample
752
program test_aimag
753
  complex(4) z4
754
  complex(8) z8
755
  z4 = cmplx(1.e0_4, 0.e0_4)
756
  z8 = cmplx(0.e0_8, 1.e0_8)
757
  print *, aimag(z4), dimag(z8)
758
end program test_aimag
759
@end smallexample
760
 
761
@item @emph{Specific names}:
762
@multitable @columnfractions .20 .20 .20 .25
763
@item Name            @tab Argument            @tab Return type       @tab Standard
764
@item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}    @tab GNU extension
765
@item @code{IMAG(Z)}  @tab @code{COMPLEX Z} @tab @code{REAL}    @tab GNU extension
766
@item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
767
@end multitable
768
@end table
769
 
770
 
771
 
772
@node AINT
773
@section @code{AINT} --- Truncate to a whole number
774
@fnindex AINT
775
@fnindex DINT
776
@cindex floor
777
@cindex rounding, floor
778
 
779
@table @asis
780
@item @emph{Description}:
781
@code{AINT(A [, KIND])} truncates its argument to a whole number.
782
 
783
@item @emph{Standard}:
784
Fortran 77 and later
785
 
786
@item @emph{Class}:
787
Elemental function
788
 
789
@item @emph{Syntax}:
790
@code{RESULT = AINT(A [, KIND])}
791
 
792
@item @emph{Arguments}:
793
@multitable @columnfractions .15 .70
794
@item @var{A}    @tab The type of the argument shall be @code{REAL}.
795
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
796
expression indicating the kind parameter of the result.
797
@end multitable
798
 
799
@item @emph{Return value}:
800
The return value is of type @code{REAL} with the kind type parameter of the
801
argument if the optional @var{KIND} is absent; otherwise, the kind
802
type parameter will be given by @var{KIND}.  If the magnitude of
803
@var{X} is less than one, @code{AINT(X)} returns zero.  If the
804
magnitude is equal to or greater than one then it returns the largest
805
whole number that does not exceed its magnitude.  The sign is the same
806
as the sign of @var{X}.
807
 
808
@item @emph{Example}:
809
@smallexample
810
program test_aint
811
  real(4) x4
812
  real(8) x8
813
  x4 = 1.234E0_4
814
  x8 = 4.321_8
815
  print *, aint(x4), dint(x8)
816
  x8 = aint(x4,8)
817
end program test_aint
818
@end smallexample
819
 
820
@item @emph{Specific names}:
821
@multitable @columnfractions .20 .20 .20 .25
822
@item Name           @tab Argument         @tab Return type      @tab Standard
823
@item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}   @tab Fortran 77 and later
824
@end multitable
825
@end table
826
 
827
 
828
 
829
@node ALARM
830
@section @code{ALARM} --- Execute a routine after a given delay
831
@fnindex ALARM
832
@cindex delayed execution
833
 
834
@table @asis
835
@item @emph{Description}:
836
@code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
837
to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
838
set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
839
supplied, it will be returned with the number of seconds remaining until
840
any previously scheduled alarm was due to be delivered, or zero if there
841
was no previously scheduled alarm.
842
 
843
@item @emph{Standard}:
844
GNU extension
845
 
846
@item @emph{Class}:
847
Subroutine
848
 
849
@item @emph{Syntax}:
850
@code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
851
 
852
@item @emph{Arguments}:
853
@multitable @columnfractions .15 .70
854
@item @var{SECONDS} @tab The type of the argument shall be a scalar
855
@code{INTEGER}. It is @code{INTENT(IN)}.
856
@item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
857
@code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
858
values may be either @code{SIG_IGN=1} to ignore the alarm generated
859
or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
860
@item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
861
variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
862
@end multitable
863
 
864
@item @emph{Example}:
865
@smallexample
866
program test_alarm
867
  external handler_print
868
  integer i
869
  call alarm (3, handler_print, i)
870
  print *, i
871
  call sleep(10)
872
end program test_alarm
873
@end smallexample
874
This will cause the external routine @var{handler_print} to be called
875
after 3 seconds.
876
@end table
877
 
878
 
879
 
880
@node ALL
881
@section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
882
@fnindex ALL
883
@cindex array, apply condition
884
@cindex array, condition testing
885
 
886
@table @asis
887
@item @emph{Description}:
888
@code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
889
in the array along dimension @var{DIM}.
890
 
891
@item @emph{Standard}:
892
Fortran 95 and later
893
 
894
@item @emph{Class}:
895
Transformational function
896
 
897
@item @emph{Syntax}:
898
@code{RESULT = ALL(MASK [, DIM])}
899
 
900
@item @emph{Arguments}:
901
@multitable @columnfractions .15 .70
902
@item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
903
it shall not be scalar.
904
@item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
905
with a value that lies between one and the rank of @var{MASK}.
906
@end multitable
907
 
908
@item @emph{Return value}:
909
@code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
910
the kind type parameter is the same as the kind type parameter of
911
@var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
912
an array with the rank of @var{MASK} minus 1.  The shape is determined from
913
the shape of @var{MASK} where the @var{DIM} dimension is elided.
914
 
915
@table @asis
916
@item (A)
917
@code{ALL(MASK)} is true if all elements of @var{MASK} are true.
918
It also is true if @var{MASK} has zero size; otherwise, it is false.
919
@item (B)
920
If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
921
to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
922
is determined by applying @code{ALL} to the array sections.
923
@end table
924
 
925
@item @emph{Example}:
926
@smallexample
927
program test_all
928
  logical l
929
  l = all((/.true., .true., .true./))
930
  print *, l
931
  call section
932
  contains
933
    subroutine section
934
      integer a(2,3), b(2,3)
935
      a = 1
936
      b = 1
937
      b(2,2) = 2
938
      print *, all(a .eq. b, 1)
939
      print *, all(a .eq. b, 2)
940
    end subroutine section
941
end program test_all
942
@end smallexample
943
@end table
944
 
945
 
946
 
947
@node ALLOCATED
948
@section @code{ALLOCATED} --- Status of an allocatable entity
949
@fnindex ALLOCATED
950
@cindex allocation, status
951
 
952
@table @asis
953
@item @emph{Description}:
954
@code{ALLOCATED(ARRAY)} checks the status of whether @var{X} is allocated.
955
 
956
@item @emph{Standard}:
957
Fortran 95 and later
958
 
959
@item @emph{Class}:
960
Inquiry function
961
 
962
@item @emph{Syntax}:
963
@code{RESULT = ALLOCATED(ARRAY)}
964
 
965
@item @emph{Arguments}:
966
@multitable @columnfractions .15 .70
967
@item @var{ARRAY}    @tab The argument shall be an @code{ALLOCATABLE} array.
968
@end multitable
969
 
970
@item @emph{Return value}:
971
The return value is a scalar @code{LOGICAL} with the default logical
972
kind type parameter.  If @var{ARRAY} is allocated, @code{ALLOCATED(ARRAY)}
973
is @code{.TRUE.}; otherwise, it returns @code{.FALSE.}
974
 
975
@item @emph{Example}:
976
@smallexample
977
program test_allocated
978
  integer :: i = 4
979
  real(4), allocatable :: x(:)
980
  if (.not. allocated(x)) allocate(x(i))
981
end program test_allocated
982
@end smallexample
983
@end table
984
 
985
 
986
 
987
@node AND
988
@section @code{AND} --- Bitwise logical AND
989
@fnindex AND
990
@cindex bitwise logical and
991
@cindex logical and, bitwise
992
 
993
@table @asis
994
@item @emph{Description}:
995
Bitwise logical @code{AND}.
996
 
997
This intrinsic routine is provided for backwards compatibility with
998
GNU Fortran 77.  For integer arguments, programmers should consider
999
the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1000
 
1001
@item @emph{Standard}:
1002
GNU extension
1003
 
1004
@item @emph{Class}:
1005
Function
1006
 
1007
@item @emph{Syntax}:
1008
@code{RESULT = AND(I, J)}
1009
 
1010
@item @emph{Arguments}:
1011
@multitable @columnfractions .15 .70
1012
@item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1013
type or a scalar @code{LOGICAL} type.
1014
@item @var{J} @tab The type shall be the same as the type of @var{I}.
1015
@end multitable
1016
 
1017
@item @emph{Return value}:
1018
The return type is either a scalar @code{INTEGER} or a scalar
1019
@code{LOGICAL}.  If the kind type parameters differ, then the
1020
smaller kind type is implicitly converted to larger kind, and the
1021
return has the larger kind.
1022
 
1023
@item @emph{Example}:
1024
@smallexample
1025
PROGRAM test_and
1026
  LOGICAL :: T = .TRUE., F = .FALSE.
1027
  INTEGER :: a, b
1028
  DATA a / Z'F' /, b / Z'3' /
1029
 
1030
  WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1031
  WRITE (*,*) AND(a, b)
1032
END PROGRAM
1033
@end smallexample
1034
 
1035
@item @emph{See also}:
1036
Fortran 95 elemental function: @ref{IAND}
1037
@end table
1038
 
1039
 
1040
 
1041
@node ANINT
1042
@section @code{ANINT} --- Nearest whole number
1043
@fnindex ANINT
1044
@fnindex DNINT
1045
@cindex ceiling
1046
@cindex rounding, ceiling
1047
 
1048
@table @asis
1049
@item @emph{Description}:
1050
@code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1051
 
1052
@item @emph{Standard}:
1053
Fortran 77 and later
1054
 
1055
@item @emph{Class}:
1056
Elemental function
1057
 
1058
@item @emph{Syntax}:
1059
@code{RESULT = ANINT(A [, KIND])}
1060
 
1061
@item @emph{Arguments}:
1062
@multitable @columnfractions .15 .70
1063
@item @var{A}    @tab The type of the argument shall be @code{REAL}.
1064
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1065
expression indicating the kind parameter of the result.
1066
@end multitable
1067
 
1068
@item @emph{Return value}:
1069
The return value is of type real with the kind type parameter of the
1070
argument if the optional @var{KIND} is absent; otherwise, the kind
1071
type parameter will be given by @var{KIND}.  If @var{A} is greater than
1072
zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}.  If @var{A} is
1073
less than or equal to zero then it returns @code{AINT(X-0.5)}.
1074
 
1075
@item @emph{Example}:
1076
@smallexample
1077
program test_anint
1078
  real(4) x4
1079
  real(8) x8
1080
  x4 = 1.234E0_4
1081
  x8 = 4.321_8
1082
  print *, anint(x4), dnint(x8)
1083
  x8 = anint(x4,8)
1084
end program test_anint
1085
@end smallexample
1086
 
1087
@item @emph{Specific names}:
1088
@multitable @columnfractions .20 .20 .20 .25
1089
@item Name            @tab Argument         @tab Return type      @tab Standard
1090
@item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
1091
@end multitable
1092
@end table
1093
 
1094
 
1095
 
1096
@node ANY
1097
@section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1098
@fnindex ANY
1099
@cindex array, apply condition
1100
@cindex array, condition testing
1101
 
1102
@table @asis
1103
@item @emph{Description}:
1104
@code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1105
@var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1106
 
1107
@item @emph{Standard}:
1108
Fortran 95 and later
1109
 
1110
@item @emph{Class}:
1111
Transformational function
1112
 
1113
@item @emph{Syntax}:
1114
@code{RESULT = ANY(MASK [, DIM])}
1115
 
1116
@item @emph{Arguments}:
1117
@multitable @columnfractions .15 .70
1118
@item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1119
it shall not be scalar.
1120
@item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
1121
with a value that lies between one and the rank of @var{MASK}.
1122
@end multitable
1123
 
1124
@item @emph{Return value}:
1125
@code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1126
the kind type parameter is the same as the kind type parameter of
1127
@var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1128
an array with the rank of @var{MASK} minus 1.  The shape is determined from
1129
the shape of @var{MASK} where the @var{DIM} dimension is elided.
1130
 
1131
@table @asis
1132
@item (A)
1133
@code{ANY(MASK)} is true if any element of @var{MASK} is true;
1134
otherwise, it is false.  It also is false if @var{MASK} has zero size.
1135
@item (B)
1136
If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1137
to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
1138
is determined by applying @code{ANY} to the array sections.
1139
@end table
1140
 
1141
@item @emph{Example}:
1142
@smallexample
1143
program test_any
1144
  logical l
1145
  l = any((/.true., .true., .true./))
1146
  print *, l
1147
  call section
1148
  contains
1149
    subroutine section
1150
      integer a(2,3), b(2,3)
1151
      a = 1
1152
      b = 1
1153
      b(2,2) = 2
1154
      print *, any(a .eq. b, 1)
1155
      print *, any(a .eq. b, 2)
1156
    end subroutine section
1157
end program test_any
1158
@end smallexample
1159
@end table
1160
 
1161
 
1162
 
1163
@node ASIN
1164
@section @code{ASIN} --- Arcsine function
1165
@fnindex ASIN
1166
@fnindex DASIN
1167
@cindex trigonometric function, sine, inverse
1168
@cindex sine, inverse
1169
 
1170
@table @asis
1171
@item @emph{Description}:
1172
@code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1173
 
1174
@item @emph{Standard}:
1175
Fortran 77 and later, for a complex argument Fortran 2008 or later
1176
 
1177
@item @emph{Class}:
1178
Elemental function
1179
 
1180
@item @emph{Syntax}:
1181
@code{RESULT = ASIN(X)}
1182
 
1183
@item @emph{Arguments}:
1184
@multitable @columnfractions .15 .70
1185
@item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1186
less than or equal to one - or be @code{COMPLEX}.
1187
@end multitable
1188
 
1189
@item @emph{Return value}:
1190
The return value is of the same type and kind as @var{X}.
1191
The real part of the result is in radians and lies in the range
1192
@math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1193
 
1194
@item @emph{Example}:
1195
@smallexample
1196
program test_asin
1197
  real(8) :: x = 0.866_8
1198
  x = asin(x)
1199
end program test_asin
1200
@end smallexample
1201
 
1202
@item @emph{Specific names}:
1203
@multitable @columnfractions .20 .20 .20 .25
1204
@item Name            @tab Argument          @tab Return type       @tab Standard
1205
@item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1206
@end multitable
1207
 
1208
@item @emph{See also}:
1209
Inverse function: @ref{SIN}
1210
 
1211
@end table
1212
 
1213
 
1214
 
1215
@node ASINH
1216
@section @code{ASINH} --- Hyperbolic arcsine function
1217
@fnindex ASINH
1218
@fnindex DASINH
1219
@cindex area hyperbolic sine
1220
@cindex hyperbolic arcsine
1221
@cindex hyperbolic function, sine, inverse
1222
@cindex sine, hyperbolic, inverse
1223
 
1224
@table @asis
1225
@item @emph{Description}:
1226
@code{ASINH(X)} computes the hyperbolic arcsine of @var{X} (inverse of @code{SINH(X)}).
1227
 
1228
@item @emph{Standard}:
1229
Fortran 2008 and later
1230
 
1231
@item @emph{Class}:
1232
Elemental function
1233
 
1234
@item @emph{Syntax}:
1235
@code{RESULT = ASINH(X)}
1236
 
1237
@item @emph{Arguments}:
1238
@multitable @columnfractions .15 .70
1239
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1240
@end multitable
1241
 
1242
@item @emph{Return value}:
1243
The return value is of the same type and kind as  @var{X}. If @var{X} is
1244
complex, the imaginary part of the result is in radians and lies between
1245
@math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1246
 
1247
@item @emph{Example}:
1248
@smallexample
1249
PROGRAM test_asinh
1250
  REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1251
  WRITE (*,*) ASINH(x)
1252
END PROGRAM
1253
@end smallexample
1254
 
1255
@item @emph{Specific names}:
1256
@multitable @columnfractions .20 .20 .20 .25
1257
@item Name             @tab Argument          @tab Return type       @tab Standard
1258
@item @code{DASINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension.
1259
@end multitable
1260
 
1261
@item @emph{See also}:
1262
Inverse function: @ref{SINH}
1263
@end table
1264
 
1265
 
1266
 
1267
@node ASSOCIATED
1268
@section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1269
@fnindex ASSOCIATED
1270
@cindex pointer, status
1271
@cindex association status
1272
 
1273
@table @asis
1274
@item @emph{Description}:
1275
@code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1276
@var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1277
 
1278
@item @emph{Standard}:
1279
Fortran 95 and later
1280
 
1281
@item @emph{Class}:
1282
Inquiry function
1283
 
1284
@item @emph{Syntax}:
1285
@code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1286
 
1287
@item @emph{Arguments}:
1288
@multitable @columnfractions .15 .70
1289
@item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1290
and it can be of any type.
1291
@item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1292
a target.  It must have the same type, kind type parameter, and
1293
array rank as @var{POINTER}.
1294
@end multitable
1295
The association status of neither @var{POINTER} nor @var{TARGET} shall be
1296
undefined.
1297
 
1298
@item @emph{Return value}:
1299
@code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1300
There are several cases:
1301
@table @asis
1302
@item (A) When the optional @var{TARGET} is not present then
1303
@code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1304
@item (B) If @var{TARGET} is present and a scalar target, the result is true if
1305
@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
1306
disassociated, the result is false.
1307
@item (C) If @var{TARGET} is present and an array target, the result is true if
1308
@var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1309
are arrays whose elements are not zero-sized storage sequences, and
1310
@var{TARGET} and @var{POINTER} occupy the same storage units in array element
1311
order.
1312
As in case(B), the result is false, if @var{POINTER} is disassociated.
1313
@item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1314
if @var{TARGET} is associated with @var{POINTER}, the target associated with
1315
@var{TARGET} are not zero-sized storage sequences and occupy the same storage
1316
units.
1317
The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1318
@item (E) If @var{TARGET} is present and an array pointer, the result is true if
1319
target associated with @var{POINTER} and the target associated with @var{TARGET}
1320
have the same shape, are not zero-sized arrays, are arrays whose elements are
1321
not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1322
the same storage units in array element order.
1323
The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1324
@end table
1325
 
1326
@item @emph{Example}:
1327
@smallexample
1328
program test_associated
1329
   implicit none
1330
   real, target  :: tgt(2) = (/1., 2./)
1331
   real, pointer :: ptr(:)
1332
   ptr => tgt
1333
   if (associated(ptr)     .eqv. .false.) call abort
1334
   if (associated(ptr,tgt) .eqv. .false.) call abort
1335
end program test_associated
1336
@end smallexample
1337
 
1338
@item @emph{See also}:
1339
@ref{NULL}
1340
@end table
1341
 
1342
 
1343
 
1344
@node ATAN
1345
@section @code{ATAN} --- Arctangent function
1346
@fnindex ATAN
1347
@fnindex DATAN
1348
@cindex trigonometric function, tangent, inverse
1349
@cindex tangent, inverse
1350
 
1351
@table @asis
1352
@item @emph{Description}:
1353
@code{ATAN(X)} computes the arctangent of @var{X}.
1354
 
1355
@item @emph{Standard}:
1356
Fortran 77 and later, for a complex argument and for two arguments
1357
Fortran 2008 or later
1358
 
1359
@item @emph{Class}:
1360
Elemental function
1361
 
1362
@item @emph{Syntax}:
1363
@code{RESULT = ATAN(X)}
1364
@code{RESULT = ATAN(Y, X)}
1365
 
1366
@item @emph{Arguments}:
1367
@multitable @columnfractions .15 .70
1368
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1369
if @var{Y} is present, @var{X} shall be REAL.
1370
@item @var{Y} shall be of the same type and kind as @var{X}.
1371
@end multitable
1372
 
1373
@item @emph{Return value}:
1374
The return value is of the same type and kind as @var{X}.
1375
If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1376
Otherwise, it the arcus tangent of @var{X}, where the real part of
1377
the result is in radians and lies in the range
1378
@math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1379
 
1380
@item @emph{Example}:
1381
@smallexample
1382
program test_atan
1383
  real(8) :: x = 2.866_8
1384
  x = atan(x)
1385
end program test_atan
1386
@end smallexample
1387
 
1388
@item @emph{Specific names}:
1389
@multitable @columnfractions .20 .20 .20 .25
1390
@item Name            @tab Argument          @tab Return type       @tab Standard
1391
@item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1392
@end multitable
1393
 
1394
@item @emph{See also}:
1395
Inverse function: @ref{TAN}
1396
 
1397
@end table
1398
 
1399
 
1400
 
1401
@node ATAN2
1402
@section @code{ATAN2} --- Arctangent function
1403
@fnindex ATAN2
1404
@fnindex DATAN2
1405
@cindex trigonometric function, tangent, inverse
1406
@cindex tangent, inverse
1407
 
1408
@table @asis
1409
@item @emph{Description}:
1410
@code{ATAN2(Y, X)} computes the principal value of the argument
1411
function of the complex number @math{X + i Y}. This function can
1412
be used to transform from carthesian into polar coordinates and
1413
allows to determine the angle in the correct quadrant.
1414
 
1415
@item @emph{Standard}:
1416
Fortran 77 and later
1417
 
1418
@item @emph{Class}:
1419
Elemental function
1420
 
1421
@item @emph{Syntax}:
1422
@code{RESULT = ATAN2(Y, X)}
1423
 
1424
@item @emph{Arguments}:
1425
@multitable @columnfractions .15 .70
1426
@item @var{Y} @tab The type shall be @code{REAL}.
1427
@item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1428
If @var{Y} is zero, then @var{X} must be nonzero.
1429
@end multitable
1430
 
1431
@item @emph{Return value}:
1432
The return value has the same type and kind type parameter as @var{Y}.
1433
It is the principal value of the complex number @math{X + i Y}.  If
1434
@var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1435
The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1436
the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1437
is negative.  Finally, if @var{X} is zero, then the magnitude of the result
1438
is @math{\pi/2}.
1439
 
1440
@item @emph{Example}:
1441
@smallexample
1442
program test_atan2
1443
  real(4) :: x = 1.e0_4, y = 0.5e0_4
1444
  x = atan2(y,x)
1445
end program test_atan2
1446
@end smallexample
1447
 
1448
@item @emph{Specific names}:
1449
@multitable @columnfractions .20 .20 .20 .25
1450
@item Name            @tab Argument          @tab Return type    @tab Standard
1451
@item @code{DATAN2(X, Y)} @tab @code{REAL(8) X}, @code{REAL(8) Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1452
@end multitable
1453
@end table
1454
 
1455
 
1456
 
1457
@node ATANH
1458
@section @code{ATANH} --- Hyperbolic arctangent function
1459
@fnindex ASINH
1460
@fnindex DASINH
1461
@cindex area hyperbolic tangent
1462
@cindex hyperbolic arctangent
1463
@cindex hyperbolic function, tangent, inverse
1464
@cindex tangent, hyperbolic, inverse
1465
 
1466
@table @asis
1467
@item @emph{Description}:
1468
@code{ATANH(X)} computes the hyperbolic arctangent of @var{X} (inverse
1469
of @code{TANH(X)}).
1470
 
1471
@item @emph{Standard}:
1472
Fortran 2008 and later
1473
 
1474
@item @emph{Class}:
1475
Elemental function
1476
 
1477
@item @emph{Syntax}:
1478
@code{RESULT = ATANH(X)}
1479
 
1480
@item @emph{Arguments}:
1481
@multitable @columnfractions .15 .70
1482
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1483
@end multitable
1484
 
1485
@item @emph{Return value}:
1486
The return value has same type and kind as @var{X}. If @var{X} is
1487
complex, the imaginary part of the result is in radians and lies between
1488
@math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1489
 
1490
@item @emph{Example}:
1491
@smallexample
1492
PROGRAM test_atanh
1493
  REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1494
  WRITE (*,*) ATANH(x)
1495
END PROGRAM
1496
@end smallexample
1497
 
1498
@item @emph{Specific names}:
1499
@multitable @columnfractions .20 .20 .20 .25
1500
@item Name             @tab Argument          @tab Return type       @tab Standard
1501
@item @code{DATANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1502
@end multitable
1503
 
1504
@item @emph{See also}:
1505
Inverse function: @ref{TANH}
1506
@end table
1507
 
1508
 
1509
 
1510
@node BESSEL_J0
1511
@section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
1512
@fnindex BESSEL_J0
1513
@fnindex BESJ0
1514
@fnindex DBESJ0
1515
@cindex Bessel function, first kind
1516
 
1517
@table @asis
1518
@item @emph{Description}:
1519
@code{BESSEL_J0(X)} computes the Bessel function of the first kind of
1520
order 0 of @var{X}. This function is available under the name
1521
@code{BESJ0} as a GNU extension.
1522
 
1523
@item @emph{Standard}:
1524
Fortran 2008 and later
1525
 
1526
@item @emph{Class}:
1527
Elemental function
1528
 
1529
@item @emph{Syntax}:
1530
@code{RESULT = BESSEL_J0(X)}
1531
 
1532
@item @emph{Arguments}:
1533
@multitable @columnfractions .15 .70
1534
@item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1535
@end multitable
1536
 
1537
@item @emph{Return value}:
1538
The return value is of type @code{REAL} and lies in the
1539
range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
1540
kind as @var{X}.
1541
 
1542
@item @emph{Example}:
1543
@smallexample
1544
program test_besj0
1545
  real(8) :: x = 0.0_8
1546
  x = bessel_j0(x)
1547
end program test_besj0
1548
@end smallexample
1549
 
1550
@item @emph{Specific names}:
1551
@multitable @columnfractions .20 .20 .20 .25
1552
@item Name            @tab Argument          @tab Return type       @tab Standard
1553
@item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}   @tab GNU extension
1554
@end multitable
1555
@end table
1556
 
1557
 
1558
 
1559
@node BESSEL_J1
1560
@section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
1561
@fnindex BESSEL_J1
1562
@fnindex BESJ1
1563
@fnindex DBESJ1
1564
@cindex Bessel function, first kind
1565
 
1566
@table @asis
1567
@item @emph{Description}:
1568
@code{BESSEL_J1(X)} computes the Bessel function of the first kind of
1569
order 1 of @var{X}. This function is available under the name
1570
@code{BESJ1} as a GNU extension.
1571
 
1572
@item @emph{Standard}:
1573
Fortran 2008
1574
 
1575
@item @emph{Class}:
1576
Elemental function
1577
 
1578
@item @emph{Syntax}:
1579
@code{RESULT = BESSEL_J1(X)}
1580
 
1581
@item @emph{Arguments}:
1582
@multitable @columnfractions .15 .70
1583
@item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1584
@end multitable
1585
 
1586
@item @emph{Return value}:
1587
The return value is of type @code{REAL} and it lies in the
1588
range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
1589
kind as @var{X}.
1590
 
1591
@item @emph{Example}:
1592
@smallexample
1593
program test_besj1
1594
  real(8) :: x = 1.0_8
1595
  x = bessel_j1(x)
1596
end program test_besj1
1597
@end smallexample
1598
 
1599
@item @emph{Specific names}:
1600
@multitable @columnfractions .20 .20 .20 .25
1601
@item Name            @tab Argument          @tab Return type       @tab Standard
1602
@item @code{DBESJ1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1603
@end multitable
1604
@end table
1605
 
1606
 
1607
 
1608
@node BESSEL_JN
1609
@section @code{BESSEL_JN} --- Bessel function of the first kind
1610
@fnindex BESSEL_JN
1611
@fnindex BESJN
1612
@fnindex DBESJN
1613
@cindex Bessel function, first kind
1614
 
1615
@table @asis
1616
@item @emph{Description}:
1617
@code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
1618
order @var{N} of @var{X}. This function is available under the name
1619
@code{BESJN} as a GNU extension.
1620
 
1621
If both arguments are arrays, their ranks and shapes shall conform.
1622
 
1623
@item @emph{Standard}:
1624
Fortran 2008 and later
1625
 
1626
@item @emph{Class}:
1627
Elemental function
1628
 
1629
@item @emph{Syntax}:
1630
@code{RESULT = BESSEL_JN(N, X)}
1631
 
1632
@item @emph{Arguments}:
1633
@multitable @columnfractions .15 .70
1634
@item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1635
@item @var{X} @tab Shall be a scalar or an array of type  @code{REAL}.
1636
@end multitable
1637
 
1638
@item @emph{Return value}:
1639
The return value is a scalar of type @code{REAL}. It has the same
1640
kind as @var{X}.
1641
 
1642
@item @emph{Example}:
1643
@smallexample
1644
program test_besjn
1645
  real(8) :: x = 1.0_8
1646
  x = bessel_jn(5,x)
1647
end program test_besjn
1648
@end smallexample
1649
 
1650
@item @emph{Specific names}:
1651
@multitable @columnfractions .20 .20 .20 .25
1652
@item Name                @tab Argument            @tab Return type       @tab Standard
1653
@item @code{DBESJN(N, X)} @tab @code{INTEGER N}    @tab @code{REAL(8)}    @tab GNU extension
1654
@item                     @tab @code{REAL(8) X}    @tab                   @tab
1655
@end multitable
1656
@end table
1657
 
1658
 
1659
 
1660
@node BESSEL_Y0
1661
@section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
1662
@fnindex BESSEL_Y0
1663
@fnindex BESY0
1664
@fnindex DBESY0
1665
@cindex Bessel function, second kind
1666
 
1667
@table @asis
1668
@item @emph{Description}:
1669
@code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
1670
order 0 of @var{X}. This function is available under the name
1671
@code{BESY0} as a GNU extension.
1672
 
1673
@item @emph{Standard}:
1674
Fortran 2008 and later
1675
 
1676
@item @emph{Class}:
1677
Elemental function
1678
 
1679
@item @emph{Syntax}:
1680
@code{RESULT = BESSEL_Y0(X)}
1681
 
1682
@item @emph{Arguments}:
1683
@multitable @columnfractions .15 .70
1684
@item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1685
@end multitable
1686
 
1687
@item @emph{Return value}:
1688
The return value is a scalar of type @code{REAL}. It has the same
1689
kind as @var{X}.
1690
 
1691
@item @emph{Example}:
1692
@smallexample
1693
program test_besy0
1694
  real(8) :: x = 0.0_8
1695
  x = bessel_y0(x)
1696
end program test_besy0
1697
@end smallexample
1698
 
1699
@item @emph{Specific names}:
1700
@multitable @columnfractions .20 .20 .20 .25
1701
@item Name            @tab Argument          @tab Return type       @tab Standard
1702
@item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1703
@end multitable
1704
@end table
1705
 
1706
 
1707
 
1708
@node BESSEL_Y1
1709
@section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
1710
@fnindex BESSEL_Y1
1711
@fnindex BESY1
1712
@fnindex DBESY1
1713
@cindex Bessel function, second kind
1714
 
1715
@table @asis
1716
@item @emph{Description}:
1717
@code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
1718
order 1 of @var{X}. This function is available under the name
1719
@code{BESY1} as a GNU extension.
1720
 
1721
@item @emph{Standard}:
1722
Fortran 2008 and later
1723
 
1724
@item @emph{Class}:
1725
Elemental function
1726
 
1727
@item @emph{Syntax}:
1728
@code{RESULT = BESSEL_Y1(X)}
1729
 
1730
@item @emph{Arguments}:
1731
@multitable @columnfractions .15 .70
1732
@item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1733
@end multitable
1734
 
1735
@item @emph{Return value}:
1736
The return value is a scalar of type @code{REAL}. It has the same
1737
kind as @var{X}.
1738
 
1739
@item @emph{Example}:
1740
@smallexample
1741
program test_besy1
1742
  real(8) :: x = 1.0_8
1743
  x = bessel_y1(x)
1744
end program test_besy1
1745
@end smallexample
1746
 
1747
@item @emph{Specific names}:
1748
@multitable @columnfractions .20 .20 .20 .25
1749
@item Name            @tab Argument          @tab Return type       @tab Standard
1750
@item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1751
@end multitable
1752
@end table
1753
 
1754
 
1755
 
1756
@node BESSEL_YN
1757
@section @code{BESSEL_YN} --- Bessel function of the second kind
1758
@fnindex BESSEL_YN
1759
@fnindex BESYN
1760
@fnindex DBESYN
1761
@cindex Bessel function, second kind
1762
 
1763
@table @asis
1764
@item @emph{Description}:
1765
@code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
1766
order @var{N} of @var{X}. This function is available under the name
1767
@code{BESYN} as a GNU extension.
1768
 
1769
If both arguments are arrays, their ranks and shapes shall conform.
1770
 
1771
@item @emph{Standard}:
1772
Fortran 2008 and later
1773
 
1774
@item @emph{Class}:
1775
Elemental function
1776
 
1777
@item @emph{Syntax}:
1778
@code{RESULT = BESSEL_YN(N, X)}
1779
 
1780
@item @emph{Arguments}:
1781
@multitable @columnfractions .15 .70
1782
@item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1783
@item @var{X} @tab Shall be a scalar or an array of type  @code{REAL}.
1784
@end multitable
1785
 
1786
@item @emph{Return value}:
1787
The return value is a scalar of type @code{REAL}. It has the same
1788
kind as @var{X}.
1789
 
1790
@item @emph{Example}:
1791
@smallexample
1792
program test_besyn
1793
  real(8) :: x = 1.0_8
1794
  x = bessel_yn(5,x)
1795
end program test_besyn
1796
@end smallexample
1797
 
1798
@item @emph{Specific names}:
1799
@multitable @columnfractions .20 .20 .20 .25
1800
@item Name               @tab Argument            @tab Return type     @tab Standard
1801
@item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)}  @tab GNU extension
1802
@item                    @tab @code{REAL(8)    X} @tab                 @tab
1803
@end multitable
1804
@end table
1805
 
1806
 
1807
 
1808
@node BIT_SIZE
1809
@section @code{BIT_SIZE} --- Bit size inquiry function
1810
@fnindex BIT_SIZE
1811
@cindex bits, number of
1812
@cindex size of a variable, in bits
1813
 
1814
@table @asis
1815
@item @emph{Description}:
1816
@code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1817
represented by the type of @var{I}.  The result of @code{BIT_SIZE(I)} is
1818
independent of the actual value of @var{I}.
1819
 
1820
@item @emph{Standard}:
1821
Fortran 95 and later
1822
 
1823
@item @emph{Class}:
1824
Inquiry function
1825
 
1826
@item @emph{Syntax}:
1827
@code{RESULT = BIT_SIZE(I)}
1828
 
1829
@item @emph{Arguments}:
1830
@multitable @columnfractions .15 .70
1831
@item @var{I} @tab The type shall be @code{INTEGER}.
1832
@end multitable
1833
 
1834
@item @emph{Return value}:
1835
The return value is of type @code{INTEGER}
1836
 
1837
@item @emph{Example}:
1838
@smallexample
1839
program test_bit_size
1840
    integer :: i = 123
1841
    integer :: size
1842
    size = bit_size(i)
1843
    print *, size
1844
end program test_bit_size
1845
@end smallexample
1846
@end table
1847
 
1848
 
1849
 
1850
@node BTEST
1851
@section @code{BTEST} --- Bit test function
1852
@fnindex BTEST
1853
@cindex bits, testing
1854
 
1855
@table @asis
1856
@item @emph{Description}:
1857
@code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1858
in @var{I} is set.  The counting of the bits starts at 0.
1859
 
1860
@item @emph{Standard}:
1861
Fortran 95 and later
1862
 
1863
@item @emph{Class}:
1864
Elemental function
1865
 
1866
@item @emph{Syntax}:
1867
@code{RESULT = BTEST(I, POS)}
1868
 
1869
@item @emph{Arguments}:
1870
@multitable @columnfractions .15 .70
1871
@item @var{I} @tab The type shall be @code{INTEGER}.
1872
@item @var{POS} @tab The type shall be @code{INTEGER}.
1873
@end multitable
1874
 
1875
@item @emph{Return value}:
1876
The return value is of type @code{LOGICAL}
1877
 
1878
@item @emph{Example}:
1879
@smallexample
1880
program test_btest
1881
    integer :: i = 32768 + 1024 + 64
1882
    integer :: pos
1883
    logical :: bool
1884
    do pos=0,16
1885
        bool = btest(i, pos)
1886
        print *, pos, bool
1887
    end do
1888
end program test_btest
1889
@end smallexample
1890
@end table
1891
 
1892
 
1893
@node C_ASSOCIATED
1894
@section @code{C_ASSOCIATED} --- Status of a C pointer
1895
@fnindex C_ASSOCIATED
1896
@cindex association status, C pointer
1897
@cindex pointer, C association status
1898
 
1899
@table @asis
1900
@item @emph{Description}:
1901
@code{C_ASSOCIATED(c_prt_1[, c_ptr_2])} determines the status of the C pointer
1902
@var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
1903
 
1904
@item @emph{Standard}:
1905
Fortran 2003 and later
1906
 
1907
@item @emph{Class}:
1908
Inquiry function
1909
 
1910
@item @emph{Syntax}:
1911
@code{RESULT = C_ASSOCIATED(c_prt_1[, c_ptr_2])}
1912
 
1913
@item @emph{Arguments}:
1914
@multitable @columnfractions .15 .70
1915
@item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
1916
@item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
1917
@end multitable
1918
 
1919
@item @emph{Return value}:
1920
The return value is of type @code{LOGICAL}; it is @code{.false.} if either
1921
@var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
1922
point to different addresses.
1923
 
1924
@item @emph{Example}:
1925
@smallexample
1926
subroutine association_test(a,b)
1927
  use iso_c_binding, only: c_associated, c_loc, c_ptr
1928
  implicit none
1929
  real, pointer :: a
1930
  type(c_ptr) :: b
1931
  if(c_associated(b, c_loc(a))) &
1932
     stop 'b and a do not point to same target'
1933
end subroutine association_test
1934
@end smallexample
1935
 
1936
@item @emph{See also}:
1937
@ref{C_LOC}, @ref{C_FUNLOC}
1938
@end table
1939
 
1940
 
1941
@node C_FUNLOC
1942
@section @code{C_FUNLOC} --- Obtain the C address of a procedure
1943
@fnindex C_FUNLOC
1944
@cindex pointer, C address of procedures
1945
 
1946
@table @asis
1947
@item @emph{Description}:
1948
@code{C_FUNLOC(x)} determines the C address of the argument.
1949
 
1950
@item @emph{Standard}:
1951
Fortran 2003 and later
1952
 
1953
@item @emph{Class}:
1954
Inquiry function
1955
 
1956
@item @emph{Syntax}:
1957
@code{RESULT = C_FUNLOC(x)}
1958
 
1959
@item @emph{Arguments}:
1960
@multitable @columnfractions .15 .70
1961
@item @var{x} @tab Interoperable function or pointer to such function.
1962
@end multitable
1963
 
1964
@item @emph{Return value}:
1965
The return value is of type @code{C_FUNPTR} and contains the C address
1966
of the argument.
1967
 
1968
@item @emph{Example}:
1969
@smallexample
1970
module x
1971
  use iso_c_binding
1972
  implicit none
1973
contains
1974
  subroutine sub(a) bind(c)
1975
    real(c_float) :: a
1976
    a = sqrt(a)+5.0
1977
  end subroutine sub
1978
end module x
1979
program main
1980
  use iso_c_binding
1981
  use x
1982
  implicit none
1983
  interface
1984
    subroutine my_routine(p) bind(c,name='myC_func')
1985
      import :: c_funptr
1986
      type(c_funptr), intent(in) :: p
1987
    end subroutine
1988
  end interface
1989
  call my_routine(c_funloc(sub))
1990
end program main
1991
@end smallexample
1992
 
1993
@item @emph{See also}:
1994
@ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
1995
@end table
1996
 
1997
 
1998
@node C_F_PROCPOINTER
1999
@section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
2000
@fnindex C_F_PROCPOINTER
2001
@cindex pointer, C address of pointers
2002
 
2003
@table @asis
2004
@item @emph{Description}:
2005
@code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
2006
@var{CPTR} to the Fortran procedure pointer @var{FPTR}.
2007
 
2008
@item @emph{Standard}:
2009
Fortran 2003 and later
2010
 
2011
@item @emph{Class}:
2012
Subroutine
2013
 
2014
@item @emph{Syntax}:
2015
@code{CALL C_F_PROCPOINTER(cptr, fptr)}
2016
 
2017
@item @emph{Arguments}:
2018
@multitable @columnfractions .15 .70
2019
@item @var{CPTR}  @tab scalar of the type @code{C_FUNPTR}. It is
2020
@code{INTENT(IN)}.
2021
@item @var{FPTR}  @tab procedure pointer interoperable with @var{cptr}. It is
2022
@code{INTENT(OUT)}.
2023
@end multitable
2024
 
2025
@item @emph{Example}:
2026
@smallexample
2027
program main
2028
  use iso_c_binding
2029
  implicit none
2030
  abstract interface
2031
    function func(a)
2032
      import :: c_float
2033
      real(c_float), intent(in) :: a
2034
      real(c_float) :: func
2035
    end function
2036
  end interface
2037
  interface
2038
     function getIterFunc() bind(c,name="getIterFunc")
2039
       import :: c_funptr
2040
       type(c_funptr) :: getIterFunc
2041
     end function
2042
  end interface
2043
  type(c_funptr) :: cfunptr
2044
  procedure(func), pointer :: myFunc
2045
  cfunptr = getIterFunc()
2046
  call c_f_procpointer(cfunptr, myFunc)
2047
end program main
2048
@end smallexample
2049
 
2050
@item @emph{See also}:
2051
@ref{C_LOC}, @ref{C_F_POINTER}
2052
@end table
2053
 
2054
 
2055
@node C_F_POINTER
2056
@section @code{C_F_POINTER} --- Convert C into Fortran pointer
2057
@fnindex C_F_POINTER
2058
@cindex pointer, convert C to Fortran
2059
 
2060
@table @asis
2061
@item @emph{Description}:
2062
@code{C_F_POINTER(CPTR, FPTR[, SHAPE])} Assign the target the C pointer
2063
@var{CPTR} to the Fortran pointer @var{FPTR} and specify its
2064
shape.
2065
 
2066
@item @emph{Standard}:
2067
Fortran 2003 and later
2068
 
2069
@item @emph{Class}:
2070
Subroutine
2071
 
2072
@item @emph{Syntax}:
2073
@code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
2074
 
2075
@item @emph{Arguments}:
2076
@multitable @columnfractions .15 .70
2077
@item @var{CPTR}  @tab scalar of the type @code{C_PTR}. It is
2078
@code{INTENT(IN)}.
2079
@item @var{FPTR}  @tab pointer interoperable with @var{cptr}. It is
2080
@code{INTENT(OUT)}.
2081
@item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
2082
with @code{INTENT(IN)}. It shall be present
2083
if and only if @var{fptr} is an array. The size
2084
must be equal to the rank of @var{fptr}.
2085
@end multitable
2086
 
2087
@item @emph{Example}:
2088
@smallexample
2089
program main
2090
  use iso_c_binding
2091
  implicit none
2092
  interface
2093
    subroutine my_routine(p) bind(c,name='myC_func')
2094
      import :: c_ptr
2095
      type(c_ptr), intent(out) :: p
2096
    end subroutine
2097
  end interface
2098
  type(c_ptr) :: cptr
2099
  real,pointer :: a(:)
2100
  call my_routine(cptr)
2101
  call c_f_pointer(cptr, a, [12])
2102
end program main
2103
@end smallexample
2104
 
2105
@item @emph{See also}:
2106
@ref{C_LOC}, @ref{C_F_PROCPOINTER}
2107
@end table
2108
 
2109
 
2110
@node C_LOC
2111
@section @code{C_LOC} --- Obtain the C address of an object
2112
@fnindex C_LOC
2113
@cindex procedure pointer, convert C to Fortran
2114
 
2115
@table @asis
2116
@item @emph{Description}:
2117
@code{C_LOC(X)} determines the C address of the argument.
2118
 
2119
@item @emph{Standard}:
2120
Fortran 2003 and later
2121
 
2122
@item @emph{Class}:
2123
Inquiry function
2124
 
2125
@item @emph{Syntax}:
2126
@code{RESULT = C_LOC(X)}
2127
 
2128
@item @emph{Arguments}:
2129
@multitable @columnfractions .15 .70
2130
@item @var{X} @tab Associated scalar pointer or interoperable scalar
2131
or allocated allocatable variable with @code{TARGET} attribute.
2132
@end multitable
2133
 
2134
@item @emph{Return value}:
2135
The return value is of type @code{C_PTR} and contains the C address
2136
of the argument.
2137
 
2138
@item @emph{Example}:
2139
@smallexample
2140
subroutine association_test(a,b)
2141
  use iso_c_binding, only: c_associated, c_loc, c_ptr
2142
  implicit none
2143
  real, pointer :: a
2144
  type(c_ptr) :: b
2145
  if(c_associated(b, c_loc(a))) &
2146
     stop 'b and a do not point to same target'
2147
end subroutine association_test
2148
@end smallexample
2149
 
2150
@item @emph{See also}:
2151
@ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2152
@end table
2153
 
2154
 
2155
@node C_SIZEOF
2156
@section @code{C_SIZEOF} --- Size in bytes of an expression
2157
@fnindex C_SIZEOF
2158
@cindex expression size
2159
@cindex size of an expression
2160
 
2161
@table @asis
2162
@item @emph{Description}:
2163
@code{C_SIZEOF(X)} calculates the number of bytes of storage the
2164
expression @code{X} occupies.
2165
 
2166
@item @emph{Standard}:
2167
Fortran 2008
2168
 
2169
@item @emph{Class}:
2170
Intrinsic function
2171
 
2172
@item @emph{Syntax}:
2173
@code{N = C_SIZEOF(X)}
2174
 
2175
@item @emph{Arguments}:
2176
@multitable @columnfractions .15 .70
2177
@item @var{X} @tab The argument shall be of any type, rank or shape.
2178
@end multitable
2179
 
2180
@item @emph{Return value}:
2181
The return value is of type integer and of the system-dependent kind
2182
@var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
2183
number of bytes occupied by the argument.  If the argument has the
2184
@code{POINTER} attribute, the number of bytes of the storage area pointed
2185
to is returned.  If the argument is of a derived type with @code{POINTER}
2186
or @code{ALLOCATABLE} components, the return value doesn't account for
2187
the sizes of the data pointed to by these components.
2188
 
2189
@item @emph{Example}:
2190
@smallexample
2191
   use iso_c_binding
2192
   integer(c_int) :: i
2193
   real(c_float) :: r, s(5)
2194
   print *, (c_sizeof(s)/c_sizeof(r) == 5)
2195
   end
2196
@end smallexample
2197
The example will print @code{.TRUE.} unless you are using a platform
2198
where default @code{REAL} variables are unusually padded.
2199
 
2200
@item @emph{See also}:
2201
@ref{SIZEOF}
2202
@end table
2203
 
2204
 
2205
@node CEILING
2206
@section @code{CEILING} --- Integer ceiling function
2207
@fnindex CEILING
2208
@cindex ceiling
2209
@cindex rounding, ceiling
2210
 
2211
@table @asis
2212
@item @emph{Description}:
2213
@code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
2214
 
2215
@item @emph{Standard}:
2216
Fortran 95 and later
2217
 
2218
@item @emph{Class}:
2219
Elemental function
2220
 
2221
@item @emph{Syntax}:
2222
@code{RESULT = CEILING(A [, KIND])}
2223
 
2224
@item @emph{Arguments}:
2225
@multitable @columnfractions .15 .70
2226
@item @var{A} @tab The type shall be @code{REAL}.
2227
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2228
expression indicating the kind parameter of the result.
2229
@end multitable
2230
 
2231
@item @emph{Return value}:
2232
The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
2233
and a default-kind @code{INTEGER} otherwise.
2234
 
2235
@item @emph{Example}:
2236
@smallexample
2237
program test_ceiling
2238
    real :: x = 63.29
2239
    real :: y = -63.59
2240
    print *, ceiling(x) ! returns 64
2241
    print *, ceiling(y) ! returns -63
2242
end program test_ceiling
2243
@end smallexample
2244
 
2245
@item @emph{See also}:
2246
@ref{FLOOR}, @ref{NINT}
2247
 
2248
@end table
2249
 
2250
 
2251
 
2252
@node CHAR
2253
@section @code{CHAR} --- Character conversion function
2254
@fnindex CHAR
2255
@cindex conversion, to character
2256
 
2257
@table @asis
2258
@item @emph{Description}:
2259
@code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2260
 
2261
@item @emph{Standard}:
2262
Fortran 77 and later
2263
 
2264
@item @emph{Class}:
2265
Elemental function
2266
 
2267
@item @emph{Syntax}:
2268
@code{RESULT = CHAR(I [, KIND])}
2269
 
2270
@item @emph{Arguments}:
2271
@multitable @columnfractions .15 .70
2272
@item @var{I} @tab The type shall be @code{INTEGER}.
2273
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2274
expression indicating the kind parameter of the result.
2275
@end multitable
2276
 
2277
@item @emph{Return value}:
2278
The return value is of type @code{CHARACTER(1)}
2279
 
2280
@item @emph{Example}:
2281
@smallexample
2282
program test_char
2283
    integer :: i = 74
2284
    character(1) :: c
2285
    c = char(i)
2286
    print *, i, c ! returns 'J'
2287
end program test_char
2288
@end smallexample
2289
 
2290
@item @emph{Note}:
2291
See @ref{ICHAR} for a discussion of converting between numerical values
2292
and formatted string representations.
2293
 
2294
@item @emph{See also}:
2295
@ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2296
 
2297
@end table
2298
 
2299
 
2300
 
2301
@node CHDIR
2302
@section @code{CHDIR} --- Change working directory
2303
@fnindex CHDIR
2304
@cindex system, working directory
2305
 
2306
@table @asis
2307
@item @emph{Description}:
2308
Change current working directory to a specified path.
2309
 
2310
This intrinsic is provided in both subroutine and function forms; however,
2311
only one form can be used in any given program unit.
2312
 
2313
@item @emph{Standard}:
2314
GNU extension
2315
 
2316
@item @emph{Class}:
2317
Subroutine, function
2318
 
2319
@item @emph{Syntax}:
2320
@multitable @columnfractions .80
2321
@item @code{CALL CHDIR(NAME [, STATUS])}
2322
@item @code{STATUS = CHDIR(NAME)}
2323
@end multitable
2324
 
2325
@item @emph{Arguments}:
2326
@multitable @columnfractions .15 .70
2327
@item @var{NAME}   @tab The type shall be @code{CHARACTER} of default
2328
kind and shall specify a valid path within the file system.
2329
@item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2330
kind.  Returns 0 on success, and a system specific and nonzero error code
2331
otherwise.
2332
@end multitable
2333
 
2334
@item @emph{Example}:
2335
@smallexample
2336
PROGRAM test_chdir
2337
  CHARACTER(len=255) :: path
2338
  CALL getcwd(path)
2339
  WRITE(*,*) TRIM(path)
2340
  CALL chdir("/tmp")
2341
  CALL getcwd(path)
2342
  WRITE(*,*) TRIM(path)
2343
END PROGRAM
2344
@end smallexample
2345
 
2346
@item @emph{See also}:
2347
@ref{GETCWD}
2348
@end table
2349
 
2350
 
2351
 
2352
@node CHMOD
2353
@section @code{CHMOD} --- Change access permissions of files
2354
@fnindex CHMOD
2355
@cindex file system, change access mode
2356
 
2357
@table @asis
2358
@item @emph{Description}:
2359
@code{CHMOD} changes the permissions of a file. This function invokes
2360
@code{/bin/chmod} and might therefore not work on all platforms.
2361
 
2362
This intrinsic is provided in both subroutine and function forms; however,
2363
only one form can be used in any given program unit.
2364
 
2365
@item @emph{Standard}:
2366
GNU extension
2367
 
2368
@item @emph{Class}:
2369
Subroutine, function
2370
 
2371
@item @emph{Syntax}:
2372
@multitable @columnfractions .80
2373
@item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2374
@item @code{STATUS = CHMOD(NAME, MODE)}
2375
@end multitable
2376
 
2377
@item @emph{Arguments}:
2378
@multitable @columnfractions .15 .70
2379
 
2380
@item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
2381
file name. Trailing blanks are ignored unless the character
2382
@code{achar(0)} is present, then all characters up to and excluding
2383
@code{achar(0)} are used as the file name.
2384
 
2385
@item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
2386
file permission. @var{MODE} uses the same syntax as the @var{MODE}
2387
argument of @code{/bin/chmod}.
2388
 
2389
@item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2390
@code{0} on success and nonzero otherwise.
2391
@end multitable
2392
 
2393
@item @emph{Return value}:
2394
In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2395
otherwise.
2396
 
2397
@item @emph{Example}:
2398
@code{CHMOD} as subroutine
2399
@smallexample
2400
program chmod_test
2401
  implicit none
2402
  integer :: status
2403
  call chmod('test.dat','u+x',status)
2404
  print *, 'Status: ', status
2405
end program chmod_test
2406
@end smallexample
2407
@code{CHMOD} as function:
2408
@smallexample
2409
program chmod_test
2410
  implicit none
2411
  integer :: status
2412
  status = chmod('test.dat','u+x')
2413
  print *, 'Status: ', status
2414
end program chmod_test
2415
@end smallexample
2416
 
2417
@end table
2418
 
2419
 
2420
 
2421
@node CMPLX
2422
@section @code{CMPLX} --- Complex conversion function
2423
@fnindex CMPLX
2424
@cindex complex numbers, conversion to
2425
@cindex conversion, to complex
2426
 
2427
@table @asis
2428
@item @emph{Description}:
2429
@code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2430
the real component.  If @var{Y} is present it is converted to the imaginary
2431
component.  If @var{Y} is not present then the imaginary component is set to
2432
0.0.  If @var{X} is complex then @var{Y} must not be present.
2433
 
2434
@item @emph{Standard}:
2435
Fortran 77 and later
2436
 
2437
@item @emph{Class}:
2438
Elemental function
2439
 
2440
@item @emph{Syntax}:
2441
@code{RESULT = CMPLX(X [, Y [, KIND]])}
2442
 
2443
@item @emph{Arguments}:
2444
@multitable @columnfractions .15 .70
2445
@item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
2446
or @code{COMPLEX}.
2447
@item @var{Y} @tab (Optional; only allowed if @var{X} is not
2448
@code{COMPLEX}.)  May be @code{INTEGER} or @code{REAL}.
2449
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2450
expression indicating the kind parameter of the result.
2451
@end multitable
2452
 
2453
@item @emph{Return value}:
2454
The return value is of @code{COMPLEX} type, with a kind equal to
2455
@var{KIND} if it is specified.  If @var{KIND} is not specified, the
2456
result is of the default @code{COMPLEX} kind, regardless of the kinds of
2457
@var{X} and @var{Y}.
2458
 
2459
@item @emph{Example}:
2460
@smallexample
2461
program test_cmplx
2462
    integer :: i = 42
2463
    real :: x = 3.14
2464
    complex :: z
2465
    z = cmplx(i, x)
2466
    print *, z, cmplx(x)
2467
end program test_cmplx
2468
@end smallexample
2469
 
2470
@item @emph{See also}:
2471
@ref{COMPLEX}
2472
@end table
2473
 
2474
 
2475
 
2476
@node COMMAND_ARGUMENT_COUNT
2477
@section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2478
@fnindex COMMAND_ARGUMENT_COUNT
2479
@cindex command-line arguments
2480
@cindex command-line arguments, number of
2481
@cindex arguments, to program
2482
 
2483
@table @asis
2484
@item @emph{Description}:
2485
@code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2486
command line when the containing program was invoked.
2487
 
2488
@item @emph{Standard}:
2489
Fortran 2003 and later
2490
 
2491
@item @emph{Class}:
2492
Inquiry function
2493
 
2494
@item @emph{Syntax}:
2495
@code{RESULT = COMMAND_ARGUMENT_COUNT()}
2496
 
2497
@item @emph{Arguments}:
2498
@multitable @columnfractions .15 .70
2499
@item None
2500
@end multitable
2501
 
2502
@item @emph{Return value}:
2503
The return value is an @code{INTEGER} of default kind.
2504
 
2505
@item @emph{Example}:
2506
@smallexample
2507
program test_command_argument_count
2508
    integer :: count
2509
    count = command_argument_count()
2510
    print *, count
2511
end program test_command_argument_count
2512
@end smallexample
2513
 
2514
@item @emph{See also}:
2515
@ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2516
@end table
2517
 
2518
 
2519
 
2520
@node COMPLEX
2521
@section @code{COMPLEX} --- Complex conversion function
2522
@fnindex COMPLEX
2523
@cindex complex numbers, conversion to
2524
@cindex conversion, to complex
2525
 
2526
@table @asis
2527
@item @emph{Description}:
2528
@code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2529
to the real component and @var{Y} is converted to the imaginary
2530
component.
2531
 
2532
@item @emph{Standard}:
2533
GNU extension
2534
 
2535
@item @emph{Class}:
2536
Elemental function
2537
 
2538
@item @emph{Syntax}:
2539
@code{RESULT = COMPLEX(X, Y)}
2540
 
2541
@item @emph{Arguments}:
2542
@multitable @columnfractions .15 .70
2543
@item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
2544
@item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
2545
@end multitable
2546
 
2547
@item @emph{Return value}:
2548
If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2549
value is of default @code{COMPLEX} type.
2550
 
2551
If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2552
type and one is of @code{INTEGER} type, then the return value is of
2553
@code{COMPLEX} type with a kind equal to that of the @code{REAL}
2554
argument with the highest precision.
2555
 
2556
@item @emph{Example}:
2557
@smallexample
2558
program test_complex
2559
    integer :: i = 42
2560
    real :: x = 3.14
2561
    print *, complex(i, x)
2562
end program test_complex
2563
@end smallexample
2564
 
2565
@item @emph{See also}:
2566
@ref{CMPLX}
2567
@end table
2568
 
2569
 
2570
 
2571
@node CONJG
2572
@section @code{CONJG} --- Complex conjugate function
2573
@fnindex CONJG
2574
@fnindex DCONJG
2575
@cindex complex conjugate
2576
 
2577
@table @asis
2578
@item @emph{Description}:
2579
@code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
2580
then the result is @code{(x, -y)}
2581
 
2582
@item @emph{Standard}:
2583
Fortran 77 and later, has overloads that are GNU extensions
2584
 
2585
@item @emph{Class}:
2586
Elemental function
2587
 
2588
@item @emph{Syntax}:
2589
@code{Z = CONJG(Z)}
2590
 
2591
@item @emph{Arguments}:
2592
@multitable @columnfractions .15 .70
2593
@item @var{Z} @tab The type shall be @code{COMPLEX}.
2594
@end multitable
2595
 
2596
@item @emph{Return value}:
2597
The return value is of type @code{COMPLEX}.
2598
 
2599
@item @emph{Example}:
2600
@smallexample
2601
program test_conjg
2602
    complex :: z = (2.0, 3.0)
2603
    complex(8) :: dz = (2.71_8, -3.14_8)
2604
    z= conjg(z)
2605
    print *, z
2606
    dz = dconjg(dz)
2607
    print *, dz
2608
end program test_conjg
2609
@end smallexample
2610
 
2611
@item @emph{Specific names}:
2612
@multitable @columnfractions .20 .20 .20 .25
2613
@item Name             @tab Argument             @tab Return type          @tab Standard
2614
@item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)}    @tab GNU extension
2615
@end multitable
2616
@end table
2617
 
2618
 
2619
 
2620
@node COS
2621
@section @code{COS} --- Cosine function
2622
@fnindex COS
2623
@fnindex DCOS
2624
@fnindex CCOS
2625
@fnindex ZCOS
2626
@fnindex CDCOS
2627
@cindex trigonometric function, cosine
2628
@cindex cosine
2629
 
2630
@table @asis
2631
@item @emph{Description}:
2632
@code{COS(X)} computes the cosine of @var{X}.
2633
 
2634
@item @emph{Standard}:
2635
Fortran 77 and later, has overloads that are GNU extensions
2636
 
2637
@item @emph{Class}:
2638
Elemental function
2639
 
2640
@item @emph{Syntax}:
2641
@code{RESULT = COS(X)}
2642
 
2643
@item @emph{Arguments}:
2644
@multitable @columnfractions .15 .70
2645
@item @var{X} @tab The type shall be @code{REAL} or
2646
@code{COMPLEX}.
2647
@end multitable
2648
 
2649
@item @emph{Return value}:
2650
The return value is of the same type and kind as @var{X}. The real part
2651
of the result is in radians. If @var{X} is of the type @code{REAL},
2652
the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
2653
 
2654
@item @emph{Example}:
2655
@smallexample
2656
program test_cos
2657
  real :: x = 0.0
2658
  x = cos(x)
2659
end program test_cos
2660
@end smallexample
2661
 
2662
@item @emph{Specific names}:
2663
@multitable @columnfractions .20 .20 .20 .25
2664
@item Name            @tab Argument            @tab Return type       @tab Standard
2665
@item @code{DCOS(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab Fortran 77 and later
2666
@item @code{CCOS(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
2667
@item @code{ZCOS(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2668
@item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2669
@end multitable
2670
 
2671
@item @emph{See also}:
2672
Inverse function: @ref{ACOS}
2673
 
2674
@end table
2675
 
2676
 
2677
 
2678
@node COSH
2679
@section @code{COSH} --- Hyperbolic cosine function
2680
@fnindex COSH
2681
@fnindex DCOSH
2682
@cindex hyperbolic cosine
2683
@cindex hyperbolic function, cosine
2684
@cindex cosine, hyperbolic
2685
 
2686
@table @asis
2687
@item @emph{Description}:
2688
@code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2689
 
2690
@item @emph{Standard}:
2691
Fortran 77 and later, for a complex argument Fortran 2008 or later
2692
 
2693
@item @emph{Class}:
2694
Elemental function
2695
 
2696
@item @emph{Syntax}:
2697
@code{X = COSH(X)}
2698
 
2699
@item @emph{Arguments}:
2700
@multitable @columnfractions .15 .70
2701
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
2702
@end multitable
2703
 
2704
@item @emph{Return value}:
2705
The return value has same type and kind as @var{X}. If @var{X} is
2706
complex, the imaginary part of the result is in radians. If @var{X}
2707
is @code{REAL}, the return value has a lower bound of one,
2708
@math{\cosh (x) \geq 1}.
2709
 
2710
@item @emph{Example}:
2711
@smallexample
2712
program test_cosh
2713
  real(8) :: x = 1.0_8
2714
  x = cosh(x)
2715
end program test_cosh
2716
@end smallexample
2717
 
2718
@item @emph{Specific names}:
2719
@multitable @columnfractions .20 .20 .20 .25
2720
@item Name            @tab Argument          @tab Return type       @tab Standard
2721
@item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
2722
@end multitable
2723
 
2724
@item @emph{See also}:
2725
Inverse function: @ref{ACOSH}
2726
 
2727
@end table
2728
 
2729
 
2730
 
2731
@node COUNT
2732
@section @code{COUNT} --- Count function
2733
@fnindex COUNT
2734
@cindex array, conditionally count elements
2735
@cindex array, element counting
2736
@cindex array, number of elements
2737
 
2738
@table @asis
2739
@item @emph{Description}:
2740
 
2741
Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
2742
or, if the @var{DIM} argument is supplied, counts the number of
2743
elements along each row of the array in the @var{DIM} direction.
2744
If the array has zero size, or all of the elements of @var{MASK} are
2745
@code{.FALSE.}, then the result is @code{0}.
2746
 
2747
@item @emph{Standard}:
2748
Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
2749
 
2750
@item @emph{Class}:
2751
Transformational function
2752
 
2753
@item @emph{Syntax}:
2754
@code{RESULT = COUNT(MASK [, DIM, KIND])}
2755
 
2756
@item @emph{Arguments}:
2757
@multitable @columnfractions .15 .70
2758
@item @var{MASK} @tab The type shall be @code{LOGICAL}.
2759
@item @var{DIM}  @tab (Optional) The type shall be @code{INTEGER}.
2760
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2761
expression indicating the kind parameter of the result.
2762
@end multitable
2763
 
2764
@item @emph{Return value}:
2765
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
2766
@var{KIND} is absent, the return value is of default integer kind.
2767
If @var{DIM} is present, the result is an array with a rank one less
2768
than the rank of @var{ARRAY}, and a size corresponding to the shape
2769
of @var{ARRAY} with the @var{DIM} dimension removed.
2770
 
2771
@item @emph{Example}:
2772
@smallexample
2773
program test_count
2774
    integer, dimension(2,3) :: a, b
2775
    logical, dimension(2,3) :: mask
2776
    a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2777
    b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2778
    print '(3i3)', a(1,:)
2779
    print '(3i3)', a(2,:)
2780
    print *
2781
    print '(3i3)', b(1,:)
2782
    print '(3i3)', b(2,:)
2783
    print *
2784
    mask = a.ne.b
2785
    print '(3l3)', mask(1,:)
2786
    print '(3l3)', mask(2,:)
2787
    print *
2788
    print '(3i3)', count(mask)
2789
    print *
2790
    print '(3i3)', count(mask, 1)
2791
    print *
2792
    print '(3i3)', count(mask, 2)
2793
end program test_count
2794
@end smallexample
2795
@end table
2796
 
2797
 
2798
 
2799
@node CPU_TIME
2800
@section @code{CPU_TIME} --- CPU elapsed time in seconds
2801
@fnindex CPU_TIME
2802
@cindex time, elapsed
2803
 
2804
@table @asis
2805
@item @emph{Description}:
2806
Returns a @code{REAL} value representing the elapsed CPU time in
2807
seconds.  This is useful for testing segments of code to determine
2808
execution time.
2809
 
2810
If a time source is available, time will be reported with microsecond
2811
resolution. If no time source is available, @var{TIME} is set to
2812
@code{-1.0}.
2813
 
2814
Note that @var{TIME} may contain a, system dependent, arbitrary offset
2815
and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
2816
value is meaningless, only differences between subsequent calls to
2817
this subroutine, as shown in the example below, should be used.
2818
 
2819
 
2820
@item @emph{Standard}:
2821
Fortran 95 and later
2822
 
2823
@item @emph{Class}:
2824
Subroutine
2825
 
2826
@item @emph{Syntax}:
2827
@code{CALL CPU_TIME(TIME)}
2828
 
2829
@item @emph{Arguments}:
2830
@multitable @columnfractions .15 .70
2831
@item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2832
@end multitable
2833
 
2834
@item @emph{Return value}:
2835
None
2836
 
2837
@item @emph{Example}:
2838
@smallexample
2839
program test_cpu_time
2840
    real :: start, finish
2841
    call cpu_time(start)
2842
        ! put code to test here
2843
    call cpu_time(finish)
2844
    print '("Time = ",f6.3," seconds.")',finish-start
2845
end program test_cpu_time
2846
@end smallexample
2847
 
2848
@item @emph{See also}:
2849
@ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2850
@end table
2851
 
2852
 
2853
 
2854
@node CSHIFT
2855
@section @code{CSHIFT} --- Circular shift elements of an array
2856
@fnindex CSHIFT
2857
@cindex array, shift circularly
2858
@cindex array, permutation
2859
@cindex array, rotate
2860
 
2861
@table @asis
2862
@item @emph{Description}:
2863
@code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2864
@var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
2865
taken to be @code{1}.  @var{DIM} is a scalar of type @code{INTEGER} in the
2866
range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
2867
If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2868
by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
2869
sections of @var{ARRAY} along the given dimension are shifted.  Elements
2870
shifted out one end of each rank one section are shifted back in the other end.
2871
 
2872
@item @emph{Standard}:
2873
Fortran 95 and later
2874
 
2875
@item @emph{Class}:
2876
Transformational function
2877
 
2878
@item @emph{Syntax}:
2879
@code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
2880
 
2881
@item @emph{Arguments}:
2882
@multitable @columnfractions .15 .70
2883
@item @var{ARRAY}  @tab Shall be an array of any type.
2884
@item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
2885
@item @var{DIM}    @tab The type shall be @code{INTEGER}.
2886
@end multitable
2887
 
2888
@item @emph{Return value}:
2889
Returns an array of same type and rank as the @var{ARRAY} argument.
2890
 
2891
@item @emph{Example}:
2892
@smallexample
2893
program test_cshift
2894
    integer, dimension(3,3) :: a
2895
    a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2896
    print '(3i3)', a(1,:)
2897
    print '(3i3)', a(2,:)
2898
    print '(3i3)', a(3,:)
2899
    a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2900
    print *
2901
    print '(3i3)', a(1,:)
2902
    print '(3i3)', a(2,:)
2903
    print '(3i3)', a(3,:)
2904
end program test_cshift
2905
@end smallexample
2906
@end table
2907
 
2908
 
2909
 
2910
@node CTIME
2911
@section @code{CTIME} --- Convert a time into a string
2912
@fnindex CTIME
2913
@cindex time, conversion to string
2914
@cindex conversion, to string
2915
 
2916
@table @asis
2917
@item @emph{Description}:
2918
@code{CTIME} converts a system time value, such as returned by
2919
@code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2920
 
2921
This intrinsic is provided in both subroutine and function forms; however,
2922
only one form can be used in any given program unit.
2923
 
2924
@item @emph{Standard}:
2925
GNU extension
2926
 
2927
@item @emph{Class}:
2928
Subroutine, function
2929
 
2930
@item @emph{Syntax}:
2931
@multitable @columnfractions .80
2932
@item @code{CALL CTIME(TIME, RESULT)}.
2933
@item @code{RESULT = CTIME(TIME)}, (not recommended).
2934
@end multitable
2935
 
2936
@item @emph{Arguments}:
2937
@multitable @columnfractions .15 .70
2938
@item @var{TIME}    @tab The type shall be of type @code{INTEGER(KIND=8)}.
2939
@item @var{RESULT}  @tab The type shall be of type @code{CHARACTER} and
2940
of default kind.
2941
@end multitable
2942
 
2943
@item @emph{Return value}:
2944
The converted date and time as a string.
2945
 
2946
@item @emph{Example}:
2947
@smallexample
2948
program test_ctime
2949
    integer(8) :: i
2950
    character(len=30) :: date
2951
    i = time8()
2952
 
2953
    ! Do something, main part of the program
2954
 
2955
    call ctime(i,date)
2956
    print *, 'Program was started on ', date
2957
end program test_ctime
2958
@end smallexample
2959
 
2960
@item @emph{See Also}:
2961
@ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2962
@end table
2963
 
2964
 
2965
 
2966
@node DATE_AND_TIME
2967
@section @code{DATE_AND_TIME} --- Date and time subroutine
2968
@fnindex DATE_AND_TIME
2969
@cindex date, current
2970
@cindex current date
2971
@cindex time, current
2972
@cindex current time
2973
 
2974
@table @asis
2975
@item @emph{Description}:
2976
@code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2977
time information from the real-time system clock.  @var{DATE} is
2978
@code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
2979
has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2980
representing the difference with respect to Coordinated Universal Time (UTC).
2981
Unavailable time and date parameters return blanks.
2982
 
2983
@var{VALUES} is @code{INTENT(OUT)} and provides the following:
2984
 
2985
@multitable @columnfractions .15 .30 .40
2986
@item @tab @code{VALUE(1)}: @tab The year
2987
@item @tab @code{VALUE(2)}: @tab The month
2988
@item @tab @code{VALUE(3)}: @tab The day of the month
2989
@item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2990
@item @tab @code{VALUE(5)}: @tab The hour of the day
2991
@item @tab @code{VALUE(6)}: @tab The minutes of the hour
2992
@item @tab @code{VALUE(7)}: @tab The seconds of the minute
2993
@item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2994
@end multitable
2995
 
2996
@item @emph{Standard}:
2997
Fortran 95 and later
2998
 
2999
@item @emph{Class}:
3000
Subroutine
3001
 
3002
@item @emph{Syntax}:
3003
@code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
3004
 
3005
@item @emph{Arguments}:
3006
@multitable @columnfractions .15 .70
3007
@item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
3008
or larger, and of default kind.
3009
@item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
3010
or larger, and of default kind.
3011
@item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
3012
or larger, and of default kind.
3013
@item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
3014
@end multitable
3015
 
3016
@item @emph{Return value}:
3017
None
3018
 
3019
@item @emph{Example}:
3020
@smallexample
3021
program test_time_and_date
3022
    character(8)  :: date
3023
    character(10) :: time
3024
    character(5)  :: zone
3025
    integer,dimension(8) :: values
3026
    ! using keyword arguments
3027
    call date_and_time(date,time,zone,values)
3028
    call date_and_time(DATE=date,ZONE=zone)
3029
    call date_and_time(TIME=time)
3030
    call date_and_time(VALUES=values)
3031
    print '(a,2x,a,2x,a)', date, time, zone
3032
    print '(8i5))', values
3033
end program test_time_and_date
3034
@end smallexample
3035
 
3036
@item @emph{See also}:
3037
@ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
3038
@end table
3039
 
3040
 
3041
 
3042
@node DBLE
3043
@section @code{DBLE} --- Double conversion function
3044
@fnindex DBLE
3045
@cindex conversion, to real
3046
 
3047
@table @asis
3048
@item @emph{Description}:
3049
@code{DBLE(A)} Converts @var{A} to double precision real type.
3050
 
3051
@item @emph{Standard}:
3052
Fortran 77 and later
3053
 
3054
@item @emph{Class}:
3055
Elemental function
3056
 
3057
@item @emph{Syntax}:
3058
@code{RESULT = DBLE(A)}
3059
 
3060
@item @emph{Arguments}:
3061
@multitable @columnfractions .15 .70
3062
@item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
3063
or @code{COMPLEX}.
3064
@end multitable
3065
 
3066
@item @emph{Return value}:
3067
The return value is of type double precision real.
3068
 
3069
@item @emph{Example}:
3070
@smallexample
3071
program test_dble
3072
    real    :: x = 2.18
3073
    integer :: i = 5
3074
    complex :: z = (2.3,1.14)
3075
    print *, dble(x), dble(i), dble(z)
3076
end program test_dble
3077
@end smallexample
3078
 
3079
@item @emph{See also}:
3080
@ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
3081
@end table
3082
 
3083
 
3084
 
3085
@node DCMPLX
3086
@section @code{DCMPLX} --- Double complex conversion function
3087
@fnindex DCMPLX
3088
@cindex complex numbers, conversion to
3089
@cindex conversion, to complex
3090
 
3091
@table @asis
3092
@item @emph{Description}:
3093
@code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3094
converted to the real component.  If @var{Y} is present it is converted to the
3095
imaginary component.  If @var{Y} is not present then the imaginary component is
3096
set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
3097
 
3098
@item @emph{Standard}:
3099
GNU extension
3100
 
3101
@item @emph{Class}:
3102
Elemental function
3103
 
3104
@item @emph{Syntax}:
3105
@code{RESULT = DCMPLX(X [, Y])}
3106
 
3107
@item @emph{Arguments}:
3108
@multitable @columnfractions .15 .70
3109
@item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3110
or @code{COMPLEX}.
3111
@item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
3112
@code{INTEGER} or @code{REAL}.
3113
@end multitable
3114
 
3115
@item @emph{Return value}:
3116
The return value is of type @code{COMPLEX(8)}
3117
 
3118
@item @emph{Example}:
3119
@smallexample
3120
program test_dcmplx
3121
    integer :: i = 42
3122
    real :: x = 3.14
3123
    complex :: z
3124
    z = cmplx(i, x)
3125
    print *, dcmplx(i)
3126
    print *, dcmplx(x)
3127
    print *, dcmplx(z)
3128
    print *, dcmplx(x,i)
3129
end program test_dcmplx
3130
@end smallexample
3131
@end table
3132
 
3133
 
3134
 
3135
@node DFLOAT
3136
@section @code{DFLOAT} --- Double conversion function
3137
@fnindex DFLOAT
3138
@cindex conversion, to real
3139
 
3140
@table @asis
3141
@item @emph{Description}:
3142
@code{DFLOAT(A)} Converts @var{A} to double precision real type.
3143
 
3144
@item @emph{Standard}:
3145
GNU extension
3146
 
3147
@item @emph{Class}:
3148
Elemental function
3149
 
3150
@item @emph{Syntax}:
3151
@code{RESULT = DFLOAT(A)}
3152
 
3153
@item @emph{Arguments}:
3154
@multitable @columnfractions .15 .70
3155
@item @var{A} @tab The type shall be @code{INTEGER}.
3156
@end multitable
3157
 
3158
@item @emph{Return value}:
3159
The return value is of type double precision real.
3160
 
3161
@item @emph{Example}:
3162
@smallexample
3163
program test_dfloat
3164
    integer :: i = 5
3165
    print *, dfloat(i)
3166
end program test_dfloat
3167
@end smallexample
3168
 
3169
@item @emph{See also}:
3170
@ref{DBLE}, @ref{FLOAT}, @ref{REAL}
3171
@end table
3172
 
3173
 
3174
 
3175
@node DIGITS
3176
@section @code{DIGITS} --- Significant binary digits function
3177
@fnindex DIGITS
3178
@cindex model representation, significant digits
3179
 
3180
@table @asis
3181
@item @emph{Description}:
3182
@code{DIGITS(X)} returns the number of significant binary digits of the internal
3183
model representation of @var{X}.  For example, on a system using a 32-bit
3184
floating point representation, a default real number would likely return 24.
3185
 
3186
@item @emph{Standard}:
3187
Fortran 95 and later
3188
 
3189
@item @emph{Class}:
3190
Inquiry function
3191
 
3192
@item @emph{Syntax}:
3193
@code{RESULT = DIGITS(X)}
3194
 
3195
@item @emph{Arguments}:
3196
@multitable @columnfractions .15 .70
3197
@item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
3198
@end multitable
3199
 
3200
@item @emph{Return value}:
3201
The return value is of type @code{INTEGER}.
3202
 
3203
@item @emph{Example}:
3204
@smallexample
3205
program test_digits
3206
    integer :: i = 12345
3207
    real :: x = 3.143
3208
    real(8) :: y = 2.33
3209
    print *, digits(i)
3210
    print *, digits(x)
3211
    print *, digits(y)
3212
end program test_digits
3213
@end smallexample
3214
@end table
3215
 
3216
 
3217
 
3218
@node DIM
3219
@section @code{DIM} --- Positive difference
3220
@fnindex DIM
3221
@fnindex IDIM
3222
@fnindex DDIM
3223
@cindex positive difference
3224
 
3225
@table @asis
3226
@item @emph{Description}:
3227
@code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3228
otherwise returns zero.
3229
 
3230
@item @emph{Standard}:
3231
Fortran 77 and later
3232
 
3233
@item @emph{Class}:
3234
Elemental function
3235
 
3236
@item @emph{Syntax}:
3237
@code{RESULT = DIM(X, Y)}
3238
 
3239
@item @emph{Arguments}:
3240
@multitable @columnfractions .15 .70
3241
@item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
3242
@item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3243
@end multitable
3244
 
3245
@item @emph{Return value}:
3246
The return value is of type @code{INTEGER} or @code{REAL}.
3247
 
3248
@item @emph{Example}:
3249
@smallexample
3250
program test_dim
3251
    integer :: i
3252
    real(8) :: x
3253
    i = dim(4, 15)
3254
    x = dim(4.345_8, 2.111_8)
3255
    print *, i
3256
    print *, x
3257
end program test_dim
3258
@end smallexample
3259
 
3260
@item @emph{Specific names}:
3261
@multitable @columnfractions .20 .20 .20 .25
3262
@item Name             @tab Argument              @tab Return type       @tab Standard
3263
@item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
3264
@item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y}    @tab @code{REAL(8)}    @tab Fortran 77 and later
3265
@end multitable
3266
@end table
3267
 
3268
 
3269
 
3270
@node DOT_PRODUCT
3271
@section @code{DOT_PRODUCT} --- Dot product function
3272
@fnindex DOT_PRODUCT
3273
@cindex dot product
3274
@cindex vector product
3275
@cindex product, vector
3276
 
3277
@table @asis
3278
@item @emph{Description}:
3279
@code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
3280
of two vectors @var{VECTOR_A} and @var{VECTOR_B}.  The two vectors may be
3281
either numeric or logical and must be arrays of rank one and of equal size. If
3282
the vectors are @code{INTEGER} or @code{REAL}, the result is
3283
@code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
3284
is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
3285
the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.
3286
 
3287
@item @emph{Standard}:
3288
Fortran 95 and later
3289
 
3290
@item @emph{Class}:
3291
Transformational function
3292
 
3293
@item @emph{Syntax}:
3294
@code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
3295
 
3296
@item @emph{Arguments}:
3297
@multitable @columnfractions .15 .70
3298
@item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3299
@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.
3300
@end multitable
3301
 
3302
@item @emph{Return value}:
3303
If the arguments are numeric, the return value is a scalar of numeric type,
3304
@code{INTEGER}, @code{REAL}, or @code{COMPLEX}.  If the arguments are
3305
@code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3306
 
3307
@item @emph{Example}:
3308
@smallexample
3309
program test_dot_prod
3310
    integer, dimension(3) :: a, b
3311
    a = (/ 1, 2, 3 /)
3312
    b = (/ 4, 5, 6 /)
3313
    print '(3i3)', a
3314
    print *
3315
    print '(3i3)', b
3316
    print *
3317
    print *, dot_product(a,b)
3318
end program test_dot_prod
3319
@end smallexample
3320
@end table
3321
 
3322
 
3323
 
3324
@node DPROD
3325
@section @code{DPROD} --- Double product function
3326
@fnindex DPROD
3327
@cindex product, double-precision
3328
 
3329
@table @asis
3330
@item @emph{Description}:
3331
@code{DPROD(X,Y)} returns the product @code{X*Y}.
3332
 
3333
@item @emph{Standard}:
3334
Fortran 77 and later
3335
 
3336
@item @emph{Class}:
3337
Elemental function
3338
 
3339
@item @emph{Syntax}:
3340
@code{RESULT = DPROD(X, Y)}
3341
 
3342
@item @emph{Arguments}:
3343
@multitable @columnfractions .15 .70
3344
@item @var{X} @tab The type shall be @code{REAL}.
3345
@item @var{Y} @tab The type shall be @code{REAL}.
3346
@end multitable
3347
 
3348
@item @emph{Return value}:
3349
The return value is of type @code{REAL(8)}.
3350
 
3351
@item @emph{Example}:
3352
@smallexample
3353
program test_dprod
3354
    real :: x = 5.2
3355
    real :: y = 2.3
3356
    real(8) :: d
3357
    d = dprod(x,y)
3358
    print *, d
3359
end program test_dprod
3360
@end smallexample
3361
@end table
3362
 
3363
 
3364
 
3365
@node DREAL
3366
@section @code{DREAL} --- Double real part function
3367
@fnindex DREAL
3368
@cindex complex numbers, real part
3369
 
3370
@table @asis
3371
@item @emph{Description}:
3372
@code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3373
 
3374
@item @emph{Standard}:
3375
GNU extension
3376
 
3377
@item @emph{Class}:
3378
Elemental function
3379
 
3380
@item @emph{Syntax}:
3381
@code{RESULT = DREAL(A)}
3382
 
3383
@item @emph{Arguments}:
3384
@multitable @columnfractions .15 .70
3385
@item @var{A} @tab The type shall be @code{COMPLEX(8)}.
3386
@end multitable
3387
 
3388
@item @emph{Return value}:
3389
The return value is of type @code{REAL(8)}.
3390
 
3391
@item @emph{Example}:
3392
@smallexample
3393
program test_dreal
3394
    complex(8) :: z = (1.3_8,7.2_8)
3395
    print *, dreal(z)
3396
end program test_dreal
3397
@end smallexample
3398
 
3399
@item @emph{See also}:
3400
@ref{AIMAG}
3401
 
3402
@end table
3403
 
3404
 
3405
 
3406
@node DTIME
3407
@section @code{DTIME} --- Execution time subroutine (or function)
3408
@fnindex DTIME
3409
@cindex time, elapsed
3410
@cindex elapsed time
3411
 
3412
@table @asis
3413
@item @emph{Description}:
3414
@code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
3415
since the start of the process's execution in @var{TIME}.  @var{VALUES}
3416
returns the user and system components of this time in @code{VALUES(1)} and
3417
@code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
3418
VALUES(2)}.
3419
 
3420
Subsequent invocations of @code{DTIME} return values accumulated since the
3421
previous invocation.
3422
 
3423
On some systems, the underlying timings are represented using types with
3424
sufficiently small limits that overflows (wrap around) are possible, such as
3425
32-bit types. Therefore, the values returned by this intrinsic might be, or
3426
become, negative, or numerically less than previous values, during a single
3427
run of the compiled program.
3428
 
3429
Please note, that this implementation is thread safe if used within OpenMP
3430
directives, i.e., its state will be consistent while called from multiple
3431
threads. However, if @code{DTIME} is called from multiple threads, the result
3432
is still the time since the last invocation. This may not give the intended
3433
results. If possible, use @code{CPU_TIME} instead.
3434
 
3435
This intrinsic is provided in both subroutine and function forms; however,
3436
only one form can be used in any given program unit.
3437
 
3438
@var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
3439
 
3440
@multitable @columnfractions .15 .30 .40
3441
@item @tab @code{VALUES(1)}: @tab User time in seconds.
3442
@item @tab @code{VALUES(2)}: @tab System time in seconds.
3443
@item @tab @code{TIME}: @tab Run time since start in seconds.
3444
@end multitable
3445
 
3446
@item @emph{Standard}:
3447
GNU extension
3448
 
3449
@item @emph{Class}:
3450
Subroutine, function
3451
 
3452
@item @emph{Syntax}:
3453
@multitable @columnfractions .80
3454
@item @code{CALL DTIME(VALUES, TIME)}.
3455
@item @code{TIME = DTIME(VALUES)}, (not recommended).
3456
@end multitable
3457
 
3458
@item @emph{Arguments}:
3459
@multitable @columnfractions .15 .70
3460
@item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3461
@item @var{TIME}@tab The type shall be @code{REAL(4)}.
3462
@end multitable
3463
 
3464
@item @emph{Return value}:
3465
Elapsed time in seconds since the last invocation or since the start of program
3466
execution if not called before.
3467
 
3468
@item @emph{Example}:
3469
@smallexample
3470
program test_dtime
3471
    integer(8) :: i, j
3472
    real, dimension(2) :: tarray
3473
    real :: result
3474
    call dtime(tarray, result)
3475
    print *, result
3476
    print *, tarray(1)
3477
    print *, tarray(2)
3478
    do i=1,100000000    ! Just a delay
3479
        j = i * i - i
3480
    end do
3481
    call dtime(tarray, result)
3482
    print *, result
3483
    print *, tarray(1)
3484
    print *, tarray(2)
3485
end program test_dtime
3486
@end smallexample
3487
 
3488
@item @emph{See also}:
3489
@ref{CPU_TIME}
3490
 
3491
@end table
3492
 
3493
 
3494
 
3495
@node EOSHIFT
3496
@section @code{EOSHIFT} --- End-off shift elements of an array
3497
@fnindex EOSHIFT
3498
@cindex array, shift
3499
 
3500
@table @asis
3501
@item @emph{Description}:
3502
@code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
3503
elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
3504
omitted it is taken to be @code{1}.  @var{DIM} is a scalar of type
3505
@code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
3506
rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
3507
@var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
3508
then all complete rank one sections of @var{ARRAY} along the given dimension are
3509
shifted.  Elements shifted out one end of each rank one section are dropped.  If
3510
@var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3511
is copied back in the other end.  If @var{BOUNDARY} is not present then the
3512
following are copied in depending on the type of @var{ARRAY}.
3513
 
3514
@multitable @columnfractions .15 .80
3515
@item @emph{Array Type} @tab @emph{Boundary Value}
3516
@item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
3517
@item Logical  @tab @code{.FALSE.}.
3518
@item Character(@var{len}) @tab @var{len} blanks.
3519
@end multitable
3520
 
3521
@item @emph{Standard}:
3522
Fortran 95 and later
3523
 
3524
@item @emph{Class}:
3525
Transformational function
3526
 
3527
@item @emph{Syntax}:
3528
@code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3529
 
3530
@item @emph{Arguments}:
3531
@multitable @columnfractions .15 .70
3532
@item @var{ARRAY}  @tab May be any type, not scalar.
3533
@item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
3534
@item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
3535
@item @var{DIM}    @tab The type shall be @code{INTEGER}.
3536
@end multitable
3537
 
3538
@item @emph{Return value}:
3539
Returns an array of same type and rank as the @var{ARRAY} argument.
3540
 
3541
@item @emph{Example}:
3542
@smallexample
3543
program test_eoshift
3544
    integer, dimension(3,3) :: a
3545
    a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3546
    print '(3i3)', a(1,:)
3547
    print '(3i3)', a(2,:)
3548
    print '(3i3)', a(3,:)
3549
    a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3550
    print *
3551
    print '(3i3)', a(1,:)
3552
    print '(3i3)', a(2,:)
3553
    print '(3i3)', a(3,:)
3554
end program test_eoshift
3555
@end smallexample
3556
@end table
3557
 
3558
 
3559
 
3560
@node EPSILON
3561
@section @code{EPSILON} --- Epsilon function
3562
@fnindex EPSILON
3563
@cindex model representation, epsilon
3564
 
3565
@table @asis
3566
@item @emph{Description}:
3567
@code{EPSILON(X)} returns the smallest number @var{E} of the same kind
3568
as @var{X} such that @math{1 + E > 1}.
3569
 
3570
@item @emph{Standard}:
3571
Fortran 95 and later
3572
 
3573
@item @emph{Class}:
3574
Inquiry function
3575
 
3576
@item @emph{Syntax}:
3577
@code{RESULT = EPSILON(X)}
3578
 
3579
@item @emph{Arguments}:
3580
@multitable @columnfractions .15 .70
3581
@item @var{X} @tab The type shall be @code{REAL}.
3582
@end multitable
3583
 
3584
@item @emph{Return value}:
3585
The return value is of same type as the argument.
3586
 
3587
@item @emph{Example}:
3588
@smallexample
3589
program test_epsilon
3590
    real :: x = 3.143
3591
    real(8) :: y = 2.33
3592
    print *, EPSILON(x)
3593
    print *, EPSILON(y)
3594
end program test_epsilon
3595
@end smallexample
3596
@end table
3597
 
3598
 
3599
 
3600
@node ERF
3601
@section @code{ERF} --- Error function
3602
@fnindex ERF
3603
@cindex error function
3604
 
3605
@table @asis
3606
@item @emph{Description}:
3607
@code{ERF(X)} computes the error function of @var{X}.
3608
 
3609
@item @emph{Standard}:
3610
Fortran 2008 and later
3611
 
3612
@item @emph{Class}:
3613
Elemental function
3614
 
3615
@item @emph{Syntax}:
3616
@code{RESULT = ERF(X)}
3617
 
3618
@item @emph{Arguments}:
3619
@multitable @columnfractions .15 .70
3620
@item @var{X} @tab The type shall be @code{REAL}.
3621
@end multitable
3622
 
3623
@item @emph{Return value}:
3624
The return value is of type @code{REAL}, of the same kind as
3625
@var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
3626
 
3627
@item @emph{Example}:
3628
@smallexample
3629
program test_erf
3630
  real(8) :: x = 0.17_8
3631
  x = erf(x)
3632
end program test_erf
3633
@end smallexample
3634
 
3635
@item @emph{Specific names}:
3636
@multitable @columnfractions .20 .20 .20 .25
3637
@item Name            @tab Argument          @tab Return type       @tab Standard
3638
@item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3639
@end multitable
3640
@end table
3641
 
3642
 
3643
 
3644
@node ERFC
3645
@section @code{ERFC} --- Error function
3646
@fnindex ERFC
3647
@cindex error function, complementary
3648
 
3649
@table @asis
3650
@item @emph{Description}:
3651
@code{ERFC(X)} computes the complementary error function of @var{X}.
3652
 
3653
@item @emph{Standard}:
3654
Fortran 2008 and later
3655
 
3656
@item @emph{Class}:
3657
Elemental function
3658
 
3659
@item @emph{Syntax}:
3660
@code{RESULT = ERFC(X)}
3661
 
3662
@item @emph{Arguments}:
3663
@multitable @columnfractions .15 .70
3664
@item @var{X} @tab The type shall be @code{REAL}.
3665
@end multitable
3666
 
3667
@item @emph{Return value}:
3668
The return value is of type @code{REAL} and of the same kind as @var{X}.
3669
It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
3670
 
3671
@item @emph{Example}:
3672
@smallexample
3673
program test_erfc
3674
  real(8) :: x = 0.17_8
3675
  x = erfc(x)
3676
end program test_erfc
3677
@end smallexample
3678
 
3679
@item @emph{Specific names}:
3680
@multitable @columnfractions .20 .20 .20 .25
3681
@item Name            @tab Argument          @tab Return type       @tab Standard
3682
@item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3683
@end multitable
3684
@end table
3685
 
3686
 
3687
 
3688
@node ERFC_SCALED
3689
@section @code{ERFC_SCALED} --- Error function
3690
@fnindex ERFC_SCALED
3691
@cindex error function, complementary, exponentially-scaled
3692
 
3693
@table @asis
3694
@item @emph{Description}:
3695
@code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
3696
error function of @var{X}.
3697
 
3698
@item @emph{Standard}:
3699
Fortran 2008 and later
3700
 
3701
@item @emph{Class}:
3702
Elemental function
3703
 
3704
@item @emph{Syntax}:
3705
@code{RESULT = ERFC_SCALED(X)}
3706
 
3707
@item @emph{Arguments}:
3708
@multitable @columnfractions .15 .70
3709
@item @var{X} @tab The type shall be @code{REAL}.
3710
@end multitable
3711
 
3712
@item @emph{Return value}:
3713
The return value is of type @code{REAL} and of the same kind as @var{X}.
3714
 
3715
@item @emph{Example}:
3716
@smallexample
3717
program test_erfc_scaled
3718
  real(8) :: x = 0.17_8
3719
  x = erfc_scaled(x)
3720
end program test_erfc_scaled
3721
@end smallexample
3722
@end table
3723
 
3724
 
3725
 
3726
@node ETIME
3727
@section @code{ETIME} --- Execution time subroutine (or function)
3728
@fnindex ETIME
3729
@cindex time, elapsed
3730
 
3731
@table @asis
3732
@item @emph{Description}:
3733
@code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
3734
since the start of the process's execution in @var{TIME}.  @var{VALUES}
3735
returns the user and system components of this time in @code{VALUES(1)} and
3736
@code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
3737
 
3738
On some systems, the underlying timings are represented using types with
3739
sufficiently small limits that overflows (wrap around) are possible, such as
3740
32-bit types. Therefore, the values returned by this intrinsic might be, or
3741
become, negative, or numerically less than previous values, during a single
3742
run of the compiled program.
3743
 
3744
This intrinsic is provided in both subroutine and function forms; however,
3745
only one form can be used in any given program unit.
3746
 
3747
@var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
3748
 
3749
@multitable @columnfractions .15 .30 .60
3750
@item @tab @code{VALUES(1)}: @tab User time in seconds.
3751
@item @tab @code{VALUES(2)}: @tab System time in seconds.
3752
@item @tab @code{TIME}: @tab Run time since start in seconds.
3753
@end multitable
3754
 
3755
@item @emph{Standard}:
3756
GNU extension
3757
 
3758
@item @emph{Class}:
3759
Subroutine, function
3760
 
3761
@item @emph{Syntax}:
3762
@multitable @columnfractions .80
3763
@item @code{CALL ETIME(VALUES, TIME)}.
3764
@item @code{TIME = ETIME(VALUES)}, (not recommended).
3765
@end multitable
3766
 
3767
@item @emph{Arguments}:
3768
@multitable @columnfractions .15 .70
3769
@item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3770
@item @var{TIME}@tab The type shall be @code{REAL(4)}.
3771
@end multitable
3772
 
3773
@item @emph{Return value}:
3774
Elapsed time in seconds since the start of program execution.
3775
 
3776
@item @emph{Example}:
3777
@smallexample
3778
program test_etime
3779
    integer(8) :: i, j
3780
    real, dimension(2) :: tarray
3781
    real :: result
3782
    call ETIME(tarray, result)
3783
    print *, result
3784
    print *, tarray(1)
3785
    print *, tarray(2)
3786
    do i=1,100000000    ! Just a delay
3787
        j = i * i - i
3788
    end do
3789
    call ETIME(tarray, result)
3790
    print *, result
3791
    print *, tarray(1)
3792
    print *, tarray(2)
3793
end program test_etime
3794
@end smallexample
3795
 
3796
@item @emph{See also}:
3797
@ref{CPU_TIME}
3798
 
3799
@end table
3800
 
3801
 
3802
 
3803
@node EXIT
3804
@section @code{EXIT} --- Exit the program with status.
3805
@fnindex EXIT
3806
@cindex program termination
3807
@cindex terminate program
3808
 
3809
@table @asis
3810
@item @emph{Description}:
3811
@code{EXIT} causes immediate termination of the program with status.  If status
3812
is omitted it returns the canonical @emph{success} for the system.  All Fortran
3813
I/O units are closed.
3814
 
3815
@item @emph{Standard}:
3816
GNU extension
3817
 
3818
@item @emph{Class}:
3819
Subroutine
3820
 
3821
@item @emph{Syntax}:
3822
@code{CALL EXIT([STATUS])}
3823
 
3824
@item @emph{Arguments}:
3825
@multitable @columnfractions .15 .70
3826
@item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3827
@end multitable
3828
 
3829
@item @emph{Return value}:
3830
@code{STATUS} is passed to the parent process on exit.
3831
 
3832
@item @emph{Example}:
3833
@smallexample
3834
program test_exit
3835
  integer :: STATUS = 0
3836
  print *, 'This program is going to exit.'
3837
  call EXIT(STATUS)
3838
end program test_exit
3839
@end smallexample
3840
 
3841
@item @emph{See also}:
3842
@ref{ABORT}, @ref{KILL}
3843
@end table
3844
 
3845
 
3846
 
3847
@node EXP
3848
@section @code{EXP} --- Exponential function
3849
@fnindex EXP
3850
@fnindex DEXP
3851
@fnindex CEXP
3852
@fnindex ZEXP
3853
@fnindex CDEXP
3854
@cindex exponential function
3855
@cindex logarithmic function, inverse
3856
 
3857
@table @asis
3858
@item @emph{Description}:
3859
@code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3860
 
3861
@item @emph{Standard}:
3862
Fortran 77 and later, has overloads that are GNU extensions
3863
 
3864
@item @emph{Class}:
3865
Elemental function
3866
 
3867
@item @emph{Syntax}:
3868
@code{RESULT = EXP(X)}
3869
 
3870
@item @emph{Arguments}:
3871
@multitable @columnfractions .15 .70
3872
@item @var{X} @tab The type shall be @code{REAL} or
3873
@code{COMPLEX}.
3874
@end multitable
3875
 
3876
@item @emph{Return value}:
3877
The return value has same type and kind as @var{X}.
3878
 
3879
@item @emph{Example}:
3880
@smallexample
3881
program test_exp
3882
  real :: x = 1.0
3883
  x = exp(x)
3884
end program test_exp
3885
@end smallexample
3886
 
3887
@item @emph{Specific names}:
3888
@multitable @columnfractions .20 .20 .20 .25
3889
@item Name            @tab Argument             @tab Return type         @tab Standard
3890
@item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab Fortran 77 and later
3891
@item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab Fortran 77 and later
3892
@item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3893
@item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3894
@end multitable
3895
@end table
3896
 
3897
 
3898
 
3899
@node EXPONENT
3900
@section @code{EXPONENT} --- Exponent function
3901
@fnindex EXPONENT
3902
@cindex real number, exponent
3903
@cindex floating point, exponent
3904
 
3905
@table @asis
3906
@item @emph{Description}:
3907
@code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3908
is zero the value returned is zero.
3909
 
3910
@item @emph{Standard}:
3911
Fortran 95 and later
3912
 
3913
@item @emph{Class}:
3914
Elemental function
3915
 
3916
@item @emph{Syntax}:
3917
@code{RESULT = EXPONENT(X)}
3918
 
3919
@item @emph{Arguments}:
3920
@multitable @columnfractions .15 .70
3921
@item @var{X} @tab The type shall be @code{REAL}.
3922
@end multitable
3923
 
3924
@item @emph{Return value}:
3925
The return value is of type default @code{INTEGER}.
3926
 
3927
@item @emph{Example}:
3928
@smallexample
3929
program test_exponent
3930
  real :: x = 1.0
3931
  integer :: i
3932
  i = exponent(x)
3933
  print *, i
3934
  print *, exponent(0.0)
3935
end program test_exponent
3936
@end smallexample
3937
@end table
3938
 
3939
 
3940
 
3941
@node FDATE
3942
@section @code{FDATE} --- Get the current time as a string
3943
@fnindex FDATE
3944
@cindex time, current
3945
@cindex current time
3946
@cindex date, current
3947
@cindex current date
3948
 
3949
@table @asis
3950
@item @emph{Description}:
3951
@code{FDATE(DATE)} returns the current date (using the same format as
3952
@code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3953
TIME())}.
3954
 
3955
This intrinsic is provided in both subroutine and function forms; however,
3956
only one form can be used in any given program unit.
3957
 
3958
@var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable of the
3959
default kind.
3960
 
3961
@item @emph{Standard}:
3962
GNU extension
3963
 
3964
@item @emph{Class}:
3965
Subroutine, function
3966
 
3967
@item @emph{Syntax}:
3968
@multitable @columnfractions .80
3969
@item @code{CALL FDATE(DATE)}.
3970
@item @code{DATE = FDATE()}, (not recommended).
3971
@end multitable
3972
 
3973
@item @emph{Arguments}:
3974
@multitable @columnfractions .15 .70
3975
@item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
3976
default kind
3977
@end multitable
3978
 
3979
@item @emph{Return value}:
3980
The current date as a string.
3981
 
3982
@item @emph{Example}:
3983
@smallexample
3984
program test_fdate
3985
    integer(8) :: i, j
3986
    character(len=30) :: date
3987
    call fdate(date)
3988
    print *, 'Program started on ', date
3989
    do i = 1, 100000000 ! Just a delay
3990
        j = i * i - i
3991
    end do
3992
    call fdate(date)
3993
    print *, 'Program ended on ', date
3994
end program test_fdate
3995
@end smallexample
3996
@end table
3997
 
3998
 
3999
 
4000
@node FLOAT
4001
@section @code{FLOAT} --- Convert integer to default real
4002
@fnindex FLOAT
4003
@cindex conversion, to real
4004
 
4005
@table @asis
4006
@item @emph{Description}:
4007
@code{FLOAT(A)} converts the integer @var{A} to a default real value.
4008
 
4009
@item @emph{Standard}:
4010
Fortran 77 and later
4011
 
4012
@item @emph{Class}:
4013
Elemental function
4014
 
4015
@item @emph{Syntax}:
4016
@code{RESULT = FLOAT(A)}
4017
 
4018
@item @emph{Arguments}:
4019
@multitable @columnfractions .15 .70
4020
@item @var{A} @tab The type shall be @code{INTEGER}.
4021
@end multitable
4022
 
4023
@item @emph{Return value}:
4024
The return value is of type default @code{REAL}.
4025
 
4026
@item @emph{Example}:
4027
@smallexample
4028
program test_float
4029
    integer :: i = 1
4030
    if (float(i) /= 1.) call abort
4031
end program test_float
4032
@end smallexample
4033
 
4034
@item @emph{See also}:
4035
@ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
4036
@end table
4037
 
4038
 
4039
 
4040
@node FGET
4041
@section @code{FGET} --- Read a single character in stream mode from stdin
4042
@fnindex FGET
4043
@cindex read character, stream mode
4044
@cindex stream mode, read character
4045
@cindex file operation, read character
4046
 
4047
@table @asis
4048
@item @emph{Description}:
4049
Read a single character in stream mode from stdin by bypassing normal
4050
formatted output. Stream I/O should not be mixed with normal record-oriented
4051
(formatted or unformatted) I/O on the same unit; the results are unpredictable.
4052
 
4053
This intrinsic is provided in both subroutine and function forms; however,
4054
only one form can be used in any given program unit.
4055
 
4056
Note that the @code{FGET} intrinsic is provided for backwards compatibility with
4057
@command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4058
Programmers should consider the use of new stream IO feature in new code
4059
for future portability. See also @ref{Fortran 2003 status}.
4060
 
4061
@item @emph{Standard}:
4062
GNU extension
4063
 
4064
@item @emph{Class}:
4065
Subroutine, function
4066
 
4067
@item @emph{Syntax}:
4068
@code{CALL FGET(C [, STATUS])}
4069
 
4070
@item @emph{Arguments}:
4071
@multitable @columnfractions .15 .70
4072
@item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4073
kind.
4074
@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4075
Returns 0 on success, -1 on end-of-file, and a system specific positive
4076
error code otherwise.
4077
@end multitable
4078
 
4079
@item @emph{Example}:
4080
@smallexample
4081
PROGRAM test_fget
4082
  INTEGER, PARAMETER :: strlen = 100
4083
  INTEGER :: status, i = 1
4084
  CHARACTER(len=strlen) :: str = ""
4085
 
4086
  WRITE (*,*) 'Enter text:'
4087
  DO
4088
    CALL fget(str(i:i), status)
4089
    if (status /= 0 .OR. i > strlen) exit
4090
    i = i + 1
4091
  END DO
4092
  WRITE (*,*) TRIM(str)
4093
END PROGRAM
4094
@end smallexample
4095
 
4096
@item @emph{See also}:
4097
@ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
4098
@end table
4099
 
4100
 
4101
 
4102
@node FGETC
4103
@section @code{FGETC} --- Read a single character in stream mode
4104
@fnindex FGETC
4105
@cindex read character, stream mode
4106
@cindex stream mode, read character
4107
@cindex file operation, read character
4108
 
4109
@table @asis
4110
@item @emph{Description}:
4111
Read a single character in stream mode by bypassing normal formatted output.
4112
Stream I/O should not be mixed with normal record-oriented (formatted or
4113
unformatted) I/O on the same unit; the results are unpredictable.
4114
 
4115
This intrinsic is provided in both subroutine and function forms; however,
4116
only one form can be used in any given program unit.
4117
 
4118
Note that the @code{FGET} intrinsic is provided for backwards compatibility
4119
with @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4120
Programmers should consider the use of new stream IO feature in new code
4121
for future portability. See also @ref{Fortran 2003 status}.
4122
 
4123
@item @emph{Standard}:
4124
GNU extension
4125
 
4126
@item @emph{Class}:
4127
Subroutine, function
4128
 
4129
@item @emph{Syntax}:
4130
@code{CALL FGETC(UNIT, C [, STATUS])}
4131
 
4132
@item @emph{Arguments}:
4133
@multitable @columnfractions .15 .70
4134
@item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4135
@item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4136
kind.
4137
@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4138
Returns 0 on success, -1 on end-of-file and a system specific positive
4139
error code otherwise.
4140
@end multitable
4141
 
4142
@item @emph{Example}:
4143
@smallexample
4144
PROGRAM test_fgetc
4145
  INTEGER :: fd = 42, status
4146
  CHARACTER :: c
4147
 
4148
  OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4149
  DO
4150
    CALL fgetc(fd, c, status)
4151
    IF (status /= 0) EXIT
4152
    call fput(c)
4153
  END DO
4154
  CLOSE(UNIT=fd)
4155
END PROGRAM
4156
@end smallexample
4157
 
4158
@item @emph{See also}:
4159
@ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4160
@end table
4161
 
4162
 
4163
 
4164
@node FLOOR
4165
@section @code{FLOOR} --- Integer floor function
4166
@fnindex FLOOR
4167
@cindex floor
4168
@cindex rounding, floor
4169
 
4170
@table @asis
4171
@item @emph{Description}:
4172
@code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
4173
 
4174
@item @emph{Standard}:
4175
Fortran 95 and later
4176
 
4177
@item @emph{Class}:
4178
Elemental function
4179
 
4180
@item @emph{Syntax}:
4181
@code{RESULT = FLOOR(A [, KIND])}
4182
 
4183
@item @emph{Arguments}:
4184
@multitable @columnfractions .15 .70
4185
@item @var{A} @tab The type shall be @code{REAL}.
4186
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4187
expression indicating the kind parameter of the result.
4188
@end multitable
4189
 
4190
@item @emph{Return value}:
4191
The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4192
and of default-kind @code{INTEGER} otherwise.
4193
 
4194
@item @emph{Example}:
4195
@smallexample
4196
program test_floor
4197
    real :: x = 63.29
4198
    real :: y = -63.59
4199
    print *, floor(x) ! returns 63
4200
    print *, floor(y) ! returns -64
4201
end program test_floor
4202
@end smallexample
4203
 
4204
@item @emph{See also}:
4205
@ref{CEILING}, @ref{NINT}
4206
 
4207
@end table
4208
 
4209
 
4210
 
4211
@node FLUSH
4212
@section @code{FLUSH} --- Flush I/O unit(s)
4213
@fnindex FLUSH
4214
@cindex file operation, flush
4215
 
4216
@table @asis
4217
@item @emph{Description}:
4218
Flushes Fortran unit(s) currently open for output. Without the optional
4219
argument, all units are flushed, otherwise just the unit specified.
4220
 
4221
@item @emph{Standard}:
4222
GNU extension
4223
 
4224
@item @emph{Class}:
4225
Subroutine
4226
 
4227
@item @emph{Syntax}:
4228
@code{CALL FLUSH(UNIT)}
4229
 
4230
@item @emph{Arguments}:
4231
@multitable @columnfractions .15 .70
4232
@item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4233
@end multitable
4234
 
4235
@item @emph{Note}:
4236
Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4237
statement that should be preferred over the @code{FLUSH} intrinsic.
4238
 
4239
@end table
4240
 
4241
 
4242
 
4243
@node FNUM
4244
@section @code{FNUM} --- File number function
4245
@fnindex FNUM
4246
@cindex file operation, file number
4247
 
4248
@table @asis
4249
@item @emph{Description}:
4250
@code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4251
open Fortran I/O unit @code{UNIT}.
4252
 
4253
@item @emph{Standard}:
4254
GNU extension
4255
 
4256
@item @emph{Class}:
4257
Function
4258
 
4259
@item @emph{Syntax}:
4260
@code{RESULT = FNUM(UNIT)}
4261
 
4262
@item @emph{Arguments}:
4263
@multitable @columnfractions .15 .70
4264
@item @var{UNIT} @tab The type shall be @code{INTEGER}.
4265
@end multitable
4266
 
4267
@item @emph{Return value}:
4268
The return value is of type @code{INTEGER}
4269
 
4270
@item @emph{Example}:
4271
@smallexample
4272
program test_fnum
4273
  integer :: i
4274
  open (unit=10, status = "scratch")
4275
  i = fnum(10)
4276
  print *, i
4277
  close (10)
4278
end program test_fnum
4279
@end smallexample
4280
@end table
4281
 
4282
 
4283
 
4284
@node FPUT
4285
@section @code{FPUT} --- Write a single character in stream mode to stdout
4286
@fnindex FPUT
4287
@cindex write character, stream mode
4288
@cindex stream mode, write character
4289
@cindex file operation, write character
4290
 
4291
@table @asis
4292
@item @emph{Description}:
4293
Write a single character in stream mode to stdout by bypassing normal
4294
formatted output. Stream I/O should not be mixed with normal record-oriented
4295
(formatted or unformatted) I/O on the same unit; the results are unpredictable.
4296
 
4297
This intrinsic is provided in both subroutine and function forms; however,
4298
only one form can be used in any given program unit.
4299
 
4300
Note that the @code{FGET} intrinsic is provided for backwards compatibility with
4301
@command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4302
Programmers should consider the use of new stream IO feature in new code
4303
for future portability. See also @ref{Fortran 2003 status}.
4304
 
4305
@item @emph{Standard}:
4306
GNU extension
4307
 
4308
@item @emph{Class}:
4309
Subroutine, function
4310
 
4311
@item @emph{Syntax}:
4312
@code{CALL FPUT(C [, STATUS])}
4313
 
4314
@item @emph{Arguments}:
4315
@multitable @columnfractions .15 .70
4316
@item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4317
kind.
4318
@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4319
Returns 0 on success, -1 on end-of-file and a system specific positive
4320
error code otherwise.
4321
@end multitable
4322
 
4323
@item @emph{Example}:
4324
@smallexample
4325
PROGRAM test_fput
4326
  CHARACTER(len=10) :: str = "gfortran"
4327
  INTEGER :: i
4328
  DO i = 1, len_trim(str)
4329
    CALL fput(str(i:i))
4330
  END DO
4331
END PROGRAM
4332
@end smallexample
4333
 
4334
@item @emph{See also}:
4335
@ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4336
@end table
4337
 
4338
 
4339
 
4340
@node FPUTC
4341
@section @code{FPUTC} --- Write a single character in stream mode
4342
@fnindex FPUTC
4343
@cindex write character, stream mode
4344
@cindex stream mode, write character
4345
@cindex file operation, write character
4346
 
4347
@table @asis
4348
@item @emph{Description}:
4349
Write a single character in stream mode by bypassing normal formatted
4350
output. Stream I/O should not be mixed with normal record-oriented
4351
(formatted or unformatted) I/O on the same unit; the results are unpredictable.
4352
 
4353
This intrinsic is provided in both subroutine and function forms; however,
4354
only one form can be used in any given program unit.
4355
 
4356
Note that the @code{FGET} intrinsic is provided for backwards compatibility with
4357
@command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4358
Programmers should consider the use of new stream IO feature in new code
4359
for future portability. See also @ref{Fortran 2003 status}.
4360
 
4361
@item @emph{Standard}:
4362
GNU extension
4363
 
4364
@item @emph{Class}:
4365
Subroutine, function
4366
 
4367
@item @emph{Syntax}:
4368
@code{CALL FPUTC(UNIT, C [, STATUS])}
4369
 
4370
@item @emph{Arguments}:
4371
@multitable @columnfractions .15 .70
4372
@item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4373
@item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4374
kind.
4375
@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4376
Returns 0 on success, -1 on end-of-file and a system specific positive
4377
error code otherwise.
4378
@end multitable
4379
 
4380
@item @emph{Example}:
4381
@smallexample
4382
PROGRAM test_fputc
4383
  CHARACTER(len=10) :: str = "gfortran"
4384
  INTEGER :: fd = 42, i
4385
 
4386
  OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
4387
  DO i = 1, len_trim(str)
4388
    CALL fputc(fd, str(i:i))
4389
  END DO
4390
  CLOSE(fd)
4391
END PROGRAM
4392
@end smallexample
4393
 
4394
@item @emph{See also}:
4395
@ref{FPUT}, @ref{FGET}, @ref{FGETC}
4396
@end table
4397
 
4398
 
4399
 
4400
@node FRACTION
4401
@section @code{FRACTION} --- Fractional part of the model representation
4402
@fnindex FRACTION
4403
@cindex real number, fraction
4404
@cindex floating point, fraction
4405
 
4406
@table @asis
4407
@item @emph{Description}:
4408
@code{FRACTION(X)} returns the fractional part of the model
4409
representation of @code{X}.
4410
 
4411
@item @emph{Standard}:
4412
Fortran 95 and later
4413
 
4414
@item @emph{Class}:
4415
Elemental function
4416
 
4417
@item @emph{Syntax}:
4418
@code{Y = FRACTION(X)}
4419
 
4420
@item @emph{Arguments}:
4421
@multitable @columnfractions .15 .70
4422
@item @var{X} @tab The type of the argument shall be a @code{REAL}.
4423
@end multitable
4424
 
4425
@item @emph{Return value}:
4426
The return value is of the same type and kind as the argument.
4427
The fractional part of the model representation of @code{X} is returned;
4428
it is @code{X * RADIX(X)**(-EXPONENT(X))}.
4429
 
4430
@item @emph{Example}:
4431
@smallexample
4432
program test_fraction
4433
  real :: x
4434
  x = 178.1387e-4
4435
  print *, fraction(x), x * radix(x)**(-exponent(x))
4436
end program test_fraction
4437
@end smallexample
4438
 
4439
@end table
4440
 
4441
 
4442
 
4443
@node FREE
4444
@section @code{FREE} --- Frees memory
4445
@fnindex FREE
4446
@cindex pointer, cray
4447
 
4448
@table @asis
4449
@item @emph{Description}:
4450
Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
4451
intrinsic is an extension intended to be used with Cray pointers, and is
4452
provided in GNU Fortran to allow user to compile legacy code. For
4453
new code using Fortran 95 pointers, the memory de-allocation intrinsic is
4454
@code{DEALLOCATE}.
4455
 
4456
@item @emph{Standard}:
4457
GNU extension
4458
 
4459
@item @emph{Class}:
4460
Subroutine
4461
 
4462
@item @emph{Syntax}:
4463
@code{CALL FREE(PTR)}
4464
 
4465
@item @emph{Arguments}:
4466
@multitable @columnfractions .15 .70
4467
@item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4468
location of the memory that should be de-allocated.
4469
@end multitable
4470
 
4471
@item @emph{Return value}:
4472
None
4473
 
4474
@item @emph{Example}:
4475
See @code{MALLOC} for an example.
4476
 
4477
@item @emph{See also}:
4478
@ref{MALLOC}
4479
@end table
4480
 
4481
 
4482
 
4483
@node FSEEK
4484
@section @code{FSEEK} --- Low level file positioning subroutine
4485
@fnindex FSEEK
4486
@cindex file operation, seek
4487
@cindex file operation, position
4488
 
4489
@table @asis
4490
@item @emph{Description}:
4491
Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
4492
is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4493
if set to 1, @var{OFFSET} is taken to be relative to the current position
4494
@code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4495
On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
4496
fails silently.
4497
 
4498
This intrinsic routine is not fully backwards compatible with @command{g77}.
4499
In @command{g77}, the @code{FSEEK} takes a statement label instead of a
4500
@var{STATUS} variable. If FSEEK is used in old code, change
4501
@smallexample
4502
  CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4503
@end smallexample
4504
to
4505
@smallexample
4506
  INTEGER :: status
4507
  CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4508
  IF (status /= 0) GOTO label
4509
@end smallexample
4510
 
4511
Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4512
Programmers should consider the use of new stream IO feature in new code
4513
for future portability. See also @ref{Fortran 2003 status}.
4514
 
4515
@item @emph{Standard}:
4516
GNU extension
4517
 
4518
@item @emph{Class}:
4519
Subroutine
4520
 
4521
@item @emph{Syntax}:
4522
@code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4523
 
4524
@item @emph{Arguments}:
4525
@multitable @columnfractions .15 .70
4526
@item @var{UNIT}   @tab Shall be a scalar of type @code{INTEGER}.
4527
@item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4528
@item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4529
Its value shall be either 0, 1 or 2.
4530
@item @var{STATUS} @tab (Optional) shall be a scalar of type
4531
@code{INTEGER(4)}.
4532
@end multitable
4533
 
4534
@item @emph{Example}:
4535
@smallexample
4536
PROGRAM test_fseek
4537
  INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
4538
  INTEGER :: fd, offset, ierr
4539
 
4540
  ierr   = 0
4541
  offset = 5
4542
  fd     = 10
4543
 
4544
  OPEN(UNIT=fd, FILE="fseek.test")
4545
  CALL FSEEK(fd, offset, SEEK_SET, ierr)  ! move to OFFSET
4546
  print *, FTELL(fd), ierr
4547
 
4548
  CALL FSEEK(fd, 0, SEEK_END, ierr)       ! move to end
4549
  print *, FTELL(fd), ierr
4550
 
4551
  CALL FSEEK(fd, 0, SEEK_SET, ierr)       ! move to beginning
4552
  print *, FTELL(fd), ierr
4553
 
4554
  CLOSE(UNIT=fd)
4555
END PROGRAM
4556
@end smallexample
4557
 
4558
@item @emph{See also}:
4559
@ref{FTELL}
4560
@end table
4561
 
4562
 
4563
 
4564
@node FSTAT
4565
@section @code{FSTAT} --- Get file status
4566
@fnindex FSTAT
4567
@cindex file system, file status
4568
 
4569
@table @asis
4570
@item @emph{Description}:
4571
@code{FSTAT} is identical to @ref{STAT}, except that information about an
4572
already opened file is obtained.
4573
 
4574
The elements in @code{VALUES} are the same as described by @ref{STAT}.
4575
 
4576
This intrinsic is provided in both subroutine and function forms; however,
4577
only one form can be used in any given program unit.
4578
 
4579
@item @emph{Standard}:
4580
GNU extension
4581
 
4582
@item @emph{Class}:
4583
Subroutine, function
4584
 
4585
@item @emph{Syntax}:
4586
@code{CALL FSTAT(UNIT, VALUES [, STATUS])}
4587
 
4588
@item @emph{Arguments}:
4589
@multitable @columnfractions .15 .70
4590
@item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
4591
@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4592
@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
4593
on success and a system specific error code otherwise.
4594
@end multitable
4595
 
4596
@item @emph{Example}:
4597
See @ref{STAT} for an example.
4598
 
4599
@item @emph{See also}:
4600
To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4601
@end table
4602
 
4603
 
4604
 
4605
@node FTELL
4606
@section @code{FTELL} --- Current stream position
4607
@fnindex FTELL
4608
@cindex file operation, position
4609
 
4610
@table @asis
4611
@item @emph{Description}:
4612
Retrieves the current position within an open file.
4613
 
4614
This intrinsic is provided in both subroutine and function forms; however,
4615
only one form can be used in any given program unit.
4616
 
4617
@item @emph{Standard}:
4618
GNU extension
4619
 
4620
@item @emph{Class}:
4621
Subroutine, function
4622
 
4623
@item @emph{Syntax}:
4624
@multitable @columnfractions .80
4625
@item @code{CALL FTELL(UNIT, OFFSET)}
4626
@item @code{OFFSET = FTELL(UNIT)}
4627
@end multitable
4628
 
4629
@item @emph{Arguments}:
4630
@multitable @columnfractions .15 .70
4631
@item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
4632
@item @var{UNIT}    @tab Shall of type @code{INTEGER}.
4633
@end multitable
4634
 
4635
@item @emph{Return value}:
4636
In either syntax, @var{OFFSET} is set to the current offset of unit
4637
number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4638
 
4639
@item @emph{Example}:
4640
@smallexample
4641
PROGRAM test_ftell
4642
  INTEGER :: i
4643
  OPEN(10, FILE="temp.dat")
4644
  CALL ftell(10,i)
4645
  WRITE(*,*) i
4646
END PROGRAM
4647
@end smallexample
4648
 
4649
@item @emph{See also}:
4650
@ref{FSEEK}
4651
@end table
4652
 
4653
 
4654
 
4655
@node GAMMA
4656
@section @code{GAMMA} --- Gamma function
4657
@fnindex GAMMA
4658
@fnindex DGAMMA
4659
@cindex Gamma function
4660
@cindex Factorial function
4661
 
4662
@table @asis
4663
@item @emph{Description}:
4664
@code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
4665
integer values of @var{X} the Gamma function simplifies to the factorial
4666
function @math{\Gamma(x)=(x-1)!}.
4667
 
4668
@tex
4669
$$
4670
\Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
4671
$$
4672
@end tex
4673
 
4674
@item @emph{Standard}:
4675
Fortran 2008 and later
4676
 
4677
@item @emph{Class}:
4678
Elemental function
4679
 
4680
@item @emph{Syntax}:
4681
@code{X = GAMMA(X)}
4682
 
4683
@item @emph{Arguments}:
4684
@multitable @columnfractions .15 .70
4685
@item @var{X} @tab Shall be of type @code{REAL} and neither zero
4686
nor a negative integer.
4687
@end multitable
4688
 
4689
@item @emph{Return value}:
4690
The return value is of type @code{REAL} of the same kind as @var{X}.
4691
 
4692
@item @emph{Example}:
4693
@smallexample
4694
program test_gamma
4695
  real :: x = 1.0
4696
  x = gamma(x) ! returns 1.0
4697
end program test_gamma
4698
@end smallexample
4699
 
4700
@item @emph{Specific names}:
4701
@multitable @columnfractions .20 .20 .20 .25
4702
@item Name             @tab Argument         @tab Return type       @tab Standard
4703
@item @code{GAMMA(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
4704
@item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
4705
@end multitable
4706
 
4707
@item @emph{See also}:
4708
Logarithm of the Gamma function: @ref{LOG_GAMMA}
4709
 
4710
@end table
4711
 
4712
 
4713
 
4714
@node GERROR
4715
@section @code{GERROR} --- Get last system error message
4716
@fnindex GERROR
4717
@cindex system, error handling
4718
 
4719
@table @asis
4720
@item @emph{Description}:
4721
Returns the system error message corresponding to the last system error.
4722
This resembles the functionality of @code{strerror(3)} in C.
4723
 
4724
@item @emph{Standard}:
4725
GNU extension
4726
 
4727
@item @emph{Class}:
4728
Subroutine
4729
 
4730
@item @emph{Syntax}:
4731
@code{CALL GERROR(RESULT)}
4732
 
4733
@item @emph{Arguments}:
4734
@multitable @columnfractions .15 .70
4735
@item @var{RESULT}  @tab Shall of type @code{CHARACTER} and of default
4736
@end multitable
4737
 
4738
@item @emph{Example}:
4739
@smallexample
4740
PROGRAM test_gerror
4741
  CHARACTER(len=100) :: msg
4742
  CALL gerror(msg)
4743
  WRITE(*,*) msg
4744
END PROGRAM
4745
@end smallexample
4746
 
4747
@item @emph{See also}:
4748
@ref{IERRNO}, @ref{PERROR}
4749
@end table
4750
 
4751
 
4752
 
4753
@node GETARG
4754
@section @code{GETARG} --- Get command line arguments
4755
@fnindex GETARG
4756
@cindex command-line arguments
4757
@cindex arguments, to program
4758
 
4759
@table @asis
4760
@item @emph{Description}:
4761
Retrieve the @var{POS}-th argument that was passed on the
4762
command line when the containing program was invoked.
4763
 
4764
This intrinsic routine is provided for backwards compatibility with
4765
GNU Fortran 77.  In new code, programmers should consider the use of
4766
the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
4767
standard.
4768
 
4769
@item @emph{Standard}:
4770
GNU extension
4771
 
4772
@item @emph{Class}:
4773
Subroutine
4774
 
4775
@item @emph{Syntax}:
4776
@code{CALL GETARG(POS, VALUE)}
4777
 
4778
@item @emph{Arguments}:
4779
@multitable @columnfractions .15 .70
4780
@item @var{POS}   @tab Shall be of type @code{INTEGER} and not wider than
4781
the default integer kind; @math{@var{POS} \geq 0}
4782
@item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
4783
kind.
4784
@item @var{VALUE} @tab Shall be of type @code{CHARACTER}.
4785
@end multitable
4786
 
4787
@item @emph{Return value}:
4788
After @code{GETARG} returns, the @var{VALUE} argument holds the
4789
@var{POS}th command line argument. If @var{VALUE} can not hold the
4790
argument, it is truncated to fit the length of @var{VALUE}. If there are
4791
less than @var{POS} arguments specified at the command line, @var{VALUE}
4792
will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
4793
to the name of the program (on systems that support this feature).
4794
 
4795
@item @emph{Example}:
4796
@smallexample
4797
PROGRAM test_getarg
4798
  INTEGER :: i
4799
  CHARACTER(len=32) :: arg
4800
 
4801
  DO i = 1, iargc()
4802
    CALL getarg(i, arg)
4803
    WRITE (*,*) arg
4804
  END DO
4805
END PROGRAM
4806
@end smallexample
4807
 
4808
@item @emph{See also}:
4809
GNU Fortran 77 compatibility function: @ref{IARGC}
4810
 
4811
Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
4812
@ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4813
@end table
4814
 
4815
 
4816
 
4817
@node GET_COMMAND
4818
@section @code{GET_COMMAND} --- Get the entire command line
4819
@fnindex GET_COMMAND
4820
@cindex command-line arguments
4821
@cindex arguments, to program
4822
 
4823
@table @asis
4824
@item @emph{Description}:
4825
Retrieve the entire command line that was used to invoke the program.
4826
 
4827
@item @emph{Standard}:
4828
Fortran 2003 and later
4829
 
4830
@item @emph{Class}:
4831
Subroutine
4832
 
4833
@item @emph{Syntax}:
4834
@code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
4835
 
4836
@item @emph{Arguments}:
4837
@multitable @columnfractions .15 .70
4838
@item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
4839
of default kind.
4840
@item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
4841
default kind.
4842
@item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
4843
default kind.
4844
@end multitable
4845
 
4846
@item @emph{Return value}:
4847
If @var{COMMAND} is present, stores the entire command line that was used
4848
to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
4849
assigned the length of the command line. If @var{STATUS} is present, it
4850
is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
4851
short to store the command line, or a positive value in case of an error.
4852
 
4853
@item @emph{Example}:
4854
@smallexample
4855
PROGRAM test_get_command
4856
  CHARACTER(len=255) :: cmd
4857
  CALL get_command(cmd)
4858
  WRITE (*,*) TRIM(cmd)
4859
END PROGRAM
4860
@end smallexample
4861
 
4862
@item @emph{See also}:
4863
@ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4864
@end table
4865
 
4866
 
4867
 
4868
@node GET_COMMAND_ARGUMENT
4869
@section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4870
@fnindex GET_COMMAND_ARGUMENT
4871
@cindex command-line arguments
4872
@cindex arguments, to program
4873
 
4874
@table @asis
4875
@item @emph{Description}:
4876
Retrieve the @var{NUMBER}-th argument that was passed on the
4877
command line when the containing program was invoked.
4878
 
4879
@item @emph{Standard}:
4880
Fortran 2003 and later
4881
 
4882
@item @emph{Class}:
4883
Subroutine
4884
 
4885
@item @emph{Syntax}:
4886
@code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
4887
 
4888
@item @emph{Arguments}:
4889
@multitable @columnfractions .15 .70
4890
@item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
4891
default kind, @math{@var{NUMBER} \geq 0}
4892
@item @var{VALUE}  @tab Shall be a scalar of type @code{CHARACTER}
4893
and of default kind.
4894
@item @var{LENGTH} @tab (Option) Shall be a scalar of type @code{INTEGER}
4895
and of default kind.
4896
@item @var{STATUS} @tab (Option) Shall be a scalar of type @code{INTEGER}
4897
and of default kind.
4898
@end multitable
4899
 
4900
@item @emph{Return value}:
4901
After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the
4902
@var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is
4903
truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
4904
arguments specified at the command line, @var{VALUE} will be filled with blanks.
4905
If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
4906
systems that support this feature). The @var{LENGTH} argument contains the
4907
length of the @var{NUMBER}-th command line argument. If the argument retrieval
4908
fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
4909
command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
4910
zero.
4911
 
4912
@item @emph{Example}:
4913
@smallexample
4914
PROGRAM test_get_command_argument
4915
  INTEGER :: i
4916
  CHARACTER(len=32) :: arg
4917
 
4918
  i = 0
4919
  DO
4920
    CALL get_command_argument(i, arg)
4921
    IF (LEN_TRIM(arg) == 0) EXIT
4922
 
4923
    WRITE (*,*) TRIM(arg)
4924
    i = i+1
4925
  END DO
4926
END PROGRAM
4927
@end smallexample
4928
 
4929
@item @emph{See also}:
4930
@ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4931
@end table
4932
 
4933
 
4934
 
4935
@node GETCWD
4936
@section @code{GETCWD} --- Get current working directory
4937
@fnindex GETCWD
4938
@cindex system, working directory
4939
 
4940
@table @asis
4941
@item @emph{Description}:
4942
Get current working directory.
4943
 
4944
This intrinsic is provided in both subroutine and function forms; however,
4945
only one form can be used in any given program unit.
4946
 
4947
@item @emph{Standard}:
4948
GNU extension
4949
 
4950
@item @emph{Class}:
4951
Subroutine, function
4952
 
4953
@item @emph{Syntax}:
4954
@code{CALL GETCWD(C [, STATUS])}
4955
 
4956
@item @emph{Arguments}:
4957
@multitable @columnfractions .15 .70
4958
@item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
4959
@item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4960
a system specific and nonzero error code otherwise.
4961
@end multitable
4962
 
4963
@item @emph{Example}:
4964
@smallexample
4965
PROGRAM test_getcwd
4966
  CHARACTER(len=255) :: cwd
4967
  CALL getcwd(cwd)
4968
  WRITE(*,*) TRIM(cwd)
4969
END PROGRAM
4970
@end smallexample
4971
 
4972
@item @emph{See also}:
4973
@ref{CHDIR}
4974
@end table
4975
 
4976
 
4977
 
4978
@node GETENV
4979
@section @code{GETENV} --- Get an environmental variable
4980
@fnindex GETENV
4981
@cindex environment variable
4982
 
4983
@table @asis
4984
@item @emph{Description}:
4985
Get the @var{VALUE} of the environmental variable @var{NAME}.
4986
 
4987
This intrinsic routine is provided for backwards compatibility with
4988
GNU Fortran 77.  In new code, programmers should consider the use of
4989
the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4990
2003 standard.
4991
 
4992
@item @emph{Standard}:
4993
GNU extension
4994
 
4995
@item @emph{Class}:
4996
Subroutine
4997
 
4998
@item @emph{Syntax}:
4999
@code{CALL GETENV(NAME, VALUE)}
5000
 
5001
@item @emph{Arguments}:
5002
@multitable @columnfractions .15 .70
5003
@item @var{NAME}  @tab Shall be of type @code{CHARACTER} and of default kind.
5004
@item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
5005
@end multitable
5006
 
5007
@item @emph{Return value}:
5008
Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
5009
not large enough to hold the data, it is truncated. If @var{NAME}
5010
is not set, @var{VALUE} will be filled with blanks.
5011
 
5012
@item @emph{Example}:
5013
@smallexample
5014
PROGRAM test_getenv
5015
  CHARACTER(len=255) :: homedir
5016
  CALL getenv("HOME", homedir)
5017
  WRITE (*,*) TRIM(homedir)
5018
END PROGRAM
5019
@end smallexample
5020
 
5021
@item @emph{See also}:
5022
@ref{GET_ENVIRONMENT_VARIABLE}
5023
@end table
5024
 
5025
 
5026
 
5027
@node GET_ENVIRONMENT_VARIABLE
5028
@section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
5029
@fnindex GET_ENVIRONMENT_VARIABLE
5030
@cindex environment variable
5031
 
5032
@table @asis
5033
@item @emph{Description}:
5034
Get the @var{VALUE} of the environmental variable @var{NAME}.
5035
 
5036
@item @emph{Standard}:
5037
Fortran 2003 and later
5038
 
5039
@item @emph{Class}:
5040
Subroutine
5041
 
5042
@item @emph{Syntax}:
5043
@code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
5044
 
5045
@item @emph{Arguments}:
5046
@multitable @columnfractions .15 .70
5047
@item @var{NAME}      @tab Shall be a scalar of type @code{CHARACTER}
5048
and of default kind.
5049
@item @var{VALUE}     @tab Shall be a scalar of type @code{CHARACTER}
5050
and of default kind.
5051
@item @var{LENGTH}    @tab Shall be a scalar of type @code{INTEGER}
5052
and of default kind.
5053
@item @var{STATUS}    @tab Shall be a scalar of type @code{INTEGER}
5054
and of default kind.
5055
@item @var{TRIM_NAME} @tab Shall be a scalar of type @code{LOGICAL}
5056
and of default kind.
5057
@end multitable
5058
 
5059
@item @emph{Return value}:
5060
Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
5061
not large enough to hold the data, it is truncated. If @var{NAME}
5062
is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5063
contains the length needed for storing the environment variable @var{NAME}
5064
or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5065
but too short for the environment variable; it is 1 if the environment
5066
variable does not exist and 2 if the processor does not support environment
5067
variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5068
present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5069
are significant; otherwise they are not part of the environment variable
5070
name.
5071
 
5072
@item @emph{Example}:
5073
@smallexample
5074
PROGRAM test_getenv
5075
  CHARACTER(len=255) :: homedir
5076
  CALL get_environment_variable("HOME", homedir)
5077
  WRITE (*,*) TRIM(homedir)
5078
END PROGRAM
5079
@end smallexample
5080
@end table
5081
 
5082
 
5083
 
5084
@node GETGID
5085
@section @code{GETGID} --- Group ID function
5086
@fnindex GETGID
5087
@cindex system, group id
5088
 
5089
@table @asis
5090
@item @emph{Description}:
5091
Returns the numerical group ID of the current process.
5092
 
5093
@item @emph{Standard}:
5094
GNU extension
5095
 
5096
@item @emph{Class}:
5097
Function
5098
 
5099
@item @emph{Syntax}:
5100
@code{RESULT = GETGID()}
5101
 
5102
@item @emph{Return value}:
5103
The return value of @code{GETGID} is an @code{INTEGER} of the default
5104
kind.
5105
 
5106
 
5107
@item @emph{Example}:
5108
See @code{GETPID} for an example.
5109
 
5110
@item @emph{See also}:
5111
@ref{GETPID}, @ref{GETUID}
5112
@end table
5113
 
5114
 
5115
 
5116
@node GETLOG
5117
@section @code{GETLOG} --- Get login name
5118
@fnindex GETLOG
5119
@cindex system, login name
5120
@cindex login name
5121
 
5122
@table @asis
5123
@item @emph{Description}:
5124
Gets the username under which the program is running.
5125
 
5126
@item @emph{Standard}:
5127
GNU extension
5128
 
5129
@item @emph{Class}:
5130
Subroutine
5131
 
5132
@item @emph{Syntax}:
5133
@code{CALL GETLOG(C)}
5134
 
5135
@item @emph{Arguments}:
5136
@multitable @columnfractions .15 .70
5137
@item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
5138
@end multitable
5139
 
5140
@item @emph{Return value}:
5141
Stores the current user name in @var{LOGIN}.  (On systems where POSIX
5142
functions @code{geteuid} and @code{getpwuid} are not available, and
5143
the @code{getlogin} function is not implemented either, this will
5144
return a blank string.)
5145
 
5146
@item @emph{Example}:
5147
@smallexample
5148
PROGRAM TEST_GETLOG
5149
  CHARACTER(32) :: login
5150
  CALL GETLOG(login)
5151
  WRITE(*,*) login
5152
END PROGRAM
5153
@end smallexample
5154
 
5155
@item @emph{See also}:
5156
@ref{GETUID}
5157
@end table
5158
 
5159
 
5160
 
5161
@node GETPID
5162
@section @code{GETPID} --- Process ID function
5163
@fnindex GETPID
5164
@cindex system, process id
5165
@cindex process id
5166
 
5167
@table @asis
5168
@item @emph{Description}:
5169
Returns the numerical process identifier of the current process.
5170
 
5171
@item @emph{Standard}:
5172
GNU extension
5173
 
5174
@item @emph{Class}:
5175
Function
5176
 
5177
@item @emph{Syntax}:
5178
@code{RESULT = GETPID()}
5179
 
5180
@item @emph{Return value}:
5181
The return value of @code{GETPID} is an @code{INTEGER} of the default
5182
kind.
5183
 
5184
 
5185
@item @emph{Example}:
5186
@smallexample
5187
program info
5188
  print *, "The current process ID is ", getpid()
5189
  print *, "Your numerical user ID is ", getuid()
5190
  print *, "Your numerical group ID is ", getgid()
5191
end program info
5192
@end smallexample
5193
 
5194
@item @emph{See also}:
5195
@ref{GETGID}, @ref{GETUID}
5196
@end table
5197
 
5198
 
5199
 
5200
@node GETUID
5201
@section @code{GETUID} --- User ID function
5202
@fnindex GETUID
5203
@cindex system, user id
5204
@cindex user id
5205
 
5206
@table @asis
5207
@item @emph{Description}:
5208
Returns the numerical user ID of the current process.
5209
 
5210
@item @emph{Standard}:
5211
GNU extension
5212
 
5213
@item @emph{Class}:
5214
Function
5215
 
5216
@item @emph{Syntax}:
5217
@code{RESULT = GETUID()}
5218
 
5219
@item @emph{Return value}:
5220
The return value of @code{GETUID} is an @code{INTEGER} of the default
5221
kind.
5222
 
5223
 
5224
@item @emph{Example}:
5225
See @code{GETPID} for an example.
5226
 
5227
@item @emph{See also}:
5228
@ref{GETPID}, @ref{GETLOG}
5229
@end table
5230
 
5231
 
5232
 
5233
@node GMTIME
5234
@section @code{GMTIME} --- Convert time to GMT info
5235
@fnindex GMTIME
5236
@cindex time, conversion to GMT info
5237
 
5238
@table @asis
5239
@item @emph{Description}:
5240
Given a system time value @var{TIME} (as provided by the @code{TIME8()}
5241
intrinsic), fills @var{VALUES} with values extracted from it appropriate
5242
to the UTC time zone (Universal Coordinated Time, also known in some
5243
countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5244
 
5245
@item @emph{Standard}:
5246
GNU extension
5247
 
5248
@item @emph{Class}:
5249
Subroutine
5250
 
5251
@item @emph{Syntax}:
5252
@code{CALL GMTIME(TIME, VALUES)}
5253
 
5254
@item @emph{Arguments}:
5255
@multitable @columnfractions .15 .70
5256
@item @var{TIME}   @tab An @code{INTEGER} scalar expression
5257
corresponding to a system time, with @code{INTENT(IN)}.
5258
@item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
5259
with @code{INTENT(OUT)}.
5260
@end multitable
5261
 
5262
@item @emph{Return value}:
5263
The elements of @var{VALUES} are assigned as follows:
5264
@enumerate
5265
@item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5266
seconds
5267
@item Minutes after the hour, range 0--59
5268
@item Hours past midnight, range 0--23
5269
@item Day of month, range 0--31
5270
@item Number of months since January, range 0--12
5271
@item Years since 1900
5272
@item Number of days since Sunday, range 0--6
5273
@item Days since January 1
5274
@item Daylight savings indicator: positive if daylight savings is in
5275
effect, zero if not, and negative if the information is not available.
5276
@end enumerate
5277
 
5278
@item @emph{See also}:
5279
@ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5280
 
5281
@end table
5282
 
5283
 
5284
 
5285
@node HOSTNM
5286
@section @code{HOSTNM} --- Get system host name
5287
@fnindex HOSTNM
5288
@cindex system, host name
5289
 
5290
@table @asis
5291
@item @emph{Description}:
5292
Retrieves the host name of the system on which the program is running.
5293
 
5294
This intrinsic is provided in both subroutine and function forms; however,
5295
only one form can be used in any given program unit.
5296
 
5297
@item @emph{Standard}:
5298
GNU extension
5299
 
5300
@item @emph{Class}:
5301
Subroutine, function
5302
 
5303
@item @emph{Syntax}:
5304
@multitable @columnfractions .80
5305
@item @code{CALL HOSTNM(C [, STATUS])}
5306
@item @code{STATUS = HOSTNM(NAME)}
5307
@end multitable
5308
 
5309
@item @emph{Arguments}:
5310
@multitable @columnfractions .15 .70
5311
@item @var{C}    @tab Shall of type @code{CHARACTER} and of default kind.
5312
@item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
5313
Returns 0 on success, or a system specific error code otherwise.
5314
@end multitable
5315
 
5316
@item @emph{Return value}:
5317
In either syntax, @var{NAME} is set to the current hostname if it can
5318
be obtained, or to a blank string otherwise.
5319
 
5320
@end table
5321
 
5322
 
5323
 
5324
@node HUGE
5325
@section @code{HUGE} --- Largest number of a kind
5326
@fnindex HUGE
5327
@cindex limits, largest number
5328
@cindex model representation, largest number
5329
 
5330
@table @asis
5331
@item @emph{Description}:
5332
@code{HUGE(X)} returns the largest number that is not an infinity in
5333
the model of the type of @code{X}.
5334
 
5335
@item @emph{Standard}:
5336
Fortran 95 and later
5337
 
5338
@item @emph{Class}:
5339
Inquiry function
5340
 
5341
@item @emph{Syntax}:
5342
@code{RESULT = HUGE(X)}
5343
 
5344
@item @emph{Arguments}:
5345
@multitable @columnfractions .15 .70
5346
@item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5347
@end multitable
5348
 
5349
@item @emph{Return value}:
5350
The return value is of the same type and kind as @var{X}
5351
 
5352
@item @emph{Example}:
5353
@smallexample
5354
program test_huge_tiny
5355
  print *, huge(0), huge(0.0), huge(0.0d0)
5356
  print *, tiny(0.0), tiny(0.0d0)
5357
end program test_huge_tiny
5358
@end smallexample
5359
@end table
5360
 
5361
 
5362
 
5363
@node HYPOT
5364
@section @code{HYPOT} --- Euclidean distance function
5365
@fnindex HYPOT
5366
@cindex Euclidean distance
5367
 
5368
@table @asis
5369
@item @emph{Description}:
5370
@code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
5371
@math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
5372
 
5373
@item @emph{Standard}:
5374
Fortran 2008 and later
5375
 
5376
@item @emph{Class}:
5377
Elemental function
5378
 
5379
@item @emph{Syntax}:
5380
@code{RESULT = HYPOT(X, Y)}
5381
 
5382
@item @emph{Arguments}:
5383
@multitable @columnfractions .15 .70
5384
@item @var{X} @tab The type shall be @code{REAL}.
5385
@item @var{Y} @tab The type and kind type parameter shall be the same as
5386
@var{X}.
5387
@end multitable
5388
 
5389
@item @emph{Return value}:
5390
The return value has the same type and kind type parameter as @var{X}.
5391
 
5392
@item @emph{Example}:
5393
@smallexample
5394
program test_hypot
5395
  real(4) :: x = 1.e0_4, y = 0.5e0_4
5396
  x = hypot(x,y)
5397
end program test_hypot
5398
@end smallexample
5399
@end table
5400
 
5401
 
5402
 
5403
@node IACHAR
5404
@section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
5405
@fnindex IACHAR
5406
@cindex @acronym{ASCII} collating sequence
5407
@cindex collating sequence, @acronym{ASCII}
5408
@cindex conversion, to integer
5409
 
5410
@table @asis
5411
@item @emph{Description}:
5412
@code{IACHAR(C)} returns the code for the @acronym{ASCII} character
5413
in the first character position of @code{C}.
5414
 
5415
@item @emph{Standard}:
5416
Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
5417
 
5418
@item @emph{Class}:
5419
Elemental function
5420
 
5421
@item @emph{Syntax}:
5422
@code{RESULT = IACHAR(C [, KIND])}
5423
 
5424
@item @emph{Arguments}:
5425
@multitable @columnfractions .15 .70
5426
@item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5427
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5428
expression indicating the kind parameter of the result.
5429
@end multitable
5430
 
5431
@item @emph{Return value}:
5432
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5433
@var{KIND} is absent, the return value is of default integer kind.
5434
 
5435
@item @emph{Example}:
5436
@smallexample
5437
program test_iachar
5438
  integer i
5439
  i = iachar(' ')
5440
end program test_iachar
5441
@end smallexample
5442
 
5443
@item @emph{Note}:
5444
See @ref{ICHAR} for a discussion of converting between numerical values
5445
and formatted string representations.
5446
 
5447
@item @emph{See also}:
5448
@ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
5449
 
5450
@end table
5451
 
5452
 
5453
 
5454
@node IAND
5455
@section @code{IAND} --- Bitwise logical and
5456
@fnindex IAND
5457
@cindex bitwise logical and
5458
@cindex logical and, bitwise
5459
 
5460
@table @asis
5461
@item @emph{Description}:
5462
Bitwise logical @code{AND}.
5463
 
5464
@item @emph{Standard}:
5465
Fortran 95 and later
5466
 
5467
@item @emph{Class}:
5468
Elemental function
5469
 
5470
@item @emph{Syntax}:
5471
@code{RESULT = IAND(I, J)}
5472
 
5473
@item @emph{Arguments}:
5474
@multitable @columnfractions .15 .70
5475
@item @var{I} @tab The type shall be @code{INTEGER}.
5476
@item @var{J} @tab The type shall be @code{INTEGER}, of the same
5477
kind as @var{I}.  (As a GNU extension, different kinds are also
5478
permitted.)
5479
@end multitable
5480
 
5481
@item @emph{Return value}:
5482
The return type is @code{INTEGER}, of the same kind as the
5483
arguments.  (If the argument kinds differ, it is of the same kind as
5484
the larger argument.)
5485
 
5486
@item @emph{Example}:
5487
@smallexample
5488
PROGRAM test_iand
5489
  INTEGER :: a, b
5490
  DATA a / Z'F' /, b / Z'3' /
5491
  WRITE (*,*) IAND(a, b)
5492
END PROGRAM
5493
@end smallexample
5494
 
5495
@item @emph{See also}:
5496
@ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5497
 
5498
@end table
5499
 
5500
 
5501
 
5502
@node IARGC
5503
@section @code{IARGC} --- Get the number of command line arguments
5504
@fnindex IARGC
5505
@cindex command-line arguments
5506
@cindex command-line arguments, number of
5507
@cindex arguments, to program
5508
 
5509
@table @asis
5510
@item @emph{Description}:
5511
@code{IARGC()} returns the number of arguments passed on the
5512
command line when the containing program was invoked.
5513
 
5514
This intrinsic routine is provided for backwards compatibility with
5515
GNU Fortran 77.  In new code, programmers should consider the use of
5516
the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
5517
standard.
5518
 
5519
@item @emph{Standard}:
5520
GNU extension
5521
 
5522
@item @emph{Class}:
5523
Function
5524
 
5525
@item @emph{Syntax}:
5526
@code{RESULT = IARGC()}
5527
 
5528
@item @emph{Arguments}:
5529
None.
5530
 
5531
@item @emph{Return value}:
5532
The number of command line arguments, type @code{INTEGER(4)}.
5533
 
5534
@item @emph{Example}:
5535
See @ref{GETARG}
5536
 
5537
@item @emph{See also}:
5538
GNU Fortran 77 compatibility subroutine: @ref{GETARG}
5539
 
5540
Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5541
@ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5542
@end table
5543
 
5544
 
5545
 
5546
@node IBCLR
5547
@section @code{IBCLR} --- Clear bit
5548
@fnindex IBCLR
5549
@cindex bits, unset
5550
@cindex bits, clear
5551
 
5552
@table @asis
5553
@item @emph{Description}:
5554
@code{IBCLR} returns the value of @var{I} with the bit at position
5555
@var{POS} set to zero.
5556
 
5557
@item @emph{Standard}:
5558
Fortran 95 and later
5559
 
5560
@item @emph{Class}:
5561
Elemental function
5562
 
5563
@item @emph{Syntax}:
5564
@code{RESULT = IBCLR(I, POS)}
5565
 
5566
@item @emph{Arguments}:
5567
@multitable @columnfractions .15 .70
5568
@item @var{I} @tab The type shall be @code{INTEGER}.
5569
@item @var{POS} @tab The type shall be @code{INTEGER}.
5570
@end multitable
5571
 
5572
@item @emph{Return value}:
5573
The return value is of type @code{INTEGER} and of the same kind as
5574
@var{I}.
5575
 
5576
@item @emph{See also}:
5577
@ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5578
 
5579
@end table
5580
 
5581
 
5582
 
5583
@node IBITS
5584
@section @code{IBITS} --- Bit extraction
5585
@fnindex IBITS
5586
@cindex bits, get
5587
@cindex bits, extract
5588
 
5589
@table @asis
5590
@item @emph{Description}:
5591
@code{IBITS} extracts a field of length @var{LEN} from @var{I},
5592
starting from bit position @var{POS} and extending left for @var{LEN}
5593
bits.  The result is right-justified and the remaining bits are
5594
zeroed.  The value of @code{POS+LEN} must be less than or equal to the
5595
value @code{BIT_SIZE(I)}.
5596
 
5597
@item @emph{Standard}:
5598
Fortran 95 and later
5599
 
5600
@item @emph{Class}:
5601
Elemental function
5602
 
5603
@item @emph{Syntax}:
5604
@code{RESULT = IBITS(I, POS, LEN)}
5605
 
5606
@item @emph{Arguments}:
5607
@multitable @columnfractions .15 .70
5608
@item @var{I}   @tab The type shall be @code{INTEGER}.
5609
@item @var{POS} @tab The type shall be @code{INTEGER}.
5610
@item @var{LEN} @tab The type shall be @code{INTEGER}.
5611
@end multitable
5612
 
5613
@item @emph{Return value}:
5614
The return value is of type @code{INTEGER} and of the same kind as
5615
@var{I}.
5616
 
5617
@item @emph{See also}:
5618
@ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
5619
@end table
5620
 
5621
 
5622
 
5623
@node IBSET
5624
@section @code{IBSET} --- Set bit
5625
@fnindex IBSET
5626
@cindex bits, set
5627
 
5628
@table @asis
5629
@item @emph{Description}:
5630
@code{IBSET} returns the value of @var{I} with the bit at position
5631
@var{POS} set to one.
5632
 
5633
@item @emph{Standard}:
5634
Fortran 95 and later
5635
 
5636
@item @emph{Class}:
5637
Elemental function
5638
 
5639
@item @emph{Syntax}:
5640
@code{RESULT = IBSET(I, POS)}
5641
 
5642
@item @emph{Arguments}:
5643
@multitable @columnfractions .15 .70
5644
@item @var{I} @tab The type shall be @code{INTEGER}.
5645
@item @var{POS} @tab The type shall be @code{INTEGER}.
5646
@end multitable
5647
 
5648
@item @emph{Return value}:
5649
The return value is of type @code{INTEGER} and of the same kind as
5650
@var{I}.
5651
 
5652
@item @emph{See also}:
5653
@ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5654
 
5655
@end table
5656
 
5657
 
5658
 
5659
@node ICHAR
5660
@section @code{ICHAR} --- Character-to-integer conversion function
5661
@fnindex ICHAR
5662
@cindex conversion, to integer
5663
 
5664
@table @asis
5665
@item @emph{Description}:
5666
@code{ICHAR(C)} returns the code for the character in the first character
5667
position of @code{C} in the system's native character set.
5668
The correspondence between characters and their codes is not necessarily
5669
the same across different GNU Fortran implementations.
5670
 
5671
@item @emph{Standard}:
5672
Fortan 95 and later, with @var{KIND} argument Fortran 2003 and later
5673
 
5674
@item @emph{Class}:
5675
Elemental function
5676
 
5677
@item @emph{Syntax}:
5678
@code{RESULT = ICHAR(C [, KIND])}
5679
 
5680
@item @emph{Arguments}:
5681
@multitable @columnfractions .15 .70
5682
@item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5683
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5684
expression indicating the kind parameter of the result.
5685
@end multitable
5686
 
5687
@item @emph{Return value}:
5688
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5689
@var{KIND} is absent, the return value is of default integer kind.
5690
 
5691
@item @emph{Example}:
5692
@smallexample
5693
program test_ichar
5694
  integer i
5695
  i = ichar(' ')
5696
end program test_ichar
5697
@end smallexample
5698
 
5699
@item @emph{Note}:
5700
No intrinsic exists to convert between a numeric value and a formatted
5701
character string representation -- for instance, given the
5702
@code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
5703
@code{REAL} value with the value 154, or vice versa. Instead, this
5704
functionality is provided by internal-file I/O, as in the following
5705
example:
5706
@smallexample
5707
program read_val
5708
  integer value
5709
  character(len=10) string, string2
5710
  string = '154'
5711
 
5712
  ! Convert a string to a numeric value
5713
  read (string,'(I10)') value
5714
  print *, value
5715
 
5716
  ! Convert a value to a formatted string
5717
  write (string2,'(I10)') value
5718
  print *, string2
5719
end program read_val
5720
@end smallexample
5721
 
5722
@item @emph{See also}:
5723
@ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5724
 
5725
@end table
5726
 
5727
 
5728
 
5729
@node IDATE
5730
@section @code{IDATE} --- Get current local time subroutine (day/month/year)
5731
@fnindex IDATE
5732
@cindex date, current
5733
@cindex current date
5734
 
5735
@table @asis
5736
@item @emph{Description}:
5737
@code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
5738
current local time. The day (in the range 1-31), month (in the range 1-12),
5739
and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively.
5740
The year has four significant digits.
5741
 
5742
@item @emph{Standard}:
5743
GNU extension
5744
 
5745
@item @emph{Class}:
5746
Subroutine
5747
 
5748
@item @emph{Syntax}:
5749
@code{CALL IDATE(VALUES)}
5750
 
5751
@item @emph{Arguments}:
5752
@multitable @columnfractions .15 .70
5753
@item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5754
the kind shall be the default integer kind.
5755
@end multitable
5756
 
5757
@item @emph{Return value}:
5758
Does not return anything.
5759
 
5760
@item @emph{Example}:
5761
@smallexample
5762
program test_idate
5763
  integer, dimension(3) :: tarray
5764
  call idate(tarray)
5765
  print *, tarray(1)
5766
  print *, tarray(2)
5767
  print *, tarray(3)
5768
end program test_idate
5769
@end smallexample
5770
@end table
5771
 
5772
 
5773
 
5774
@node IEOR
5775
@section @code{IEOR} --- Bitwise logical exclusive or
5776
@fnindex IEOR
5777
@cindex bitwise logical exclusive or
5778
@cindex logical exclusive or, bitwise
5779
 
5780
@table @asis
5781
@item @emph{Description}:
5782
@code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5783
@var{J}.
5784
 
5785
@item @emph{Standard}:
5786
Fortran 95 and later
5787
 
5788
@item @emph{Class}:
5789
Elemental function
5790
 
5791
@item @emph{Syntax}:
5792
@code{RESULT = IEOR(I, J)}
5793
 
5794
@item @emph{Arguments}:
5795
@multitable @columnfractions .15 .70
5796
@item @var{I} @tab The type shall be @code{INTEGER}.
5797
@item @var{J} @tab The type shall be @code{INTEGER}, of the same
5798
kind as @var{I}.  (As a GNU extension, different kinds are also
5799
permitted.)
5800
@end multitable
5801
 
5802
@item @emph{Return value}:
5803
The return type is @code{INTEGER}, of the same kind as the
5804
arguments.  (If the argument kinds differ, it is of the same kind as
5805
the larger argument.)
5806
 
5807
@item @emph{See also}:
5808
@ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5809
@end table
5810
 
5811
 
5812
 
5813
@node IERRNO
5814
@section @code{IERRNO} --- Get the last system error number
5815
@fnindex IERRNO
5816
@cindex system, error handling
5817
 
5818
@table @asis
5819
@item @emph{Description}:
5820
Returns the last system error number, as given by the C @code{errno()}
5821
function.
5822
 
5823
@item @emph{Standard}:
5824
GNU extension
5825
 
5826
@item @emph{Class}:
5827
Function
5828
 
5829
@item @emph{Syntax}:
5830
@code{RESULT = IERRNO()}
5831
 
5832
@item @emph{Arguments}:
5833
None.
5834
 
5835
@item @emph{Return value}:
5836
The return value is of type @code{INTEGER} and of the default integer
5837
kind.
5838
 
5839
@item @emph{See also}:
5840
@ref{PERROR}
5841
@end table
5842
 
5843
 
5844
 
5845
@node INDEX intrinsic
5846
@section @code{INDEX} --- Position of a substring within a string
5847
@fnindex INDEX
5848
@cindex substring position
5849
@cindex string, find substring
5850
 
5851
@table @asis
5852
@item @emph{Description}:
5853
Returns the position of the start of the first occurrence of string
5854
@var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
5855
@var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If
5856
the @var{BACK} argument is present and true, the return value is the
5857
start of the last occurrence rather than the first.
5858
 
5859
@item @emph{Standard}:
5860
Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
5861
 
5862
@item @emph{Class}:
5863
Elemental function
5864
 
5865
@item @emph{Syntax}:
5866
@code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
5867
 
5868
@item @emph{Arguments}:
5869
@multitable @columnfractions .15 .70
5870
@item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
5871
@code{INTENT(IN)}
5872
@item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
5873
@code{INTENT(IN)}
5874
@item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
5875
@code{INTENT(IN)}
5876
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5877
expression indicating the kind parameter of the result.
5878
@end multitable
5879
 
5880
@item @emph{Return value}:
5881
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5882
@var{KIND} is absent, the return value is of default integer kind.
5883
 
5884
@item @emph{See also}:
5885
@ref{SCAN}, @ref{VERIFY}
5886
@end table
5887
 
5888
 
5889
 
5890
@node INT
5891
@section @code{INT} --- Convert to integer type
5892
@fnindex INT
5893
@fnindex IFIX
5894
@fnindex IDINT
5895
@cindex conversion, to integer
5896
 
5897
@table @asis
5898
@item @emph{Description}:
5899
Convert to integer type
5900
 
5901
@item @emph{Standard}:
5902
Fortran 77 and later
5903
 
5904
@item @emph{Class}:
5905
Elemental function
5906
 
5907
@item @emph{Syntax}:
5908
@code{RESULT = INT(A [, KIND))}
5909
 
5910
@item @emph{Arguments}:
5911
@multitable @columnfractions .15 .70
5912
@item @var{A}    @tab Shall be of type @code{INTEGER},
5913
@code{REAL}, or @code{COMPLEX}.
5914
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5915
expression indicating the kind parameter of the result.
5916
@end multitable
5917
 
5918
@item @emph{Return value}:
5919
These functions return a @code{INTEGER} variable or array under
5920
the following rules:
5921
 
5922
@table @asis
5923
@item (A)
5924
If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
5925
@item (B)
5926
If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
5927
If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
5928
the range of @var{A} and whose sign is the same as the sign of @var{A}.
5929
@item (C)
5930
If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
5931
@end table
5932
 
5933
@item @emph{Example}:
5934
@smallexample
5935
program test_int
5936
  integer :: i = 42
5937
  complex :: z = (-3.7, 1.0)
5938
  print *, int(i)
5939
  print *, int(z), int(z,8)
5940
end program
5941
@end smallexample
5942
 
5943
@item @emph{Specific names}:
5944
@multitable @columnfractions .20 .20 .20 .25
5945
@item Name             @tab Argument            @tab Return type       @tab Standard
5946
@item @code{IFIX(A)}   @tab @code{REAL(4) A}    @tab @code{INTEGER}    @tab Fortran 77 and later
5947
@item @code{IDINT(A)}  @tab @code{REAL(8) A}    @tab @code{INTEGER}    @tab Fortran 77 and later
5948
@end multitable
5949
 
5950
@end table
5951
 
5952
 
5953
 
5954
@node INT2
5955
@section @code{INT2} --- Convert to 16-bit integer type
5956
@fnindex INT2
5957
@fnindex SHORT
5958
@cindex conversion, to integer
5959
 
5960
@table @asis
5961
@item @emph{Description}:
5962
Convert to a @code{KIND=2} integer type. This is equivalent to the
5963
standard @code{INT} intrinsic with an optional argument of
5964
@code{KIND=2}, and is only included for backwards compatibility.
5965
 
5966
The @code{SHORT} intrinsic is equivalent to @code{INT2}.
5967
 
5968
@item @emph{Standard}:
5969
GNU extension
5970
 
5971
@item @emph{Class}:
5972
Elemental function
5973
 
5974
@item @emph{Syntax}:
5975
@code{RESULT = INT2(A)}
5976
 
5977
@item @emph{Arguments}:
5978
@multitable @columnfractions .15 .70
5979
@item @var{A}    @tab Shall be of type @code{INTEGER},
5980
@code{REAL}, or @code{COMPLEX}.
5981
@end multitable
5982
 
5983
@item @emph{Return value}:
5984
The return value is a @code{INTEGER(2)} variable.
5985
 
5986
@item @emph{See also}:
5987
@ref{INT}, @ref{INT8}, @ref{LONG}
5988
@end table
5989
 
5990
 
5991
 
5992
@node INT8
5993
@section @code{INT8} --- Convert to 64-bit integer type
5994
@fnindex INT8
5995
@cindex conversion, to integer
5996
 
5997
@table @asis
5998
@item @emph{Description}:
5999
Convert to a @code{KIND=8} integer type. This is equivalent to the
6000
standard @code{INT} intrinsic with an optional argument of
6001
@code{KIND=8}, and is only included for backwards compatibility.
6002
 
6003
@item @emph{Standard}:
6004
GNU extension
6005
 
6006
@item @emph{Class}:
6007
Elemental function
6008
 
6009
@item @emph{Syntax}:
6010
@code{RESULT = INT8(A)}
6011
 
6012
@item @emph{Arguments}:
6013
@multitable @columnfractions .15 .70
6014
@item @var{A}    @tab Shall be of type @code{INTEGER},
6015
@code{REAL}, or @code{COMPLEX}.
6016
@end multitable
6017
 
6018
@item @emph{Return value}:
6019
The return value is a @code{INTEGER(8)} variable.
6020
 
6021
@item @emph{See also}:
6022
@ref{INT}, @ref{INT2}, @ref{LONG}
6023
@end table
6024
 
6025
 
6026
 
6027
@node IOR
6028
@section @code{IOR} --- Bitwise logical or
6029
@fnindex IOR
6030
@cindex bitwise logical or
6031
@cindex logical or, bitwise
6032
 
6033
@table @asis
6034
@item @emph{Description}:
6035
@code{IOR} returns the bitwise boolean inclusive-OR of @var{I} and
6036
@var{J}.
6037
 
6038
@item @emph{Standard}:
6039
Fortran 95 and later
6040
 
6041
@item @emph{Class}:
6042
Elemental function
6043
 
6044
@item @emph{Syntax}:
6045
@code{RESULT = IOR(I, J)}
6046
 
6047
@item @emph{Arguments}:
6048
@multitable @columnfractions .15 .70
6049
@item @var{I} @tab The type shall be @code{INTEGER}.
6050
@item @var{J} @tab The type shall be @code{INTEGER}, of the same
6051
kind as @var{I}.  (As a GNU extension, different kinds are also
6052
permitted.)
6053
@end multitable
6054
 
6055
@item @emph{Return value}:
6056
The return type is @code{INTEGER}, of the same kind as the
6057
arguments.  (If the argument kinds differ, it is of the same kind as
6058
the larger argument.)
6059
 
6060
@item @emph{See also}:
6061
@ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6062
@end table
6063
 
6064
 
6065
 
6066
@node IRAND
6067
@section @code{IRAND} --- Integer pseudo-random number
6068
@fnindex IRAND
6069
@cindex random number generation
6070
 
6071
@table @asis
6072
@item @emph{Description}:
6073
@code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6074
distribution between 0 and a system-dependent limit (which is in most
6075
cases 2147483647). If @var{FLAG} is 0, the next number
6076
in the current sequence is returned; if @var{FLAG} is 1, the generator
6077
is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6078
it is used as a new seed with @code{SRAND}.
6079
 
6080
This intrinsic routine is provided for backwards compatibility with
6081
GNU Fortran 77. It implements a simple modulo generator as provided
6082
by @command{g77}. For new code, one should consider the use of
6083
@ref{RANDOM_NUMBER} as it implements a superior algorithm.
6084
 
6085
@item @emph{Standard}:
6086
GNU extension
6087
 
6088
@item @emph{Class}:
6089
Function
6090
 
6091
@item @emph{Syntax}:
6092
@code{RESULT = IRAND(I)}
6093
 
6094
@item @emph{Arguments}:
6095
@multitable @columnfractions .15 .70
6096
@item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
6097
@end multitable
6098
 
6099
@item @emph{Return value}:
6100
The return value is of @code{INTEGER(kind=4)} type.
6101
 
6102
@item @emph{Example}:
6103
@smallexample
6104
program test_irand
6105
  integer,parameter :: seed = 86456
6106
 
6107
  call srand(seed)
6108
  print *, irand(), irand(), irand(), irand()
6109
  print *, irand(seed), irand(), irand(), irand()
6110
end program test_irand
6111
@end smallexample
6112
 
6113
@end table
6114
 
6115
 
6116
 
6117
@node IS_IOSTAT_END
6118
@section @code{IS_IOSTAT_END} --- Test for end-of-file value
6119
@fnindex IS_IOSTAT_END
6120
@cindex IOSTAT, end of file
6121
 
6122
@table @asis
6123
@item @emph{Description}:
6124
@code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6125
status ``end of file''. The function is equivalent to comparing the variable
6126
with the @code{IOSTAT_END} parameter of the intrinsic module
6127
@code{ISO_FORTRAN_ENV}.
6128
 
6129
@item @emph{Standard}:
6130
Fortran 2003 and later
6131
 
6132
@item @emph{Class}:
6133
Elemental function
6134
 
6135
@item @emph{Syntax}:
6136
@code{RESULT = IS_IOSTAT_END(I)}
6137
 
6138
@item @emph{Arguments}:
6139
@multitable @columnfractions .15 .70
6140
@item @var{I} @tab Shall be of the type @code{INTEGER}.
6141
@end multitable
6142
 
6143
@item @emph{Return value}:
6144
Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6145
@var{I} has the value which indicates an end of file condition for
6146
IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6147
 
6148
@item @emph{Example}:
6149
@smallexample
6150
PROGRAM iostat
6151
  IMPLICIT NONE
6152
  INTEGER :: stat, i
6153
  OPEN(88, FILE='test.dat')
6154
  READ(88, *, IOSTAT=stat) i
6155
  IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
6156
END PROGRAM
6157
@end smallexample
6158
@end table
6159
 
6160
 
6161
 
6162
@node IS_IOSTAT_EOR
6163
@section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
6164
@fnindex IS_IOSTAT_EOR
6165
@cindex IOSTAT, end of record
6166
 
6167
@table @asis
6168
@item @emph{Description}:
6169
@code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
6170
status ``end of record''. The function is equivalent to comparing the
6171
variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
6172
@code{ISO_FORTRAN_ENV}.
6173
 
6174
@item @emph{Standard}:
6175
Fortran 2003 and later
6176
 
6177
@item @emph{Class}:
6178
Elemental function
6179
 
6180
@item @emph{Syntax}:
6181
@code{RESULT = IS_IOSTAT_EOR(I)}
6182
 
6183
@item @emph{Arguments}:
6184
@multitable @columnfractions .15 .70
6185
@item @var{I} @tab Shall be of the type @code{INTEGER}.
6186
@end multitable
6187
 
6188
@item @emph{Return value}:
6189
Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6190
@var{I} has the value which indicates an end of file condition for
6191
IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6192
 
6193
@item @emph{Example}:
6194
@smallexample
6195
PROGRAM iostat
6196
  IMPLICIT NONE
6197
  INTEGER :: stat, i(50)
6198
  OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
6199
  READ(88, IOSTAT=stat) i
6200
  IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
6201
END PROGRAM
6202
@end smallexample
6203
@end table
6204
 
6205
 
6206
 
6207
@node ISATTY
6208
@section @code{ISATTY} --- Whether a unit is a terminal device.
6209
@fnindex ISATTY
6210
@cindex system, terminal
6211
 
6212
@table @asis
6213
@item @emph{Description}:
6214
Determine whether a unit is connected to a terminal device.
6215
 
6216
@item @emph{Standard}:
6217
GNU extension
6218
 
6219
@item @emph{Class}:
6220
Function
6221
 
6222
@item @emph{Syntax}:
6223
@code{RESULT = ISATTY(UNIT)}
6224
 
6225
@item @emph{Arguments}:
6226
@multitable @columnfractions .15 .70
6227
@item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
6228
@end multitable
6229
 
6230
@item @emph{Return value}:
6231
Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
6232
device, @code{.FALSE.} otherwise.
6233
 
6234
@item @emph{Example}:
6235
@smallexample
6236
PROGRAM test_isatty
6237
  INTEGER(kind=1) :: unit
6238
  DO unit = 1, 10
6239
    write(*,*) isatty(unit=unit)
6240
  END DO
6241
END PROGRAM
6242
@end smallexample
6243
@item @emph{See also}:
6244
@ref{TTYNAM}
6245
@end table
6246
 
6247
 
6248
 
6249
@node ISHFT
6250
@section @code{ISHFT} --- Shift bits
6251
@fnindex ISHFT
6252
@cindex bits, shift
6253
 
6254
@table @asis
6255
@item @emph{Description}:
6256
@code{ISHFT} returns a value corresponding to @var{I} with all of the
6257
bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
6258
zero corresponds to a left shift, a value of zero corresponds to no
6259
shift, and a value less than zero corresponds to a right shift.  If the
6260
absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
6261
value is undefined.  Bits shifted out from the left end or right end are
6262
lost; zeros are shifted in from the opposite end.
6263
 
6264
@item @emph{Standard}:
6265
Fortran 95 and later
6266
 
6267
@item @emph{Class}:
6268
Elemental function
6269
 
6270
@item @emph{Syntax}:
6271
@code{RESULT = ISHFT(I, SHIFT)}
6272
 
6273
@item @emph{Arguments}:
6274
@multitable @columnfractions .15 .70
6275
@item @var{I} @tab The type shall be @code{INTEGER}.
6276
@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6277
@end multitable
6278
 
6279
@item @emph{Return value}:
6280
The return value is of type @code{INTEGER} and of the same kind as
6281
@var{I}.
6282
 
6283
@item @emph{See also}:
6284
@ref{ISHFTC}
6285
@end table
6286
 
6287
 
6288
 
6289
@node ISHFTC
6290
@section @code{ISHFTC} --- Shift bits circularly
6291
@fnindex ISHFTC
6292
@cindex bits, shift circular
6293
 
6294
@table @asis
6295
@item @emph{Description}:
6296
@code{ISHFTC} returns a value corresponding to @var{I} with the
6297
rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
6298
is, bits shifted out one end are shifted into the opposite end.  A value
6299
of @var{SHIFT} greater than zero corresponds to a left shift, a value of
6300
zero corresponds to no shift, and a value less than zero corresponds to
6301
a right shift.  The absolute value of @var{SHIFT} must be less than
6302
@var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
6303
equivalent to @code{BIT_SIZE(I)}.
6304
 
6305
@item @emph{Standard}:
6306
Fortran 95 and later
6307
 
6308
@item @emph{Class}:
6309
Elemental function
6310
 
6311
@item @emph{Syntax}:
6312
@code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
6313
 
6314
@item @emph{Arguments}:
6315
@multitable @columnfractions .15 .70
6316
@item @var{I} @tab The type shall be @code{INTEGER}.
6317
@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6318
@item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
6319
the value must be greater than zero and less than or equal to
6320
@code{BIT_SIZE(I)}.
6321
@end multitable
6322
 
6323
@item @emph{Return value}:
6324
The return value is of type @code{INTEGER} and of the same kind as
6325
@var{I}.
6326
 
6327
@item @emph{See also}:
6328
@ref{ISHFT}
6329
@end table
6330
 
6331
 
6332
 
6333
@node ISNAN
6334
@section @code{ISNAN} --- Test for a NaN
6335
@fnindex ISNAN
6336
@cindex IEEE, ISNAN
6337
 
6338
@table @asis
6339
@item @emph{Description}:
6340
@code{ISNAN} tests whether a floating-point value is an IEEE
6341
Not-a-Number (NaN).
6342
@item @emph{Standard}:
6343
GNU extension
6344
 
6345
@item @emph{Class}:
6346
Elemental function
6347
 
6348
@item @emph{Syntax}:
6349
@code{ISNAN(X)}
6350
 
6351
@item @emph{Arguments}:
6352
@multitable @columnfractions .15 .70
6353
@item @var{X} @tab Variable of the type @code{REAL}.
6354
 
6355
@end multitable
6356
 
6357
@item @emph{Return value}:
6358
Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
6359
if @var{X} is a NaN and @code{FALSE} otherwise.
6360
 
6361
@item @emph{Example}:
6362
@smallexample
6363
program test_nan
6364
  implicit none
6365
  real :: x
6366
  x = -1.0
6367
  x = sqrt(x)
6368
  if (isnan(x)) stop '"x" is a NaN'
6369
end program test_nan
6370
@end smallexample
6371
@end table
6372
 
6373
 
6374
 
6375
@node ITIME
6376
@section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
6377
@fnindex ITIME
6378
@cindex time, current
6379
@cindex current time
6380
 
6381
@table @asis
6382
@item @emph{Description}:
6383
@code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
6384
current local time. The hour (in the range 1-24), minute (in the range 1-60),
6385
and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES},
6386
respectively.
6387
 
6388
@item @emph{Standard}:
6389
GNU extension
6390
 
6391
@item @emph{Class}:
6392
Subroutine
6393
 
6394
@item @emph{Syntax}:
6395
@code{CALL ITIME(VALUES)}
6396
 
6397
@item @emph{Arguments}:
6398
@multitable @columnfractions .15 .70
6399
@item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
6400
and the kind shall be the default integer kind.
6401
@end multitable
6402
 
6403
@item @emph{Return value}:
6404
Does not return anything.
6405
 
6406
 
6407
@item @emph{Example}:
6408
@smallexample
6409
program test_itime
6410
  integer, dimension(3) :: tarray
6411
  call itime(tarray)
6412
  print *, tarray(1)
6413
  print *, tarray(2)
6414
  print *, tarray(3)
6415
end program test_itime
6416
@end smallexample
6417
@end table
6418
 
6419
 
6420
 
6421
@node KILL
6422
@section @code{KILL} --- Send a signal to a process
6423
@fnindex KILL
6424
 
6425
@table @asis
6426
@item @emph{Description}:
6427
@item @emph{Standard}:
6428
Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
6429
See @code{kill(2)}.
6430
 
6431
This intrinsic is provided in both subroutine and function forms; however,
6432
only one form can be used in any given program unit.
6433
 
6434
@item @emph{Class}:
6435
Subroutine, function
6436
 
6437
@item @emph{Syntax}:
6438
@code{CALL KILL(C, VALUE [, STATUS])}
6439
 
6440
@item @emph{Arguments}:
6441
@multitable @columnfractions .15 .70
6442
@item @var{C} @tab Shall be a scalar @code{INTEGER}, with
6443
@code{INTENT(IN)}
6444
@item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
6445
@code{INTENT(IN)}
6446
@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
6447
@code{INTEGER(8)}. Returns 0 on success, or a system-specific error code
6448
otherwise.
6449
@end multitable
6450
 
6451
@item @emph{See also}:
6452
@ref{ABORT}, @ref{EXIT}
6453
@end table
6454
 
6455
 
6456
 
6457
@node KIND
6458
@section @code{KIND} --- Kind of an entity
6459
@fnindex KIND
6460
@cindex kind
6461
 
6462
@table @asis
6463
@item @emph{Description}:
6464
@code{KIND(X)} returns the kind value of the entity @var{X}.
6465
 
6466
@item @emph{Standard}:
6467
Fortran 95 and later
6468
 
6469
@item @emph{Class}:
6470
Inquiry function
6471
 
6472
@item @emph{Syntax}:
6473
@code{K = KIND(X)}
6474
 
6475
@item @emph{Arguments}:
6476
@multitable @columnfractions .15 .70
6477
@item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
6478
@code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
6479
@end multitable
6480
 
6481
@item @emph{Return value}:
6482
The return value is a scalar of type @code{INTEGER} and of the default
6483
integer kind.
6484
 
6485
@item @emph{Example}:
6486
@smallexample
6487
program test_kind
6488
  integer,parameter :: kc = kind(' ')
6489
  integer,parameter :: kl = kind(.true.)
6490
 
6491
  print *, "The default character kind is ", kc
6492
  print *, "The default logical kind is ", kl
6493
end program test_kind
6494
@end smallexample
6495
 
6496
@end table
6497
 
6498
 
6499
 
6500
@node LBOUND
6501
@section @code{LBOUND} --- Lower dimension bounds of an array
6502
@fnindex LBOUND
6503
@cindex array, lower bound
6504
 
6505
@table @asis
6506
@item @emph{Description}:
6507
Returns the lower bounds of an array, or a single lower bound
6508
along the @var{DIM} dimension.
6509
@item @emph{Standard}:
6510
Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6511
 
6512
@item @emph{Class}:
6513
Inquiry function
6514
 
6515
@item @emph{Syntax}:
6516
@code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
6517
 
6518
@item @emph{Arguments}:
6519
@multitable @columnfractions .15 .70
6520
@item @var{ARRAY} @tab Shall be an array, of any type.
6521
@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
6522
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6523
expression indicating the kind parameter of the result.
6524
@end multitable
6525
 
6526
@item @emph{Return value}:
6527
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6528
@var{KIND} is absent, the return value is of default integer kind.
6529
If @var{DIM} is absent, the result is an array of the lower bounds of
6530
@var{ARRAY}.  If @var{DIM} is present, the result is a scalar
6531
corresponding to the lower bound of the array along that dimension.  If
6532
@var{ARRAY} is an expression rather than a whole array or array
6533
structure component, or if it has a zero extent along the relevant
6534
dimension, the lower bound is taken to be 1.
6535
 
6536
@item @emph{See also}:
6537
@ref{UBOUND}
6538
@end table
6539
 
6540
 
6541
 
6542
@node LEADZ
6543
@section @code{LEADZ} --- Number of leading zero bits of an integer
6544
@fnindex LEADZ
6545
@cindex zero bits
6546
 
6547
@table @asis
6548
@item @emph{Description}:
6549
@code{LEADZ} returns the number of leading zero bits of an integer.
6550
 
6551
@item @emph{Standard}:
6552
Fortran 2008 and later
6553
 
6554
@item @emph{Class}:
6555
Elemental function
6556
 
6557
@item @emph{Syntax}:
6558
@code{RESULT = LEADZ(I)}
6559
 
6560
@item @emph{Arguments}:
6561
@multitable @columnfractions .15 .70
6562
@item @var{I} @tab Shall be of type @code{INTEGER}.
6563
@end multitable
6564
 
6565
@item @emph{Return value}:
6566
The type of the return value is the default @code{INTEGER}.
6567
If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
6568
 
6569
@item @emph{Example}:
6570
@smallexample
6571
PROGRAM test_leadz
6572
  WRITE (*,*) LEADZ(1)  ! prints 8 if BITSIZE(I) has the value 32
6573
END PROGRAM
6574
@end smallexample
6575
 
6576
@item @emph{See also}:
6577
@ref{BIT_SIZE}, @ref{TRAILZ}
6578
@end table
6579
 
6580
 
6581
 
6582
@node LEN
6583
@section @code{LEN} --- Length of a character entity
6584
@fnindex LEN
6585
@cindex string, length
6586
 
6587
@table @asis
6588
@item @emph{Description}:
6589
Returns the length of a character string.  If @var{STRING} is an array,
6590
the length of an element of @var{STRING} is returned.  Note that
6591
@var{STRING} need not be defined when this intrinsic is invoked, since
6592
only the length, not the content, of @var{STRING} is needed.
6593
 
6594
@item @emph{Standard}:
6595
Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
6596
 
6597
@item @emph{Class}:
6598
Inquiry function
6599
 
6600
@item @emph{Syntax}:
6601
@code{L = LEN(STRING [, KIND])}
6602
 
6603
@item @emph{Arguments}:
6604
@multitable @columnfractions .15 .70
6605
@item @var{STRING} @tab Shall be a scalar or array of type
6606
@code{CHARACTER}, with @code{INTENT(IN)}
6607
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6608
expression indicating the kind parameter of the result.
6609
@end multitable
6610
 
6611
@item @emph{Return value}:
6612
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6613
@var{KIND} is absent, the return value is of default integer kind.
6614
 
6615
@item @emph{See also}:
6616
@ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
6617
@end table
6618
 
6619
 
6620
 
6621
@node LEN_TRIM
6622
@section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
6623
@fnindex LEN_TRIM
6624
@cindex string, length, without trailing whitespace
6625
 
6626
@table @asis
6627
@item @emph{Description}:
6628
Returns the length of a character string, ignoring any trailing blanks.
6629
 
6630
@item @emph{Standard}:
6631
Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6632
 
6633
@item @emph{Class}:
6634
Elemental function
6635
 
6636
@item @emph{Syntax}:
6637
@code{RESULT = LEN_TRIM(STRING [, KIND])}
6638
 
6639
@item @emph{Arguments}:
6640
@multitable @columnfractions .15 .70
6641
@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6642
with @code{INTENT(IN)}
6643
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6644
expression indicating the kind parameter of the result.
6645
@end multitable
6646
 
6647
@item @emph{Return value}:
6648
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6649
@var{KIND} is absent, the return value is of default integer kind.
6650
 
6651
@item @emph{See also}:
6652
@ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
6653
@end table
6654
 
6655
 
6656
 
6657
@node LGE
6658
@section @code{LGE} --- Lexical greater than or equal
6659
@fnindex LGE
6660
@cindex lexical comparison of strings
6661
@cindex string, comparison
6662
 
6663
@table @asis
6664
@item @emph{Description}:
6665
Determines whether one string is lexically greater than or equal to
6666
another string, where the two strings are interpreted as containing
6667
ASCII character codes.  If the String A and String B are not the same
6668
length, the shorter is compared as if spaces were appended to it to form
6669
a value that has the same length as the longer.
6670
 
6671
In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6672
@code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6673
operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6674
that the latter use the processor's character ordering (which is not
6675
ASCII on some targets), whereas the former always use the ASCII
6676
ordering.
6677
 
6678
@item @emph{Standard}:
6679
Fortran 77 and later
6680
 
6681
@item @emph{Class}:
6682
Elemental function
6683
 
6684
@item @emph{Syntax}:
6685
@code{RESULT = LGE(STRING_A, STRING_B)}
6686
 
6687
@item @emph{Arguments}:
6688
@multitable @columnfractions .15 .70
6689
@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6690
@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6691
@end multitable
6692
 
6693
@item @emph{Return value}:
6694
Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
6695
otherwise, based on the ASCII ordering.
6696
 
6697
@item @emph{See also}:
6698
@ref{LGT}, @ref{LLE}, @ref{LLT}
6699
@end table
6700
 
6701
 
6702
 
6703
@node LGT
6704
@section @code{LGT} --- Lexical greater than
6705
@fnindex LGT
6706
@cindex lexical comparison of strings
6707
@cindex string, comparison
6708
 
6709
@table @asis
6710
@item @emph{Description}:
6711
Determines whether one string is lexically greater than another string,
6712
where the two strings are interpreted as containing ASCII character
6713
codes.  If the String A and String B are not the same length, the
6714
shorter is compared as if spaces were appended to it to form a value
6715
that has the same length as the longer.
6716
 
6717
In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6718
@code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6719
operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6720
that the latter use the processor's character ordering (which is not
6721
ASCII on some targets), whereas the former always use the ASCII
6722
ordering.
6723
 
6724
@item @emph{Standard}:
6725
Fortran 77 and later
6726
 
6727
@item @emph{Class}:
6728
Elemental function
6729
 
6730
@item @emph{Syntax}:
6731
@code{RESULT = LGT(STRING_A, STRING_B)}
6732
 
6733
@item @emph{Arguments}:
6734
@multitable @columnfractions .15 .70
6735
@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6736
@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6737
@end multitable
6738
 
6739
@item @emph{Return value}:
6740
Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
6741
otherwise, based on the ASCII ordering.
6742
 
6743
@item @emph{See also}:
6744
@ref{LGE}, @ref{LLE}, @ref{LLT}
6745
@end table
6746
 
6747
 
6748
 
6749
@node LINK
6750
@section @code{LINK} --- Create a hard link
6751
@fnindex LINK
6752
@cindex file system, create link
6753
@cindex file system, hard link
6754
 
6755
@table @asis
6756
@item @emph{Description}:
6757
Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
6758
character (@code{CHAR(0)}) can be used to mark the end of the names in
6759
@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
6760
names are ignored.  If the @var{STATUS} argument is supplied, it
6761
contains 0 on success or a nonzero error code upon return; see
6762
@code{link(2)}.
6763
 
6764
This intrinsic is provided in both subroutine and function forms;
6765
however, only one form can be used in any given program unit.
6766
 
6767
@item @emph{Standard}:
6768
GNU extension
6769
 
6770
@item @emph{Class}:
6771
Subroutine, function
6772
 
6773
@item @emph{Syntax}:
6774
@multitable @columnfractions .80
6775
@item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
6776
@item @code{STATUS = LINK(PATH1, PATH2)}
6777
@end multitable
6778
 
6779
@item @emph{Arguments}:
6780
@multitable @columnfractions .15 .70
6781
@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
6782
@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
6783
@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
6784
@end multitable
6785
 
6786
@item @emph{See also}:
6787
@ref{SYMLNK}, @ref{UNLINK}
6788
@end table
6789
 
6790
 
6791
 
6792
@node LLE
6793
@section @code{LLE} --- Lexical less than or equal
6794
@fnindex LLE
6795
@cindex lexical comparison of strings
6796
@cindex string, comparison
6797
 
6798
@table @asis
6799
@item @emph{Description}:
6800
Determines whether one string is lexically less than or equal to another
6801
string, where the two strings are interpreted as containing ASCII
6802
character codes.  If the String A and String B are not the same length,
6803
the shorter is compared as if spaces were appended to it to form a value
6804
that has the same length as the longer.
6805
 
6806
In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6807
@code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6808
operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6809
that the latter use the processor's character ordering (which is not
6810
ASCII on some targets), whereas the former always use the ASCII
6811
ordering.
6812
 
6813
@item @emph{Standard}:
6814
Fortran 77 and later
6815
 
6816
@item @emph{Class}:
6817
Elemental function
6818
 
6819
@item @emph{Syntax}:
6820
@code{RESULT = LLE(STRING_A, STRING_B)}
6821
 
6822
@item @emph{Arguments}:
6823
@multitable @columnfractions .15 .70
6824
@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6825
@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6826
@end multitable
6827
 
6828
@item @emph{Return value}:
6829
Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
6830
otherwise, based on the ASCII ordering.
6831
 
6832
@item @emph{See also}:
6833
@ref{LGE}, @ref{LGT}, @ref{LLT}
6834
@end table
6835
 
6836
 
6837
 
6838
@node LLT
6839
@section @code{LLT} --- Lexical less than
6840
@fnindex LLT
6841
@cindex lexical comparison of strings
6842
@cindex string, comparison
6843
 
6844
@table @asis
6845
@item @emph{Description}:
6846
Determines whether one string is lexically less than another string,
6847
where the two strings are interpreted as containing ASCII character
6848
codes.  If the String A and String B are not the same length, the
6849
shorter is compared as if spaces were appended to it to form a value
6850
that has the same length as the longer.
6851
 
6852
In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6853
@code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6854
operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6855
that the latter use the processor's character ordering (which is not
6856
ASCII on some targets), whereas the former always use the ASCII
6857
ordering.
6858
 
6859
@item @emph{Standard}:
6860
Fortran 77 and later
6861
 
6862
@item @emph{Class}:
6863
Elemental function
6864
 
6865
@item @emph{Syntax}:
6866
@code{RESULT = LLT(STRING_A, STRING_B)}
6867
 
6868
@item @emph{Arguments}:
6869
@multitable @columnfractions .15 .70
6870
@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6871
@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6872
@end multitable
6873
 
6874
@item @emph{Return value}:
6875
Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
6876
otherwise, based on the ASCII ordering.
6877
 
6878
@item @emph{See also}:
6879
@ref{LGE}, @ref{LGT}, @ref{LLE}
6880
@end table
6881
 
6882
 
6883
 
6884
@node LNBLNK
6885
@section @code{LNBLNK} --- Index of the last non-blank character in a string
6886
@fnindex LNBLNK
6887
@cindex string, find non-blank character
6888
 
6889
@table @asis
6890
@item @emph{Description}:
6891
Returns the length of a character string, ignoring any trailing blanks.
6892
This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
6893
included for backwards compatibility.
6894
 
6895
@item @emph{Standard}:
6896
GNU extension
6897
 
6898
@item @emph{Class}:
6899
Elemental function
6900
 
6901
@item @emph{Syntax}:
6902
@code{RESULT = LNBLNK(STRING)}
6903
 
6904
@item @emph{Arguments}:
6905
@multitable @columnfractions .15 .70
6906
@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6907
with @code{INTENT(IN)}
6908
@end multitable
6909
 
6910
@item @emph{Return value}:
6911
The return value is of @code{INTEGER(kind=4)} type.
6912
 
6913
@item @emph{See also}:
6914
@ref{INDEX intrinsic}, @ref{LEN_TRIM}
6915
@end table
6916
 
6917
 
6918
 
6919
@node LOC
6920
@section @code{LOC} --- Returns the address of a variable
6921
@fnindex LOC
6922
@cindex location of a variable in memory
6923
 
6924
@table @asis
6925
@item @emph{Description}:
6926
@code{LOC(X)} returns the address of @var{X} as an integer.
6927
 
6928
@item @emph{Standard}:
6929
GNU extension
6930
 
6931
@item @emph{Class}:
6932
Inquiry function
6933
 
6934
@item @emph{Syntax}:
6935
@code{RESULT = LOC(X)}
6936
 
6937
@item @emph{Arguments}:
6938
@multitable @columnfractions .15 .70
6939
@item @var{X} @tab Variable of any type.
6940
@end multitable
6941
 
6942
@item @emph{Return value}:
6943
The return value is of type @code{INTEGER}, with a @code{KIND}
6944
corresponding to the size (in bytes) of a memory address on the target
6945
machine.
6946
 
6947
@item @emph{Example}:
6948
@smallexample
6949
program test_loc
6950
  integer :: i
6951
  real :: r
6952
  i = loc(r)
6953
  print *, i
6954
end program test_loc
6955
@end smallexample
6956
@end table
6957
 
6958
 
6959
 
6960
@node LOG
6961
@section @code{LOG} --- Logarithm function
6962
@fnindex LOG
6963
@fnindex ALOG
6964
@fnindex DLOG
6965
@fnindex CLOG
6966
@fnindex ZLOG
6967
@fnindex CDLOG
6968
@cindex exponential function, inverse
6969
@cindex logarithmic function
6970
 
6971
@table @asis
6972
@item @emph{Description}:
6973
@code{LOG(X)} computes the logarithm of @var{X}.
6974
 
6975
@item @emph{Standard}:
6976
Fortran 77 and later
6977
 
6978
@item @emph{Class}:
6979
Elemental function
6980
 
6981
@item @emph{Syntax}:
6982
@code{RESULT = LOG(X)}
6983
 
6984
@item @emph{Arguments}:
6985
@multitable @columnfractions .15 .70
6986
@item @var{X} @tab The type shall be @code{REAL} or
6987
@code{COMPLEX}.
6988
@end multitable
6989
 
6990
@item @emph{Return value}:
6991
The return value is of type @code{REAL} or @code{COMPLEX}.
6992
The kind type parameter is the same as @var{X}.
6993
If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
6994
@math{-\pi \leq \omega \leq \pi}.
6995
 
6996
@item @emph{Example}:
6997
@smallexample
6998
program test_log
6999
  real(8) :: x = 1.0_8
7000
  complex :: z = (1.0, 2.0)
7001
  x = log(x)
7002
  z = log(z)
7003
end program test_log
7004
@end smallexample
7005
 
7006
@item @emph{Specific names}:
7007
@multitable @columnfractions .20 .20 .20 .25
7008
@item Name            @tab Argument          @tab Return type       @tab Standard
7009
@item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
7010
@item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
7011
@item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
7012
@item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7013
@item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7014
@end multitable
7015
@end table
7016
 
7017
 
7018
 
7019
@node LOG10
7020
@section @code{LOG10} --- Base 10 logarithm function
7021
@fnindex LOG10
7022
@fnindex ALOG10
7023
@fnindex DLOG10
7024
@cindex exponential function, inverse
7025
@cindex logarithmic function
7026
 
7027
@table @asis
7028
@item @emph{Description}:
7029
@code{LOG10(X)} computes the base 10 logarithm of @var{X}.
7030
 
7031
@item @emph{Standard}:
7032
Fortran 77 and later
7033
 
7034
@item @emph{Class}:
7035
Elemental function
7036
 
7037
@item @emph{Syntax}:
7038
@code{RESULT = LOG10(X)}
7039
 
7040
@item @emph{Arguments}:
7041
@multitable @columnfractions .15 .70
7042
@item @var{X} @tab The type shall be @code{REAL}.
7043
@end multitable
7044
 
7045
@item @emph{Return value}:
7046
The return value is of type @code{REAL} or @code{COMPLEX}.
7047
The kind type parameter is the same as @var{X}.
7048
 
7049
@item @emph{Example}:
7050
@smallexample
7051
program test_log10
7052
  real(8) :: x = 10.0_8
7053
  x = log10(x)
7054
end program test_log10
7055
@end smallexample
7056
 
7057
@item @emph{Specific names}:
7058
@multitable @columnfractions .20 .20 .20 .25
7059
@item Name            @tab Argument          @tab Return type       @tab Standard
7060
@item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
7061
@item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
7062
@end multitable
7063
@end table
7064
 
7065
 
7066
 
7067
@node LOG_GAMMA
7068
@section @code{LOG_GAMMA} --- Logarithm of the Gamma function
7069
@fnindex LOG_GAMMA
7070
@fnindex LGAMMA
7071
@fnindex ALGAMA
7072
@fnindex DLGAMA
7073
@cindex Gamma function, logarithm of
7074
 
7075
@table @asis
7076
@item @emph{Description}:
7077
@code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
7078
of the Gamma (@math{\Gamma}) function.
7079
 
7080
@item @emph{Standard}:
7081
Fortran 2008 and later
7082
 
7083
@item @emph{Class}:
7084
Elemental function
7085
 
7086
@item @emph{Syntax}:
7087
@code{X = LOG_GAMMA(X)}
7088
 
7089
@item @emph{Arguments}:
7090
@multitable @columnfractions .15 .70
7091
@item @var{X} @tab Shall be of type @code{REAL} and neither zero
7092
nor a negative integer.
7093
@end multitable
7094
 
7095
@item @emph{Return value}:
7096
The return value is of type @code{REAL} of the same kind as @var{X}.
7097
 
7098
@item @emph{Example}:
7099
@smallexample
7100
program test_log_gamma
7101
  real :: x = 1.0
7102
  x = lgamma(x) ! returns 0.0
7103
end program test_log_gamma
7104
@end smallexample
7105
 
7106
@item @emph{Specific names}:
7107
@multitable @columnfractions .20 .20 .20 .25
7108
@item Name             @tab Argument         @tab Return type       @tab Standard
7109
@item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7110
@item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7111
@item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
7112
@end multitable
7113
 
7114
@item @emph{See also}:
7115
Gamma function: @ref{GAMMA}
7116
 
7117
@end table
7118
 
7119
 
7120
 
7121
@node LOGICAL
7122
@section @code{LOGICAL} --- Convert to logical type
7123
@fnindex LOGICAL
7124
@cindex conversion, to logical
7125
 
7126
@table @asis
7127
@item @emph{Description}:
7128
Converts one kind of @code{LOGICAL} variable to another.
7129
 
7130
@item @emph{Standard}:
7131
Fortran 95 and later
7132
 
7133
@item @emph{Class}:
7134
Elemental function
7135
 
7136
@item @emph{Syntax}:
7137
@code{RESULT = LOGICAL(L [, KIND])}
7138
 
7139
@item @emph{Arguments}:
7140
@multitable @columnfractions .15 .70
7141
@item @var{L}    @tab The type shall be @code{LOGICAL}.
7142
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7143
expression indicating the kind parameter of the result.
7144
@end multitable
7145
 
7146
@item @emph{Return value}:
7147
The return value is a @code{LOGICAL} value equal to @var{L}, with a
7148
kind corresponding to @var{KIND}, or of the default logical kind if
7149
@var{KIND} is not given.
7150
 
7151
@item @emph{See also}:
7152
@ref{INT}, @ref{REAL}, @ref{CMPLX}
7153
@end table
7154
 
7155
 
7156
 
7157
@node LONG
7158
@section @code{LONG} --- Convert to integer type
7159
@fnindex LONG
7160
@cindex conversion, to integer
7161
 
7162
@table @asis
7163
@item @emph{Description}:
7164
Convert to a @code{KIND=4} integer type, which is the same size as a C
7165
@code{long} integer.  This is equivalent to the standard @code{INT}
7166
intrinsic with an optional argument of @code{KIND=4}, and is only
7167
included for backwards compatibility.
7168
 
7169
@item @emph{Standard}:
7170
GNU extension
7171
 
7172
@item @emph{Class}:
7173
Elemental function
7174
 
7175
@item @emph{Syntax}:
7176
@code{RESULT = LONG(A)}
7177
 
7178
@item @emph{Arguments}:
7179
@multitable @columnfractions .15 .70
7180
@item @var{A}    @tab Shall be of type @code{INTEGER},
7181
@code{REAL}, or @code{COMPLEX}.
7182
@end multitable
7183
 
7184
@item @emph{Return value}:
7185
The return value is a @code{INTEGER(4)} variable.
7186
 
7187
@item @emph{See also}:
7188
@ref{INT}, @ref{INT2}, @ref{INT8}
7189
@end table
7190
 
7191
 
7192
 
7193
@node LSHIFT
7194
@section @code{LSHIFT} --- Left shift bits
7195
@fnindex LSHIFT
7196
@cindex bits, shift left
7197
 
7198
@table @asis
7199
@item @emph{Description}:
7200
@code{LSHIFT} returns a value corresponding to @var{I} with all of the
7201
bits shifted left by @var{SHIFT} places.  If the absolute value of
7202
@var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
7203
Bits shifted out from the left end are lost; zeros are shifted in from
7204
the opposite end.
7205
 
7206
This function has been superseded by the @code{ISHFT} intrinsic, which
7207
is standard in Fortran 95 and later.
7208
 
7209
@item @emph{Standard}:
7210
GNU extension
7211
 
7212
@item @emph{Class}:
7213
Elemental function
7214
 
7215
@item @emph{Syntax}:
7216
@code{RESULT = LSHIFT(I, SHIFT)}
7217
 
7218
@item @emph{Arguments}:
7219
@multitable @columnfractions .15 .70
7220
@item @var{I} @tab The type shall be @code{INTEGER}.
7221
@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7222
@end multitable
7223
 
7224
@item @emph{Return value}:
7225
The return value is of type @code{INTEGER} and of the same kind as
7226
@var{I}.
7227
 
7228
@item @emph{See also}:
7229
@ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
7230
 
7231
@end table
7232
 
7233
 
7234
 
7235
@node LSTAT
7236
@section @code{LSTAT} --- Get file status
7237
@fnindex LSTAT
7238
@cindex file system, file status
7239
 
7240
@table @asis
7241
@item @emph{Description}:
7242
@code{LSTAT} is identical to @ref{STAT}, except that if path is a
7243
symbolic link, then the link itself is statted, not the file that it
7244
refers to.
7245
 
7246
The elements in @code{VALUES} are the same as described by @ref{STAT}.
7247
 
7248
This intrinsic is provided in both subroutine and function forms;
7249
however, only one form can be used in any given program unit.
7250
 
7251
@item @emph{Standard}:
7252
GNU extension
7253
 
7254
@item @emph{Class}:
7255
Subroutine, function
7256
 
7257
@item @emph{Syntax}:
7258
@code{CALL LSTAT(NAME, VALUES [, STATUS])}
7259
 
7260
@item @emph{Arguments}:
7261
@multitable @columnfractions .15 .70
7262
@item @var{NAME}   @tab The type shall be @code{CHARACTER} of the default
7263
kind, a valid path within the file system.
7264
@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
7265
@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
7266
Returns 0 on success and a system specific error code otherwise.
7267
@end multitable
7268
 
7269
@item @emph{Example}:
7270
See @ref{STAT} for an example.
7271
 
7272
@item @emph{See also}:
7273
To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
7274
@end table
7275
 
7276
 
7277
 
7278
@node LTIME
7279
@section @code{LTIME} --- Convert time to local time info
7280
@fnindex LTIME
7281
@cindex time, conversion to local time info
7282
 
7283
@table @asis
7284
@item @emph{Description}:
7285
Given a system time value @var{TIME} (as provided by the @code{TIME8()}
7286
intrinsic), fills @var{VALUES} with values extracted from it appropriate
7287
to the local time zone using @code{localtime(3)}.
7288
 
7289
@item @emph{Standard}:
7290
GNU extension
7291
 
7292
@item @emph{Class}:
7293
Subroutine
7294
 
7295
@item @emph{Syntax}:
7296
@code{CALL LTIME(TIME, VALUES)}
7297
 
7298
@item @emph{Arguments}:
7299
@multitable @columnfractions .15 .70
7300
@item @var{TIME}  @tab An @code{INTEGER} scalar expression
7301
corresponding to a system time, with @code{INTENT(IN)}.
7302
@item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
7303
with @code{INTENT(OUT)}.
7304
@end multitable
7305
 
7306
@item @emph{Return value}:
7307
The elements of @var{VALUES} are assigned as follows:
7308
@enumerate
7309
@item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7310
seconds
7311
@item Minutes after the hour, range 0--59
7312
@item Hours past midnight, range 0--23
7313
@item Day of month, range 0--31
7314
@item Number of months since January, range 0--12
7315
@item Years since 1900
7316
@item Number of days since Sunday, range 0--6
7317
@item Days since January 1
7318
@item Daylight savings indicator: positive if daylight savings is in
7319
effect, zero if not, and negative if the information is not available.
7320
@end enumerate
7321
 
7322
@item @emph{See also}:
7323
@ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
7324
 
7325
@end table
7326
 
7327
 
7328
 
7329
@node MALLOC
7330
@section @code{MALLOC} --- Allocate dynamic memory
7331
@fnindex MALLOC
7332
@cindex pointer, cray
7333
 
7334
@table @asis
7335
@item @emph{Description}:
7336
@code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
7337
returns the address of the allocated memory. The @code{MALLOC} intrinsic
7338
is an extension intended to be used with Cray pointers, and is provided
7339
in GNU Fortran to allow the user to compile legacy code. For new code
7340
using Fortran 95 pointers, the memory allocation intrinsic is
7341
@code{ALLOCATE}.
7342
 
7343
@item @emph{Standard}:
7344
GNU extension
7345
 
7346
@item @emph{Class}:
7347
Function
7348
 
7349
@item @emph{Syntax}:
7350
@code{PTR = MALLOC(SIZE)}
7351
 
7352
@item @emph{Arguments}:
7353
@multitable @columnfractions .15 .70
7354
@item @var{SIZE} @tab The type shall be @code{INTEGER}.
7355
@end multitable
7356
 
7357
@item @emph{Return value}:
7358
The return value is of type @code{INTEGER(K)}, with @var{K} such that
7359
variables of type @code{INTEGER(K)} have the same size as
7360
C pointers (@code{sizeof(void *)}).
7361
 
7362
@item @emph{Example}:
7363
The following example demonstrates the use of @code{MALLOC} and
7364
@code{FREE} with Cray pointers.
7365
 
7366
@smallexample
7367
program test_malloc
7368
  implicit none
7369
  integer i
7370
  real*8 x(*), z
7371
  pointer(ptr_x,x)
7372
 
7373
  ptr_x = malloc(20*8)
7374
  do i = 1, 20
7375
    x(i) = sqrt(1.0d0 / i)
7376
  end do
7377
  z = 0
7378
  do i = 1, 20
7379
    z = z + x(i)
7380
    print *, z
7381
  end do
7382
  call free(ptr_x)
7383
end program test_malloc
7384
@end smallexample
7385
 
7386
@item @emph{See also}:
7387
@ref{FREE}
7388
@end table
7389
 
7390
 
7391
 
7392
@node MATMUL
7393
@section @code{MATMUL} --- matrix multiplication
7394
@fnindex MATMUL
7395
@cindex matrix multiplication
7396
@cindex product, matrix
7397
 
7398
@table @asis
7399
@item @emph{Description}:
7400
Performs a matrix multiplication on numeric or logical arguments.
7401
 
7402
@item @emph{Standard}:
7403
Fortran 95 and later
7404
 
7405
@item @emph{Class}:
7406
Transformational function
7407
 
7408
@item @emph{Syntax}:
7409
@code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
7410
 
7411
@item @emph{Arguments}:
7412
@multitable @columnfractions .15 .70
7413
@item @var{MATRIX_A} @tab An array of @code{INTEGER},
7414
@code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
7415
one or two.
7416
@item @var{MATRIX_B} @tab An array of @code{INTEGER},
7417
@code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
7418
type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
7419
or two, and the first (or only) dimension of @var{MATRIX_B} shall be
7420
equal to the last (or only) dimension of @var{MATRIX_A}.
7421
@end multitable
7422
 
7423
@item @emph{Return value}:
7424
The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
7425
kind of the result follow the usual type and kind promotion rules, as
7426
for the @code{*} or @code{.AND.} operators.
7427
 
7428
@item @emph{See also}:
7429
@end table
7430
 
7431
 
7432
 
7433
@node MAX
7434
@section @code{MAX} --- Maximum value of an argument list
7435
@fnindex MAX
7436
@fnindex MAX0
7437
@fnindex AMAX0
7438
@fnindex MAX1
7439
@fnindex AMAX1
7440
@fnindex DMAX1
7441
@cindex maximum value
7442
 
7443
@table @asis
7444
@item @emph{Description}:
7445
Returns the argument with the largest (most positive) value.
7446
 
7447
@item @emph{Standard}:
7448
Fortran 77 and later
7449
 
7450
@item @emph{Class}:
7451
Elemental function
7452
 
7453
@item @emph{Syntax}:
7454
@code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
7455
 
7456
@item @emph{Arguments}:
7457
@multitable @columnfractions .15 .70
7458
@item @var{A1}          @tab The type shall be @code{INTEGER} or
7459
@code{REAL}.
7460
@item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7461
as @var{A1}.  (As a GNU extension, arguments of different kinds are
7462
permitted.)
7463
@end multitable
7464
 
7465
@item @emph{Return value}:
7466
The return value corresponds to the maximum value among the arguments,
7467
and has the same type and kind as the first argument.
7468
 
7469
@item @emph{Specific names}:
7470
@multitable @columnfractions .20 .20 .20 .25
7471
@item Name             @tab Argument            @tab Return type         @tab Standard
7472
@item @code{MAX0(I)}   @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
7473
@item @code{AMAX0(I)}  @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
7474
@item @code{MAX1(X)}   @tab @code{REAL X}    @tab @code{INT(MAX(X))}  @tab Fortran 77 and later
7475
@item @code{AMAX1(X)}  @tab @code{REAL(4)    X} @tab @code{REAL(4)}      @tab Fortran 77 and later
7476
@item @code{DMAX1(X)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}      @tab Fortran 77 and later
7477
@end multitable
7478
 
7479
@item @emph{See also}:
7480
@ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
7481
 
7482
@end table
7483
 
7484
 
7485
 
7486
@node MAXEXPONENT
7487
@section @code{MAXEXPONENT} --- Maximum exponent of a real kind
7488
@fnindex MAXEXPONENT
7489
@cindex model representation, maximum exponent
7490
 
7491
@table @asis
7492
@item @emph{Description}:
7493
@code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
7494
type of @code{X}.
7495
 
7496
@item @emph{Standard}:
7497
Fortran 95 and later
7498
 
7499
@item @emph{Class}:
7500
Inquiry function
7501
 
7502
@item @emph{Syntax}:
7503
@code{RESULT = MAXEXPONENT(X)}
7504
 
7505
@item @emph{Arguments}:
7506
@multitable @columnfractions .15 .70
7507
@item @var{X} @tab Shall be of type @code{REAL}.
7508
@end multitable
7509
 
7510
@item @emph{Return value}:
7511
The return value is of type @code{INTEGER} and of the default integer
7512
kind.
7513
 
7514
@item @emph{Example}:
7515
@smallexample
7516
program exponents
7517
  real(kind=4) :: x
7518
  real(kind=8) :: y
7519
 
7520
  print *, minexponent(x), maxexponent(x)
7521
  print *, minexponent(y), maxexponent(y)
7522
end program exponents
7523
@end smallexample
7524
@end table
7525
 
7526
 
7527
 
7528
@node MAXLOC
7529
@section @code{MAXLOC} --- Location of the maximum value within an array
7530
@fnindex MAXLOC
7531
@cindex array, location of maximum element
7532
 
7533
@table @asis
7534
@item @emph{Description}:
7535
Determines the location of the element in the array with the maximum
7536
value, or, if the @var{DIM} argument is supplied, determines the
7537
locations of the maximum element along each row of the array in the
7538
@var{DIM} direction.  If @var{MASK} is present, only the elements for
7539
which @var{MASK} is @code{.TRUE.} are considered.  If more than one
7540
element in the array has the maximum value, the location returned is
7541
that of the first such element in array element order.  If the array has
7542
zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7543
the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
7544
and all of the elements of @var{MASK} along a given row are zero, the
7545
result value for that row is zero.
7546
 
7547
@item @emph{Standard}:
7548
Fortran 95 and later
7549
 
7550
@item @emph{Class}:
7551
Transformational function
7552
 
7553
@item @emph{Syntax}:
7554
@multitable @columnfractions .80
7555
@item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
7556
@item @code{RESULT = MAXLOC(ARRAY [, MASK])}
7557
@end multitable
7558
 
7559
@item @emph{Arguments}:
7560
@multitable @columnfractions .15 .70
7561
@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7562
@code{REAL}.
7563
@item @var{DIM}   @tab (Optional) Shall be a scalar of type
7564
@code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7565
inclusive.  It may not be an optional dummy argument.
7566
@item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7567
and conformable with @var{ARRAY}.
7568
@end multitable
7569
 
7570
@item @emph{Return value}:
7571
If @var{DIM} is absent, the result is a rank-one array with a length
7572
equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
7573
is an array with a rank one less than the rank of @var{ARRAY}, and a
7574
size corresponding to the size of @var{ARRAY} with the @var{DIM}
7575
dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
7576
of one, the result is a scalar.  In all cases, the result is of default
7577
@code{INTEGER} type.
7578
 
7579
@item @emph{See also}:
7580
@ref{MAX}, @ref{MAXVAL}
7581
 
7582
@end table
7583
 
7584
 
7585
 
7586
@node MAXVAL
7587
@section @code{MAXVAL} --- Maximum value of an array
7588
@fnindex MAXVAL
7589
@cindex array, maximum value
7590
@cindex maximum value
7591
 
7592
@table @asis
7593
@item @emph{Description}:
7594
Determines the maximum value of the elements in an array value, or, if
7595
the @var{DIM} argument is supplied, determines the maximum value along
7596
each row of the array in the @var{DIM} direction.  If @var{MASK} is
7597
present, only the elements for which @var{MASK} is @code{.TRUE.} are
7598
considered.  If the array has zero size, or all of the elements of
7599
@var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
7600
if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
7601
type.
7602
 
7603
@item @emph{Standard}:
7604
Fortran 95 and later
7605
 
7606
@item @emph{Class}:
7607
Transformational function
7608
 
7609
@item @emph{Syntax}:
7610
@multitable @columnfractions .80
7611
@item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
7612
@item @code{RESULT = MAXVAL(ARRAY [, MASK])}
7613
@end multitable
7614
 
7615
@item @emph{Arguments}:
7616
@multitable @columnfractions .15 .70
7617
@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7618
@code{REAL}.
7619
@item @var{DIM}   @tab (Optional) Shall be a scalar of type
7620
@code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7621
inclusive.  It may not be an optional dummy argument.
7622
@item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7623
and conformable with @var{ARRAY}.
7624
@end multitable
7625
 
7626
@item @emph{Return value}:
7627
If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7628
is a scalar.  If @var{DIM} is present, the result is an array with a
7629
rank one less than the rank of @var{ARRAY}, and a size corresponding to
7630
the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
7631
cases, the result is of the same type and kind as @var{ARRAY}.
7632
 
7633
@item @emph{See also}:
7634
@ref{MAX}, @ref{MAXLOC}
7635
@end table
7636
 
7637
 
7638
 
7639
@node MCLOCK
7640
@section @code{MCLOCK} --- Time function
7641
@fnindex MCLOCK
7642
@cindex time, clock ticks
7643
@cindex clock ticks
7644
 
7645
@table @asis
7646
@item @emph{Description}:
7647
Returns the number of clock ticks since the start of the process, based
7648
on the UNIX function @code{clock(3)}.
7649
 
7650
This intrinsic is not fully portable, such as to systems with 32-bit
7651
@code{INTEGER} types but supporting times wider than 32 bits. Therefore,
7652
the values returned by this intrinsic might be, or become, negative, or
7653
numerically less than previous values, during a single run of the
7654
compiled program.
7655
 
7656
@item @emph{Standard}:
7657
GNU extension
7658
 
7659
@item @emph{Class}:
7660
Function
7661
 
7662
@item @emph{Syntax}:
7663
@code{RESULT = MCLOCK()}
7664
 
7665
@item @emph{Return value}:
7666
The return value is a scalar of type @code{INTEGER(4)}, equal to the
7667
number of clock ticks since the start of the process, or @code{-1} if
7668
the system does not support @code{clock(3)}.
7669
 
7670
@item @emph{See also}:
7671
@ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
7672
 
7673
@end table
7674
 
7675
 
7676
 
7677
@node MCLOCK8
7678
@section @code{MCLOCK8} --- Time function (64-bit)
7679
@fnindex MCLOCK8
7680
@cindex time, clock ticks
7681
@cindex clock ticks
7682
 
7683
@table @asis
7684
@item @emph{Description}:
7685
Returns the number of clock ticks since the start of the process, based
7686
on the UNIX function @code{clock(3)}.
7687
 
7688
@emph{Warning:} this intrinsic does not increase the range of the timing
7689
values over that returned by @code{clock(3)}. On a system with a 32-bit
7690
@code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
7691
it is converted to a 64-bit @code{INTEGER(8)} value. That means
7692
overflows of the 32-bit value can still occur. Therefore, the values
7693
returned by this intrinsic might be or become negative or numerically
7694
less than previous values during a single run of the compiled program.
7695
 
7696
@item @emph{Standard}:
7697
GNU extension
7698
 
7699
@item @emph{Class}:
7700
Function
7701
 
7702
@item @emph{Syntax}:
7703
@code{RESULT = MCLOCK8()}
7704
 
7705
@item @emph{Return value}:
7706
The return value is a scalar of type @code{INTEGER(8)}, equal to the
7707
number of clock ticks since the start of the process, or @code{-1} if
7708
the system does not support @code{clock(3)}.
7709
 
7710
@item @emph{See also}:
7711
@ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
7712
 
7713
@end table
7714
 
7715
 
7716
 
7717
@node MERGE
7718
@section @code{MERGE} --- Merge variables
7719
@fnindex MERGE
7720
@cindex array, merge arrays
7721
@cindex array, combine arrays
7722
 
7723
@table @asis
7724
@item @emph{Description}:
7725
Select values from two arrays according to a logical mask.  The result
7726
is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
7727
@var{FSOURCE} if it is @code{.FALSE.}.
7728
 
7729
@item @emph{Standard}:
7730
Fortran 95 and later
7731
 
7732
@item @emph{Class}:
7733
Elemental function
7734
 
7735
@item @emph{Syntax}:
7736
@code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
7737
 
7738
@item @emph{Arguments}:
7739
@multitable @columnfractions .15 .70
7740
@item @var{TSOURCE} @tab May be of any type.
7741
@item @var{FSOURCE} @tab Shall be of the same type and type parameters
7742
as @var{TSOURCE}.
7743
@item @var{MASK}    @tab Shall be of type @code{LOGICAL}.
7744
@end multitable
7745
 
7746
@item @emph{Return value}:
7747
The result is of the same type and type parameters as @var{TSOURCE}.
7748
 
7749
@end table
7750
 
7751
 
7752
 
7753
@node MIN
7754
@section @code{MIN} --- Minimum value of an argument list
7755
@fnindex MIN
7756
@fnindex MIN0
7757
@fnindex AMIN0
7758
@fnindex MIN1
7759
@fnindex AMIN1
7760
@fnindex DMIN1
7761
@cindex minimum value
7762
 
7763
@table @asis
7764
@item @emph{Description}:
7765
Returns the argument with the smallest (most negative) value.
7766
 
7767
@item @emph{Standard}:
7768
Fortran 77 and later
7769
 
7770
@item @emph{Class}:
7771
Elemental function
7772
 
7773
@item @emph{Syntax}:
7774
@code{RESULT = MIN(A1, A2 [, A3, ...])}
7775
 
7776
@item @emph{Arguments}:
7777
@multitable @columnfractions .15 .70
7778
@item @var{A1}          @tab The type shall be @code{INTEGER} or
7779
@code{REAL}.
7780
@item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7781
as @var{A1}.  (As a GNU extension, arguments of different kinds are
7782
permitted.)
7783
@end multitable
7784
 
7785
@item @emph{Return value}:
7786
The return value corresponds to the maximum value among the arguments,
7787
and has the same type and kind as the first argument.
7788
 
7789
@item @emph{Specific names}:
7790
@multitable @columnfractions .20 .20 .20 .25
7791
@item Name             @tab Argument            @tab Return type         @tab Standard
7792
@item @code{MIN0(I)}   @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
7793
@item @code{AMIN0(I)}  @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab Fortran 77 and later
7794
@item @code{MIN1(X)}   @tab @code{REAL X}    @tab @code{INT(MIN(X))}  @tab Fortran 77 and later
7795
@item @code{AMIN1(X)}  @tab @code{REAL(4)    X} @tab @code{REAL(4)}      @tab Fortran 77 and later
7796
@item @code{DMIN1(X)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}      @tab Fortran 77 and later
7797
@end multitable
7798
 
7799
@item @emph{See also}:
7800
@ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
7801
@end table
7802
 
7803
 
7804
 
7805
@node MINEXPONENT
7806
@section @code{MINEXPONENT} --- Minimum exponent of a real kind
7807
@fnindex MINEXPONENT
7808
@cindex model representation, minimum exponent
7809
 
7810
@table @asis
7811
@item @emph{Description}:
7812
@code{MINEXPONENT(X)} returns the minimum exponent in the model of the
7813
type of @code{X}.
7814
 
7815
@item @emph{Standard}:
7816
Fortran 95 and later
7817
 
7818
@item @emph{Class}:
7819
Inquiry function
7820
 
7821
@item @emph{Syntax}:
7822
@code{RESULT = MINEXPONENT(X)}
7823
 
7824
@item @emph{Arguments}:
7825
@multitable @columnfractions .15 .70
7826
@item @var{X} @tab Shall be of type @code{REAL}.
7827
@end multitable
7828
 
7829
@item @emph{Return value}:
7830
The return value is of type @code{INTEGER} and of the default integer
7831
kind.
7832
 
7833
@item @emph{Example}:
7834
See @code{MAXEXPONENT} for an example.
7835
@end table
7836
 
7837
 
7838
 
7839
@node MINLOC
7840
@section @code{MINLOC} --- Location of the minimum value within an array
7841
@fnindex MINLOC
7842
@cindex array, location of minimum element
7843
 
7844
@table @asis
7845
@item @emph{Description}:
7846
Determines the location of the element in the array with the minimum
7847
value, or, if the @var{DIM} argument is supplied, determines the
7848
locations of the minimum element along each row of the array in the
7849
@var{DIM} direction.  If @var{MASK} is present, only the elements for
7850
which @var{MASK} is @code{.TRUE.} are considered.  If more than one
7851
element in the array has the minimum value, the location returned is
7852
that of the first such element in array element order.  If the array has
7853
zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7854
the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
7855
and all of the elements of @var{MASK} along a given row are zero, the
7856
result value for that row is zero.
7857
 
7858
@item @emph{Standard}:
7859
Fortran 95 and later
7860
 
7861
@item @emph{Class}:
7862
Transformational function
7863
 
7864
@item @emph{Syntax}:
7865
@multitable @columnfractions .80
7866
@item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
7867
@item @code{RESULT = MINLOC(ARRAY [, MASK])}
7868
@end multitable
7869
 
7870
@item @emph{Arguments}:
7871
@multitable @columnfractions .15 .70
7872
@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7873
@code{REAL}.
7874
@item @var{DIM}   @tab (Optional) Shall be a scalar of type
7875
@code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7876
inclusive.  It may not be an optional dummy argument.
7877
@item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7878
and conformable with @var{ARRAY}.
7879
@end multitable
7880
 
7881
@item @emph{Return value}:
7882
If @var{DIM} is absent, the result is a rank-one array with a length
7883
equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
7884
is an array with a rank one less than the rank of @var{ARRAY}, and a
7885
size corresponding to the size of @var{ARRAY} with the @var{DIM}
7886
dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
7887
of one, the result is a scalar.  In all cases, the result is of default
7888
@code{INTEGER} type.
7889
 
7890
@item @emph{See also}:
7891
@ref{MIN}, @ref{MINVAL}
7892
 
7893
@end table
7894
 
7895
 
7896
 
7897
@node MINVAL
7898
@section @code{MINVAL} --- Minimum value of an array
7899
@fnindex MINVAL
7900
@cindex array, minimum value
7901
@cindex minimum value
7902
 
7903
@table @asis
7904
@item @emph{Description}:
7905
Determines the minimum value of the elements in an array value, or, if
7906
the @var{DIM} argument is supplied, determines the minimum value along
7907
each row of the array in the @var{DIM} direction.  If @var{MASK} is
7908
present, only the elements for which @var{MASK} is @code{.TRUE.} are
7909
considered.  If the array has zero size, or all of the elements of
7910
@var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
7911
@var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
7912
@var{ARRAY} is of character type.
7913
 
7914
@item @emph{Standard}:
7915
Fortran 95 and later
7916
 
7917
@item @emph{Class}:
7918
Transformational function
7919
 
7920
@item @emph{Syntax}:
7921
@multitable @columnfractions .80
7922
@item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
7923
@item @code{RESULT = MINVAL(ARRAY [, MASK])}
7924
@end multitable
7925
 
7926
@item @emph{Arguments}:
7927
@multitable @columnfractions .15 .70
7928
@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7929
@code{REAL}.
7930
@item @var{DIM}   @tab (Optional) Shall be a scalar of type
7931
@code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7932
inclusive.  It may not be an optional dummy argument.
7933
@item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7934
and conformable with @var{ARRAY}.
7935
@end multitable
7936
 
7937
@item @emph{Return value}:
7938
If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7939
is a scalar.  If @var{DIM} is present, the result is an array with a
7940
rank one less than the rank of @var{ARRAY}, and a size corresponding to
7941
the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
7942
cases, the result is of the same type and kind as @var{ARRAY}.
7943
 
7944
@item @emph{See also}:
7945
@ref{MIN}, @ref{MINLOC}
7946
 
7947
@end table
7948
 
7949
 
7950
 
7951
@node MOD
7952
@section @code{MOD} --- Remainder function
7953
@fnindex MOD
7954
@fnindex AMOD
7955
@fnindex DMOD
7956
@cindex remainder
7957
@cindex division, remainder
7958
 
7959
@table @asis
7960
@item @emph{Description}:
7961
@code{MOD(A,P)} computes the remainder of the division of A by P@. It is
7962
calculated as @code{A - (INT(A/P) * P)}.
7963
 
7964
@item @emph{Standard}:
7965
Fortran 77 and later
7966
 
7967
@item @emph{Class}:
7968
Elemental function
7969
 
7970
@item @emph{Syntax}:
7971
@code{RESULT = MOD(A, P)}
7972
 
7973
@item @emph{Arguments}:
7974
@multitable @columnfractions .15 .70
7975
@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7976
@item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
7977
equal to zero
7978
@end multitable
7979
 
7980
@item @emph{Return value}:
7981
The kind of the return value is the result of cross-promoting
7982
the kinds of the arguments.
7983
 
7984
@item @emph{Example}:
7985
@smallexample
7986
program test_mod
7987
  print *, mod(17,3)
7988
  print *, mod(17.5,5.5)
7989
  print *, mod(17.5d0,5.5)
7990
  print *, mod(17.5,5.5d0)
7991
 
7992
  print *, mod(-17,3)
7993
  print *, mod(-17.5,5.5)
7994
  print *, mod(-17.5d0,5.5)
7995
  print *, mod(-17.5,5.5d0)
7996
 
7997
  print *, mod(17,-3)
7998
  print *, mod(17.5,-5.5)
7999
  print *, mod(17.5d0,-5.5)
8000
  print *, mod(17.5,-5.5d0)
8001
end program test_mod
8002
@end smallexample
8003
 
8004
@item @emph{Specific names}:
8005
@multitable @columnfractions .20 .20 .20 .25
8006
@item Name             @tab Arguments      @tab Return type    @tab Standard
8007
@item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab Fortran 95 and later
8008
@item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab Fortran 95 and later
8009
@end multitable
8010
@end table
8011
 
8012
 
8013
 
8014
@node MODULO
8015
@section @code{MODULO} --- Modulo function
8016
@fnindex MODULO
8017
@cindex modulo
8018
@cindex division, modulo
8019
 
8020
@table @asis
8021
@item @emph{Description}:
8022
@code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
8023
 
8024
@item @emph{Standard}:
8025
Fortran 95 and later
8026
 
8027
@item @emph{Class}:
8028
Elemental function
8029
 
8030
@item @emph{Syntax}:
8031
@code{RESULT = MODULO(A, P)}
8032
 
8033
@item @emph{Arguments}:
8034
@multitable @columnfractions .15 .70
8035
@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8036
@item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
8037
@end multitable
8038
 
8039
@item @emph{Return value}:
8040
The type and kind of the result are those of the arguments.
8041
@table @asis
8042
@item If @var{A} and @var{P} are of type @code{INTEGER}:
8043
@code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
8044
@var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
8045
(exclusive).
8046
@item If @var{A} and @var{P} are of type @code{REAL}:
8047
@code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
8048
@end table
8049
In all cases, if @var{P} is zero the result is processor-dependent.
8050
 
8051
@item @emph{Example}:
8052
@smallexample
8053
program test_modulo
8054
  print *, modulo(17,3)
8055
  print *, modulo(17.5,5.5)
8056
 
8057
  print *, modulo(-17,3)
8058
  print *, modulo(-17.5,5.5)
8059
 
8060
  print *, modulo(17,-3)
8061
  print *, modulo(17.5,-5.5)
8062
end program
8063
@end smallexample
8064
 
8065
@end table
8066
 
8067
 
8068
 
8069
@node MOVE_ALLOC
8070
@section @code{MOVE_ALLOC} --- Move allocation from one object to another
8071
@fnindex MOVE_ALLOC
8072
@cindex moving allocation
8073
@cindex allocation, moving
8074
 
8075
@table @asis
8076
@item @emph{Description}:
8077
@code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
8078
@var{TO}.  @var{FROM} will become deallocated in the process.
8079
 
8080
@item @emph{Standard}:
8081
Fortran 2003 and later
8082
 
8083
@item @emph{Class}:
8084
Subroutine
8085
 
8086
@item @emph{Syntax}:
8087
@code{CALL MOVE_ALLOC(FROM, TO)}
8088
 
8089
@item @emph{Arguments}:
8090
@multitable @columnfractions .15 .70
8091
@item @var{FROM}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
8092
of any type and kind.
8093
@item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
8094
of the same type, kind and rank as @var{FROM}.
8095
@end multitable
8096
 
8097
@item @emph{Return value}:
8098
None
8099
 
8100
@item @emph{Example}:
8101
@smallexample
8102
program test_move_alloc
8103
    integer, allocatable :: a(:), b(:)
8104
 
8105
    allocate(a(3))
8106
    a = [ 1, 2, 3 ]
8107
    call move_alloc(a, b)
8108
    print *, allocated(a), allocated(b)
8109
    print *, b
8110
end program test_move_alloc
8111
@end smallexample
8112
@end table
8113
 
8114
 
8115
 
8116
@node MVBITS
8117
@section @code{MVBITS} --- Move bits from one integer to another
8118
@fnindex MVBITS
8119
@cindex bits, move
8120
 
8121
@table @asis
8122
@item @emph{Description}:
8123
Moves @var{LEN} bits from positions @var{FROMPOS} through
8124
@code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
8125
@code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
8126
affected by the movement of bits is unchanged. The values of
8127
@code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
8128
@code{BIT_SIZE(FROM)}.
8129
 
8130
@item @emph{Standard}:
8131
Fortran 95 and later
8132
 
8133
@item @emph{Class}:
8134
Elemental subroutine
8135
 
8136
@item @emph{Syntax}:
8137
@code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
8138
 
8139
@item @emph{Arguments}:
8140
@multitable @columnfractions .15 .70
8141
@item @var{FROM}    @tab The type shall be @code{INTEGER}.
8142
@item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
8143
@item @var{LEN}     @tab The type shall be @code{INTEGER}.
8144
@item @var{TO}      @tab The type shall be @code{INTEGER}, of the
8145
same kind as @var{FROM}.
8146
@item @var{TOPOS}   @tab The type shall be @code{INTEGER}.
8147
@end multitable
8148
 
8149
@item @emph{See also}:
8150
@ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
8151
@end table
8152
 
8153
 
8154
 
8155
@node NEAREST
8156
@section @code{NEAREST} --- Nearest representable number
8157
@fnindex NEAREST
8158
@cindex real number, nearest different
8159
@cindex floating point, nearest different
8160
 
8161
@table @asis
8162
@item @emph{Description}:
8163
@code{NEAREST(X, S)} returns the processor-representable number nearest
8164
to @code{X} in the direction indicated by the sign of @code{S}.
8165
 
8166
@item @emph{Standard}:
8167
Fortran 95 and later
8168
 
8169
@item @emph{Class}:
8170
Elemental function
8171
 
8172
@item @emph{Syntax}:
8173
@code{RESULT = NEAREST(X, S)}
8174
 
8175
@item @emph{Arguments}:
8176
@multitable @columnfractions .15 .70
8177
@item @var{X} @tab Shall be of type @code{REAL}.
8178
@item @var{S} @tab (Optional) shall be of type @code{REAL} and
8179
not equal to zero.
8180
@end multitable
8181
 
8182
@item @emph{Return value}:
8183
The return value is of the same type as @code{X}. If @code{S} is
8184
positive, @code{NEAREST} returns the processor-representable number
8185
greater than @code{X} and nearest to it. If @code{S} is negative,
8186
@code{NEAREST} returns the processor-representable number smaller than
8187
@code{X} and nearest to it.
8188
 
8189
@item @emph{Example}:
8190
@smallexample
8191
program test_nearest
8192
  real :: x, y
8193
  x = nearest(42.0, 1.0)
8194
  y = nearest(42.0, -1.0)
8195
  write (*,"(3(G20.15))") x, y, x - y
8196
end program test_nearest
8197
@end smallexample
8198
@end table
8199
 
8200
 
8201
 
8202
@node NEW_LINE
8203
@section @code{NEW_LINE} --- New line character
8204
@fnindex NEW_LINE
8205
@cindex newline
8206
@cindex output, newline
8207
 
8208
@table @asis
8209
@item @emph{Description}:
8210
@code{NEW_LINE(C)} returns the new-line character.
8211
 
8212
@item @emph{Standard}:
8213
Fortran 2003 and later
8214
 
8215
@item @emph{Class}:
8216
Inquiry function
8217
 
8218
@item @emph{Syntax}:
8219
@code{RESULT = NEW_LINE(C)}
8220
 
8221
@item @emph{Arguments}:
8222
@multitable @columnfractions .15 .70
8223
@item @var{C}    @tab The argument shall be a scalar or array of the
8224
type @code{CHARACTER}.
8225
@end multitable
8226
 
8227
@item @emph{Return value}:
8228
Returns a @var{CHARACTER} scalar of length one with the new-line character of
8229
the same kind as parameter @var{C}.
8230
 
8231
@item @emph{Example}:
8232
@smallexample
8233
program newline
8234
  implicit none
8235
  write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
8236
end program newline
8237
@end smallexample
8238
@end table
8239
 
8240
 
8241
 
8242
@node NINT
8243
@section @code{NINT} --- Nearest whole number
8244
@fnindex NINT
8245
@fnindex IDNINT
8246
@cindex rounding, nearest whole number
8247
 
8248
@table @asis
8249
@item @emph{Description}:
8250
@code{NINT(A)} rounds its argument to the nearest whole number.
8251
 
8252
@item @emph{Standard}:
8253
Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
8254
 
8255
@item @emph{Class}:
8256
Elemental function
8257
 
8258
@item @emph{Syntax}:
8259
@code{RESULT = NINT(A [, KIND])}
8260
 
8261
@item @emph{Arguments}:
8262
@multitable @columnfractions .15 .70
8263
@item @var{A}    @tab The type of the argument shall be @code{REAL}.
8264
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8265
expression indicating the kind parameter of the result.
8266
@end multitable
8267
 
8268
@item @emph{Return value}:
8269
Returns @var{A} with the fractional portion of its magnitude eliminated by
8270
rounding to the nearest whole number and with its sign preserved,
8271
converted to an @code{INTEGER} of the default kind.
8272
 
8273
@item @emph{Example}:
8274
@smallexample
8275
program test_nint
8276
  real(4) x4
8277
  real(8) x8
8278
  x4 = 1.234E0_4
8279
  x8 = 4.321_8
8280
  print *, nint(x4), idnint(x8)
8281
end program test_nint
8282
@end smallexample
8283
 
8284
@item @emph{Specific names}:
8285
@multitable @columnfractions .25 .25 .25
8286
@item Name             @tab Argument         @tab Standard
8287
@item @code{IDNINT(X)} @tab @code{REAL(8)}   @tab Fortran 95 and later
8288
@end multitable
8289
 
8290
@item @emph{See also}:
8291
@ref{CEILING}, @ref{FLOOR}
8292
 
8293
@end table
8294
 
8295
 
8296
 
8297
@node NOT
8298
@section @code{NOT} --- Logical negation
8299
@fnindex NOT
8300
@cindex bits, negate
8301
@cindex bitwise logical not
8302
@cindex logical not, bitwise
8303
 
8304
@table @asis
8305
@item @emph{Description}:
8306
@code{NOT} returns the bitwise boolean inverse of @var{I}.
8307
 
8308
@item @emph{Standard}:
8309
Fortran 95 and later
8310
 
8311
@item @emph{Class}:
8312
Elemental function
8313
 
8314
@item @emph{Syntax}:
8315
@code{RESULT = NOT(I)}
8316
 
8317
@item @emph{Arguments}:
8318
@multitable @columnfractions .15 .70
8319
@item @var{I} @tab The type shall be @code{INTEGER}.
8320
@end multitable
8321
 
8322
@item @emph{Return value}:
8323
The return type is @code{INTEGER}, of the same kind as the
8324
argument.
8325
 
8326
@item @emph{See also}:
8327
@ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
8328
 
8329
@end table
8330
 
8331
 
8332
 
8333
@node NULL
8334
@section @code{NULL} --- Function that returns an disassociated pointer
8335
@fnindex NULL
8336
@cindex pointer, status
8337
@cindex pointer, disassociated
8338
 
8339
@table @asis
8340
@item @emph{Description}:
8341
Returns a disassociated pointer.
8342
 
8343
If @var{MOLD} is present, a dissassociated pointer of the same type is
8344
returned, otherwise the type is determined by context.
8345
 
8346
In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
8347
includes cases where it is required.
8348
 
8349
@item @emph{Standard}:
8350
Fortran 95 and later
8351
 
8352
@item @emph{Class}:
8353
Transformational function
8354
 
8355
@item @emph{Syntax}:
8356
@code{PTR => NULL([MOLD])}
8357
 
8358
@item @emph{Arguments}:
8359
@multitable @columnfractions .15 .70
8360
@item @var{MOLD} @tab (Optional) shall be a pointer of any association
8361
status and of any type.
8362
@end multitable
8363
 
8364
@item @emph{Return value}:
8365
A disassociated pointer.
8366
 
8367
@item @emph{Example}:
8368
@smallexample
8369
REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
8370
@end smallexample
8371
 
8372
@item @emph{See also}:
8373
@ref{ASSOCIATED}
8374
@end table
8375
 
8376
 
8377
 
8378
@node OR
8379
@section @code{OR} --- Bitwise logical OR
8380
@fnindex OR
8381
@cindex bitwise logical or
8382
@cindex logical or, bitwise
8383
 
8384
@table @asis
8385
@item @emph{Description}:
8386
Bitwise logical @code{OR}.
8387
 
8388
This intrinsic routine is provided for backwards compatibility with
8389
GNU Fortran 77.  For integer arguments, programmers should consider
8390
the use of the @ref{IOR} intrinsic defined by the Fortran standard.
8391
 
8392
@item @emph{Standard}:
8393
GNU extension
8394
 
8395
@item @emph{Class}:
8396
Function
8397
 
8398
@item @emph{Syntax}:
8399
@code{RESULT = OR(I, J)}
8400
 
8401
@item @emph{Arguments}:
8402
@multitable @columnfractions .15 .70
8403
@item @var{I} @tab The type shall be either a scalar @code{INTEGER}
8404
type or a scalar @code{LOGICAL} type.
8405
@item @var{J} @tab The type shall be the same as the type of @var{J}.
8406
@end multitable
8407
 
8408
@item @emph{Return value}:
8409
The return type is either a scalar @code{INTEGER} or a scalar
8410
@code{LOGICAL}.  If the kind type parameters differ, then the
8411
smaller kind type is implicitly converted to larger kind, and the
8412
return has the larger kind.
8413
 
8414
@item @emph{Example}:
8415
@smallexample
8416
PROGRAM test_or
8417
  LOGICAL :: T = .TRUE., F = .FALSE.
8418
  INTEGER :: a, b
8419
  DATA a / Z'F' /, b / Z'3' /
8420
 
8421
  WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
8422
  WRITE (*,*) OR(a, b)
8423
END PROGRAM
8424
@end smallexample
8425
 
8426
@item @emph{See also}:
8427
Fortran 95 elemental function: @ref{IOR}
8428
@end table
8429
 
8430
 
8431
 
8432
@node PACK
8433
@section @code{PACK} --- Pack an array into an array of rank one
8434
@fnindex PACK
8435
@cindex array, packing
8436
@cindex array, reduce dimension
8437
@cindex array, gather elements
8438
 
8439
@table @asis
8440
@item @emph{Description}:
8441
Stores the elements of @var{ARRAY} in an array of rank one.
8442
 
8443
The beginning of the resulting array is made up of elements whose @var{MASK}
8444
equals @code{TRUE}. Afterwards, positions are filled with elements taken from
8445
@var{VECTOR}.
8446
 
8447
@item @emph{Standard}:
8448
Fortran 95 and later
8449
 
8450
@item @emph{Class}:
8451
Transformational function
8452
 
8453
@item @emph{Syntax}:
8454
@code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
8455
 
8456
@item @emph{Arguments}:
8457
@multitable @columnfractions .15 .70
8458
@item @var{ARRAY}  @tab Shall be an array of any type.
8459
@item @var{MASK}   @tab Shall be an array of type @code{LOGICAL} and
8460
of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
8461
scalar.
8462
@item @var{VECTOR} @tab (Optional) shall be an array of the same type
8463
as @var{ARRAY} and of rank one. If present, the number of elements in
8464
@var{VECTOR} shall be equal to or greater than the number of true elements
8465
in @var{MASK}. If @var{MASK} is scalar, the number of elements in
8466
@var{VECTOR} shall be equal to or greater than the number of elements in
8467
@var{ARRAY}.
8468
@end multitable
8469
 
8470
@item @emph{Return value}:
8471
The result is an array of rank one and the same type as that of @var{ARRAY}.
8472
If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
8473
number of @code{TRUE} values in @var{MASK} otherwise.
8474
 
8475
@item @emph{Example}:
8476
Gathering nonzero elements from an array:
8477
@smallexample
8478
PROGRAM test_pack_1
8479
  INTEGER :: m(6)
8480
  m = (/ 1, 0, 0, 0, 5, 0 /)
8481
  WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0)  ! "1 5"
8482
END PROGRAM
8483
@end smallexample
8484
 
8485
Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
8486
@smallexample
8487
PROGRAM test_pack_2
8488
  INTEGER :: m(4)
8489
  m = (/ 1, 0, 0, 2 /)
8490
  WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))  ! "1 2 3 4"
8491
END PROGRAM
8492
@end smallexample
8493
 
8494
@item @emph{See also}:
8495
@ref{UNPACK}
8496
@end table
8497
 
8498
 
8499
 
8500
@node PERROR
8501
@section @code{PERROR} --- Print system error message
8502
@fnindex PERROR
8503
@cindex system, error handling
8504
 
8505
@table @asis
8506
@item @emph{Description}:
8507
Prints (on the C @code{stderr} stream) a newline-terminated error
8508
message corresponding to the last system error. This is prefixed by
8509
@var{STRING}, a colon and a space. See @code{perror(3)}.
8510
 
8511
@item @emph{Standard}:
8512
GNU extension
8513
 
8514
@item @emph{Class}:
8515
Subroutine
8516
 
8517
@item @emph{Syntax}:
8518
@code{CALL PERROR(STRING)}
8519
 
8520
@item @emph{Arguments}:
8521
@multitable @columnfractions .15 .70
8522
@item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
8523
default kind.
8524
@end multitable
8525
 
8526
@item @emph{See also}:
8527
@ref{IERRNO}
8528
@end table
8529
 
8530
 
8531
 
8532
@node PRECISION
8533
@section @code{PRECISION} --- Decimal precision of a real kind
8534
@fnindex PRECISION
8535
@cindex model representation, precision
8536
 
8537
@table @asis
8538
@item @emph{Description}:
8539
@code{PRECISION(X)} returns the decimal precision in the model of the
8540
type of @code{X}.
8541
 
8542
@item @emph{Standard}:
8543
Fortran 95 and later
8544
 
8545
@item @emph{Class}:
8546
Inquiry function
8547
 
8548
@item @emph{Syntax}:
8549
@code{RESULT = PRECISION(X)}
8550
 
8551
@item @emph{Arguments}:
8552
@multitable @columnfractions .15 .70
8553
@item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8554
@end multitable
8555
 
8556
@item @emph{Return value}:
8557
The return value is of type @code{INTEGER} and of the default integer
8558
kind.
8559
 
8560
@item @emph{Example}:
8561
@smallexample
8562
program prec_and_range
8563
  real(kind=4) :: x(2)
8564
  complex(kind=8) :: y
8565
 
8566
  print *, precision(x), range(x)
8567
  print *, precision(y), range(y)
8568
end program prec_and_range
8569
@end smallexample
8570
@end table
8571
 
8572
 
8573
 
8574
@node PRESENT
8575
@section @code{PRESENT} --- Determine whether an optional dummy argument is specified
8576
@fnindex PRESENT
8577
 
8578
@table @asis
8579
@item @emph{Description}:
8580
Determines whether an optional dummy argument is present.
8581
 
8582
@item @emph{Standard}:
8583
Fortran 95 and later
8584
 
8585
@item @emph{Class}:
8586
Inquiry function
8587
 
8588
@item @emph{Syntax}:
8589
@code{RESULT = PRESENT(A)}
8590
 
8591
@item @emph{Arguments}:
8592
@multitable @columnfractions .15 .70
8593
@item @var{A} @tab May be of any type and may be a pointer, scalar or array
8594
value, or a dummy procedure. It shall be the name of an optional dummy argument
8595
accessible within the current subroutine or function.
8596
@end multitable
8597
 
8598
@item @emph{Return value}:
8599
Returns either @code{TRUE} if the optional argument @var{A} is present, or
8600
@code{FALSE} otherwise.
8601
 
8602
@item @emph{Example}:
8603
@smallexample
8604
PROGRAM test_present
8605
  WRITE(*,*) f(), f(42)      ! "F T"
8606
CONTAINS
8607
  LOGICAL FUNCTION f(x)
8608
    INTEGER, INTENT(IN), OPTIONAL :: x
8609
    f = PRESENT(x)
8610
  END FUNCTION
8611
END PROGRAM
8612
@end smallexample
8613
@end table
8614
 
8615
 
8616
 
8617
@node PRODUCT
8618
@section @code{PRODUCT} --- Product of array elements
8619
@fnindex PRODUCT
8620
@cindex array, product
8621
@cindex array, multiply elements
8622
@cindex array, conditionally multiply elements
8623
@cindex multiply array elements
8624
 
8625
@table @asis
8626
@item @emph{Description}:
8627
Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
8628
the corresponding element in @var{MASK} is @code{TRUE}.
8629
 
8630
@item @emph{Standard}:
8631
Fortran 95 and later
8632
 
8633
@item @emph{Class}:
8634
Transformational function
8635
 
8636
@item @emph{Syntax}:
8637
@multitable @columnfractions .80
8638
@item @code{RESULT = PRODUCT(ARRAY[, MASK])}
8639
@item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
8640
@end multitable
8641
 
8642
@item @emph{Arguments}:
8643
@multitable @columnfractions .15 .70
8644
@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
8645
@code{REAL} or @code{COMPLEX}.
8646
@item @var{DIM}   @tab (Optional) shall be a scalar of type
8647
@code{INTEGER} with a value in the range from 1 to n, where n
8648
equals the rank of @var{ARRAY}.
8649
@item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL}
8650
and either be a scalar or an array of the same shape as @var{ARRAY}.
8651
@end multitable
8652
 
8653
@item @emph{Return value}:
8654
The result is of the same type as @var{ARRAY}.
8655
 
8656
If @var{DIM} is absent, a scalar with the product of all elements in
8657
@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
8658
the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
8659
dimension @var{DIM} dropped is returned.
8660
 
8661
 
8662
@item @emph{Example}:
8663
@smallexample
8664
PROGRAM test_product
8665
  INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
8666
  print *, PRODUCT(x)                    ! all elements, product = 120
8667
  print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
8668
END PROGRAM
8669
@end smallexample
8670
 
8671
@item @emph{See also}:
8672
@ref{SUM}
8673
@end table
8674
 
8675
 
8676
 
8677
@node RADIX
8678
@section @code{RADIX} --- Base of a model number
8679
@fnindex RADIX
8680
@cindex model representation, base
8681
@cindex model representation, radix
8682
 
8683
@table @asis
8684
@item @emph{Description}:
8685
@code{RADIX(X)} returns the base of the model representing the entity @var{X}.
8686
 
8687
@item @emph{Standard}:
8688
Fortran 95 and later
8689
 
8690
@item @emph{Class}:
8691
Inquiry function
8692
 
8693
@item @emph{Syntax}:
8694
@code{RESULT = RADIX(X)}
8695
 
8696
@item @emph{Arguments}:
8697
@multitable @columnfractions .15 .70
8698
@item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
8699
@end multitable
8700
 
8701
@item @emph{Return value}:
8702
The return value is a scalar of type @code{INTEGER} and of the default
8703
integer kind.
8704
 
8705
@item @emph{Example}:
8706
@smallexample
8707
program test_radix
8708
  print *, "The radix for the default integer kind is", radix(0)
8709
  print *, "The radix for the default real kind is", radix(0.0)
8710
end program test_radix
8711
@end smallexample
8712
 
8713
@end table
8714
 
8715
 
8716
 
8717
@node RAN
8718
@section @code{RAN} --- Real pseudo-random number
8719
@fnindex RAN
8720
@cindex random number generation
8721
 
8722
@table @asis
8723
@item @emph{Description}:
8724
For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
8725
provided as an alias for @code{RAND}.  See @ref{RAND} for complete
8726
documentation.
8727
 
8728
@item @emph{Standard}:
8729
GNU extension
8730
 
8731
@item @emph{Class}:
8732
Function
8733
 
8734
@item @emph{See also}:
8735
@ref{RAND}, @ref{RANDOM_NUMBER}
8736
@end table
8737
 
8738
 
8739
 
8740
@node RAND
8741
@section @code{RAND} --- Real pseudo-random number
8742
@fnindex RAND
8743
@cindex random number generation
8744
 
8745
@table @asis
8746
@item @emph{Description}:
8747
@code{RAND(FLAG)} returns a pseudo-random number from a uniform
8748
distribution between 0 and 1. If @var{FLAG} is 0, the next number
8749
in the current sequence is returned; if @var{FLAG} is 1, the generator
8750
is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8751
it is used as a new seed with @code{SRAND}.
8752
 
8753
This intrinsic routine is provided for backwards compatibility with
8754
GNU Fortran 77. It implements a simple modulo generator as provided
8755
by @command{g77}. For new code, one should consider the use of
8756
@ref{RANDOM_NUMBER} as it implements a superior algorithm.
8757
 
8758
@item @emph{Standard}:
8759
GNU extension
8760
 
8761
@item @emph{Class}:
8762
Function
8763
 
8764
@item @emph{Syntax}:
8765
@code{RESULT = RAND(I)}
8766
 
8767
@item @emph{Arguments}:
8768
@multitable @columnfractions .15 .70
8769
@item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
8770
@end multitable
8771
 
8772
@item @emph{Return value}:
8773
The return value is of @code{REAL} type and the default kind.
8774
 
8775
@item @emph{Example}:
8776
@smallexample
8777
program test_rand
8778
  integer,parameter :: seed = 86456
8779
 
8780
  call srand(seed)
8781
  print *, rand(), rand(), rand(), rand()
8782
  print *, rand(seed), rand(), rand(), rand()
8783
end program test_rand
8784
@end smallexample
8785
 
8786
@item @emph{See also}:
8787
@ref{SRAND}, @ref{RANDOM_NUMBER}
8788
 
8789
@end table
8790
 
8791
 
8792
 
8793
@node RANDOM_NUMBER
8794
@section @code{RANDOM_NUMBER} --- Pseudo-random number
8795
@fnindex RANDOM_NUMBER
8796
@cindex random number generation
8797
 
8798
@table @asis
8799
@item @emph{Description}:
8800
Returns a single pseudorandom number or an array of pseudorandom numbers
8801
from the uniform distribution over the range @math{ 0 \leq x < 1}.
8802
 
8803
The runtime-library implements George Marsaglia's KISS (Keep It Simple
8804
Stupid) random number generator (RNG). This RNG combines:
8805
@enumerate
8806
@item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
8807
with a period of @math{2^{32}},
8808
@item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
8809
@item  Two 16-bit multiply-with-carry generators with a period of
8810
@math{597273182964842497 > 2^{59}}.
8811
@end enumerate
8812
The overall period exceeds @math{2^{123}}.
8813
 
8814
Please note, this RNG is thread safe if used within OpenMP directives,
8815
i.e., its state will be consistent while called from multiple threads.
8816
However, the KISS generator does not create random numbers in parallel
8817
from multiple sources, but in sequence from a single source. If an
8818
OpenMP-enabled application heavily relies on random numbers, one should
8819
consider employing a dedicated parallel random number generator instead.
8820
 
8821
@item @emph{Standard}:
8822
Fortran 95 and later
8823
 
8824
@item @emph{Class}:
8825
Subroutine
8826
 
8827
@item @emph{Syntax}:
8828
@code{RANDOM_NUMBER(HARVEST)}
8829
 
8830
@item @emph{Arguments}:
8831
@multitable @columnfractions .15 .70
8832
@item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
8833
@end multitable
8834
 
8835
@item @emph{Example}:
8836
@smallexample
8837
program test_random_number
8838
  REAL :: r(5,5)
8839
  CALL init_random_seed()         ! see example of RANDOM_SEED
8840
  CALL RANDOM_NUMBER(r)
8841
end program
8842
@end smallexample
8843
 
8844
@item @emph{See also}:
8845
@ref{RANDOM_SEED}
8846
@end table
8847
 
8848
 
8849
 
8850
@node RANDOM_SEED
8851
@section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
8852
@fnindex RANDOM_SEED
8853
@cindex random number generation, seeding
8854
@cindex seeding a random number generator
8855
 
8856
@table @asis
8857
@item @emph{Description}:
8858
Restarts or queries the state of the pseudorandom number generator used by
8859
@code{RANDOM_NUMBER}.
8860
 
8861
If @code{RANDOM_SEED} is called without arguments, it is initialized to
8862
a default state. The example below shows how to initialize the random
8863
seed based on the system's time.
8864
 
8865
@item @emph{Standard}:
8866
Fortran 95 and later
8867
 
8868
@item @emph{Class}:
8869
Subroutine
8870
 
8871
@item @emph{Syntax}:
8872
@code{CALL RANDOM_SEED([SIZE, PUT, GET])}
8873
 
8874
@item @emph{Arguments}:
8875
@multitable @columnfractions .15 .70
8876
@item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
8877
@code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
8878
of the arrays used with the @var{PUT} and @var{GET} arguments.
8879
@item @var{PUT}  @tab (Optional) Shall be an array of type default
8880
@code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
8881
the array must be larger than or equal to the number returned by the
8882
@var{SIZE} argument.
8883
@item @var{GET}  @tab (Optional) Shall be an array of type default
8884
@code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
8885
of the array must be larger than or equal to the number returned by
8886
the @var{SIZE} argument.
8887
@end multitable
8888
 
8889
@item @emph{Example}:
8890
@smallexample
8891
SUBROUTINE init_random_seed()
8892
  INTEGER :: i, n, clock
8893
  INTEGER, DIMENSION(:), ALLOCATABLE :: seed
8894
 
8895
  CALL RANDOM_SEED(size = n)
8896
  ALLOCATE(seed(n))
8897
 
8898
  CALL SYSTEM_CLOCK(COUNT=clock)
8899
 
8900
  seed = clock + 37 * (/ (i - 1, i = 1, n) /)
8901
  CALL RANDOM_SEED(PUT = seed)
8902
 
8903
  DEALLOCATE(seed)
8904
END SUBROUTINE
8905
@end smallexample
8906
 
8907
@item @emph{See also}:
8908
@ref{RANDOM_NUMBER}
8909
@end table
8910
 
8911
 
8912
 
8913
@node RANGE
8914
@section @code{RANGE} --- Decimal exponent range
8915
@fnindex RANGE
8916
@cindex model representation, range
8917
 
8918
@table @asis
8919
@item @emph{Description}:
8920
@code{RANGE(X)} returns the decimal exponent range in the model of the
8921
type of @code{X}.
8922
 
8923
@item @emph{Standard}:
8924
Fortran 95 and later
8925
 
8926
@item @emph{Class}:
8927
Inquiry function
8928
 
8929
@item @emph{Syntax}:
8930
@code{RESULT = RANGE(X)}
8931
 
8932
@item @emph{Arguments}:
8933
@multitable @columnfractions .15 .70
8934
@item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
8935
or @code{COMPLEX}.
8936
@end multitable
8937
 
8938
@item @emph{Return value}:
8939
The return value is of type @code{INTEGER} and of the default integer
8940
kind.
8941
 
8942
@item @emph{Example}:
8943
See @code{PRECISION} for an example.
8944
@end table
8945
 
8946
 
8947
 
8948
@node REAL
8949
@section @code{REAL} --- Convert to real type
8950
@fnindex REAL
8951
@fnindex REALPART
8952
@cindex conversion, to real
8953
@cindex complex numbers, real part
8954
 
8955
@table @asis
8956
@item @emph{Description}:
8957
@code{REAL(A [, KIND])} converts its argument @var{A} to a real type.  The
8958
@code{REALPART} function is provided for compatibility with @command{g77},
8959
and its use is strongly discouraged.
8960
 
8961
@item @emph{Standard}:
8962
Fortran 77 and later
8963
 
8964
@item @emph{Class}:
8965
Elemental function
8966
 
8967
@item @emph{Syntax}:
8968
@multitable @columnfractions .80
8969
@item @code{RESULT = REAL(A [, KIND])}
8970
@item @code{RESULT = REALPART(Z)}
8971
@end multitable
8972
 
8973
@item @emph{Arguments}:
8974
@multitable @columnfractions .15 .70
8975
@item @var{A}    @tab Shall be @code{INTEGER}, @code{REAL}, or
8976
@code{COMPLEX}.
8977
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8978
expression indicating the kind parameter of the result.
8979
@end multitable
8980
 
8981
@item @emph{Return value}:
8982
These functions return a @code{REAL} variable or array under
8983
the following rules:
8984
 
8985
@table @asis
8986
@item (A)
8987
@code{REAL(A)} is converted to a default real type if @var{A} is an
8988
integer or real variable.
8989
@item (B)
8990
@code{REAL(A)} is converted to a real type with the kind type parameter
8991
of @var{A} if @var{A} is a complex variable.
8992
@item (C)
8993
@code{REAL(A, KIND)} is converted to a real type with kind type
8994
parameter @var{KIND} if @var{A} is a complex, integer, or real
8995
variable.
8996
@end table
8997
 
8998
@item @emph{Example}:
8999
@smallexample
9000
program test_real
9001
  complex :: x = (1.0, 2.0)
9002
  print *, real(x), real(x,8), realpart(x)
9003
end program test_real
9004
@end smallexample
9005
 
9006
@item @emph{See also}:
9007
@ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
9008
 
9009
@end table
9010
 
9011
 
9012
 
9013
@node RENAME
9014
@section @code{RENAME} --- Rename a file
9015
@fnindex RENAME
9016
@cindex file system, rename file
9017
 
9018
@table @asis
9019
@item @emph{Description}:
9020
Renames a file from file @var{PATH1} to @var{PATH2}. A null
9021
character (@code{CHAR(0)}) can be used to mark the end of the names in
9022
@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9023
names are ignored.  If the @var{STATUS} argument is supplied, it
9024
contains 0 on success or a nonzero error code upon return; see
9025
@code{rename(2)}.
9026
 
9027
This intrinsic is provided in both subroutine and function forms;
9028
however, only one form can be used in any given program unit.
9029
 
9030
@item @emph{Standard}:
9031
GNU extension
9032
 
9033
@item @emph{Class}:
9034
Subroutine, function
9035
 
9036
@item @emph{Syntax}:
9037
@multitable @columnfractions .80
9038
@item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
9039
@item @code{STATUS = RENAME(PATH1, PATH2)}
9040
@end multitable
9041
 
9042
@item @emph{Arguments}:
9043
@multitable @columnfractions .15 .70
9044
@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9045
@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9046
@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9047
@end multitable
9048
 
9049
@item @emph{See also}:
9050
@ref{LINK}
9051
 
9052
@end table
9053
 
9054
 
9055
 
9056
@node REPEAT
9057
@section @code{REPEAT} --- Repeated string concatenation
9058
@fnindex REPEAT
9059
@cindex string, repeat
9060
@cindex string, concatenate
9061
 
9062
@table @asis
9063
@item @emph{Description}:
9064
Concatenates @var{NCOPIES} copies of a string.
9065
 
9066
@item @emph{Standard}:
9067
Fortran 95 and later
9068
 
9069
@item @emph{Class}:
9070
Transformational function
9071
 
9072
@item @emph{Syntax}:
9073
@code{RESULT = REPEAT(STRING, NCOPIES)}
9074
 
9075
@item @emph{Arguments}:
9076
@multitable @columnfractions .15 .70
9077
@item @var{STRING}  @tab Shall be scalar and of type @code{CHARACTER}.
9078
@item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
9079
@end multitable
9080
 
9081
@item @emph{Return value}:
9082
A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
9083
of @var{STRING}.
9084
 
9085
@item @emph{Example}:
9086
@smallexample
9087
program test_repeat
9088
  write(*,*) repeat("x", 5)   ! "xxxxx"
9089
end program
9090
@end smallexample
9091
@end table
9092
 
9093
 
9094
 
9095
@node RESHAPE
9096
@section @code{RESHAPE} --- Function to reshape an array
9097
@fnindex RESHAPE
9098
@cindex array, change dimensions
9099
@cindex array, transmogrify
9100
 
9101
@table @asis
9102
@item @emph{Description}:
9103
Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
9104
the new array may be padded with elements from @var{PAD} or permuted
9105
as defined by @var{ORDER}.
9106
 
9107
@item @emph{Standard}:
9108
Fortran 95 and later
9109
 
9110
@item @emph{Class}:
9111
Transformational function
9112
 
9113
@item @emph{Syntax}:
9114
@code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
9115
 
9116
@item @emph{Arguments}:
9117
@multitable @columnfractions .15 .70
9118
@item @var{SOURCE} @tab Shall be an array of any type.
9119
@item @var{SHAPE}  @tab Shall be of type @code{INTEGER} and an
9120
array of rank one. Its values must be positive or zero.
9121
@item @var{PAD}    @tab (Optional) shall be an array of the same
9122
type as @var{SOURCE}.
9123
@item @var{ORDER}  @tab (Optional) shall be of type @code{INTEGER}
9124
and an array of the same shape as @var{SHAPE}. Its values shall
9125
be a permutation of the numbers from 1 to n, where n is the size of
9126
@var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
9127
be assumed.
9128
@end multitable
9129
 
9130
@item @emph{Return value}:
9131
The result is an array of shape @var{SHAPE} with the same type as
9132
@var{SOURCE}.
9133
 
9134
@item @emph{Example}:
9135
@smallexample
9136
PROGRAM test_reshape
9137
  INTEGER, DIMENSION(4) :: x
9138
  WRITE(*,*) SHAPE(x)                       ! prints "4"
9139
  WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/)))    ! prints "2 2"
9140
END PROGRAM
9141
@end smallexample
9142
 
9143
@item @emph{See also}:
9144
@ref{SHAPE}
9145
@end table
9146
 
9147
 
9148
 
9149
@node RRSPACING
9150
@section @code{RRSPACING} --- Reciprocal of the relative spacing
9151
@fnindex RRSPACING
9152
@cindex real number, relative spacing
9153
@cindex floating point, relative spacing
9154
 
9155
 
9156
@table @asis
9157
@item @emph{Description}:
9158
@code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
9159
model numbers near @var{X}.
9160
 
9161
@item @emph{Standard}:
9162
Fortran 95 and later
9163
 
9164
@item @emph{Class}:
9165
Elemental function
9166
 
9167
@item @emph{Syntax}:
9168
@code{RESULT = RRSPACING(X)}
9169
 
9170
@item @emph{Arguments}:
9171
@multitable @columnfractions .15 .70
9172
@item @var{X} @tab Shall be of type @code{REAL}.
9173
@end multitable
9174
 
9175
@item @emph{Return value}:
9176
The return value is of the same type and kind as @var{X}.
9177
The value returned is equal to
9178
@code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
9179
 
9180
@item @emph{See also}:
9181
@ref{SPACING}
9182
@end table
9183
 
9184
 
9185
 
9186
@node RSHIFT
9187
@section @code{RSHIFT} --- Right shift bits
9188
@fnindex RSHIFT
9189
@cindex bits, shift right
9190
 
9191
@table @asis
9192
@item @emph{Description}:
9193
@code{RSHIFT} returns a value corresponding to @var{I} with all of the
9194
bits shifted right by @var{SHIFT} places.  If the absolute value of
9195
@var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
9196
Bits shifted out from the left end are lost; zeros are shifted in from
9197
the opposite end.
9198
 
9199
This function has been superseded by the @code{ISHFT} intrinsic, which
9200
is standard in Fortran 95 and later.
9201
 
9202
@item @emph{Standard}:
9203
GNU extension
9204
 
9205
@item @emph{Class}:
9206
Elemental function
9207
 
9208
@item @emph{Syntax}:
9209
@code{RESULT = RSHIFT(I, SHIFT)}
9210
 
9211
@item @emph{Arguments}:
9212
@multitable @columnfractions .15 .70
9213
@item @var{I} @tab The type shall be @code{INTEGER}.
9214
@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9215
@end multitable
9216
 
9217
@item @emph{Return value}:
9218
The return value is of type @code{INTEGER} and of the same kind as
9219
@var{I}.
9220
 
9221
@item @emph{See also}:
9222
@ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
9223
 
9224
@end table
9225
 
9226
 
9227
 
9228
@node SCALE
9229
@section @code{SCALE} --- Scale a real value
9230
@fnindex SCALE
9231
@cindex real number, scale
9232
@cindex floating point, scale
9233
 
9234
@table @asis
9235
@item @emph{Description}:
9236
@code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
9237
 
9238
@item @emph{Standard}:
9239
Fortran 95 and later
9240
 
9241
@item @emph{Class}:
9242
Elemental function
9243
 
9244
@item @emph{Syntax}:
9245
@code{RESULT = SCALE(X, I)}
9246
 
9247
@item @emph{Arguments}:
9248
@multitable @columnfractions .15 .70
9249
@item @var{X} @tab The type of the argument shall be a @code{REAL}.
9250
@item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
9251
@end multitable
9252
 
9253
@item @emph{Return value}:
9254
The return value is of the same type and kind as @var{X}.
9255
Its value is @code{X * RADIX(X)**I}.
9256
 
9257
@item @emph{Example}:
9258
@smallexample
9259
program test_scale
9260
  real :: x = 178.1387e-4
9261
  integer :: i = 5
9262
  print *, scale(x,i), x*radix(x)**i
9263
end program test_scale
9264
@end smallexample
9265
 
9266
@end table
9267
 
9268
 
9269
 
9270
@node SCAN
9271
@section @code{SCAN} --- Scan a string for the presence of a set of characters
9272
@fnindex SCAN
9273
@cindex string, find subset
9274
 
9275
@table @asis
9276
@item @emph{Description}:
9277
Scans a @var{STRING} for any of the characters in a @var{SET}
9278
of characters.
9279
 
9280
If @var{BACK} is either absent or equals @code{FALSE}, this function
9281
returns the position of the leftmost character of @var{STRING} that is
9282
in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
9283
is returned. If no character of @var{SET} is found in @var{STRING}, the
9284
result is zero.
9285
 
9286
@item @emph{Standard}:
9287
Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9288
 
9289
@item @emph{Class}:
9290
Elemental function
9291
 
9292
@item @emph{Syntax}:
9293
@code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
9294
 
9295
@item @emph{Arguments}:
9296
@multitable @columnfractions .15 .70
9297
@item @var{STRING} @tab Shall be of type @code{CHARACTER}.
9298
@item @var{SET}    @tab Shall be of type @code{CHARACTER}.
9299
@item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
9300
@item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
9301
expression indicating the kind parameter of the result.
9302
@end multitable
9303
 
9304
@item @emph{Return value}:
9305
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9306
@var{KIND} is absent, the return value is of default integer kind.
9307
 
9308
@item @emph{Example}:
9309
@smallexample
9310
PROGRAM test_scan
9311
  WRITE(*,*) SCAN("FORTRAN", "AO")          ! 2, found 'O'
9312
  WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.)  ! 6, found 'A'
9313
  WRITE(*,*) SCAN("FORTRAN", "C++")         ! 0, found none
9314
END PROGRAM
9315
@end smallexample
9316
 
9317
@item @emph{See also}:
9318
@ref{INDEX intrinsic}, @ref{VERIFY}
9319
@end table
9320
 
9321
 
9322
 
9323
@node SECNDS
9324
@section @code{SECNDS} --- Time function
9325
@fnindex SECNDS
9326
@cindex time, elapsed
9327
@cindex elapsed time
9328
 
9329
@table @asis
9330
@item @emph{Description}:
9331
@code{SECNDS(X)} gets the time in seconds from the real-time system clock.
9332
@var{X} is a reference time, also in seconds. If this is zero, the time in
9333
seconds from midnight is returned. This function is non-standard and its
9334
use is discouraged.
9335
 
9336
@item @emph{Standard}:
9337
GNU extension
9338
 
9339
@item @emph{Class}:
9340
Function
9341
 
9342
@item @emph{Syntax}:
9343
@code{RESULT = SECNDS (X)}
9344
 
9345
@item @emph{Arguments}:
9346
@multitable @columnfractions .15 .70
9347
@item @var{T}     @tab Shall be of type @code{REAL(4)}.
9348
@item @var{X}     @tab Shall be of type @code{REAL(4)}.
9349
@end multitable
9350
 
9351
@item @emph{Return value}:
9352
None
9353
 
9354
@item @emph{Example}:
9355
@smallexample
9356
program test_secnds
9357
    integer :: i
9358
    real(4) :: t1, t2
9359
    print *, secnds (0.0)   ! seconds since midnight
9360
    t1 = secnds (0.0)       ! reference time
9361
    do i = 1, 10000000      ! do something
9362
    end do
9363
    t2 = secnds (t1)        ! elapsed time
9364
    print *, "Something took ", t2, " seconds."
9365
end program test_secnds
9366
@end smallexample
9367
@end table
9368
 
9369
 
9370
 
9371
@node SECOND
9372
@section @code{SECOND} --- CPU time function
9373
@fnindex SECOND
9374
@cindex time, elapsed
9375
@cindex elapsed time
9376
 
9377
@table @asis
9378
@item @emph{Description}:
9379
Returns a @code{REAL(4)} value representing the elapsed CPU time in
9380
seconds.  This provides the same functionality as the standard
9381
@code{CPU_TIME} intrinsic, and is only included for backwards
9382
compatibility.
9383
 
9384
This intrinsic is provided in both subroutine and function forms;
9385
however, only one form can be used in any given program unit.
9386
 
9387
@item @emph{Standard}:
9388
GNU extension
9389
 
9390
@item @emph{Class}:
9391
Subroutine, function
9392
 
9393
@item @emph{Syntax}:
9394
@multitable @columnfractions .80
9395
@item @code{CALL SECOND(TIME)}
9396
@item @code{TIME = SECOND()}
9397
@end multitable
9398
 
9399
@item @emph{Arguments}:
9400
@multitable @columnfractions .15 .70
9401
@item @var{TIME}  @tab Shall be of type @code{REAL(4)}.
9402
@end multitable
9403
 
9404
@item @emph{Return value}:
9405
In either syntax, @var{TIME} is set to the process's current runtime in
9406
seconds.
9407
 
9408
@item @emph{See also}:
9409
@ref{CPU_TIME}
9410
 
9411
@end table
9412
 
9413
 
9414
 
9415
@node SELECTED_CHAR_KIND
9416
@section @code{SELECTED_CHAR_KIND} --- Choose character kind
9417
@fnindex SELECTED_CHAR_KIND
9418
@cindex character kind
9419
@cindex kind, character
9420
 
9421
@table @asis
9422
@item @emph{Description}:
9423
 
9424
@code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
9425
set named @var{NAME}, if a character set with such a name is supported,
9426
or @math{-1} otherwise. Currently, supported character sets include
9427
``ASCII'' and ``DEFAULT'', which are equivalent.
9428
 
9429
@item @emph{Standard}:
9430
Fortran 2003 and later
9431
 
9432
@item @emph{Class}:
9433
Transformational function
9434
 
9435
@item @emph{Syntax}:
9436
@code{RESULT = SELECTED_CHAR_KIND(NAME)}
9437
 
9438
@item @emph{Arguments}:
9439
@multitable @columnfractions .15 .70
9440
@item @var{NAME} @tab Shall be a scalar and of the default character type.
9441
@end multitable
9442
 
9443
@item @emph{Example}:
9444
@smallexample
9445
program ascii_kind
9446
  integer,parameter :: ascii = selected_char_kind("ascii")
9447
  character(kind=ascii, len=26) :: s
9448
 
9449
  s = ascii_"abcdefghijklmnopqrstuvwxyz"
9450
  print *, s
9451
end program ascii_kind
9452
@end smallexample
9453
@end table
9454
 
9455
 
9456
 
9457
@node SELECTED_INT_KIND
9458
@section @code{SELECTED_INT_KIND} --- Choose integer kind
9459
@fnindex SELECTED_INT_KIND
9460
@cindex integer kind
9461
@cindex kind, integer
9462
 
9463
@table @asis
9464
@item @emph{Description}:
9465
@code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
9466
type that can represent all values ranging from @math{-10^R} (exclusive)
9467
to @math{10^R} (exclusive). If there is no integer kind that accommodates
9468
this range, @code{SELECTED_INT_KIND} returns @math{-1}.
9469
 
9470
@item @emph{Standard}:
9471
Fortran 95 and later
9472
 
9473
@item @emph{Class}:
9474
Transformational function
9475
 
9476
@item @emph{Syntax}:
9477
@code{RESULT = SELECTED_INT_KIND(R)}
9478
 
9479
@item @emph{Arguments}:
9480
@multitable @columnfractions .15 .70
9481
@item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
9482
@end multitable
9483
 
9484
@item @emph{Example}:
9485
@smallexample
9486
program large_integers
9487
  integer,parameter :: k5 = selected_int_kind(5)
9488
  integer,parameter :: k15 = selected_int_kind(15)
9489
  integer(kind=k5) :: i5
9490
  integer(kind=k15) :: i15
9491
 
9492
  print *, huge(i5), huge(i15)
9493
 
9494
  ! The following inequalities are always true
9495
  print *, huge(i5) >= 10_k5**5-1
9496
  print *, huge(i15) >= 10_k15**15-1
9497
end program large_integers
9498
@end smallexample
9499
@end table
9500
 
9501
 
9502
 
9503
@node SELECTED_REAL_KIND
9504
@section @code{SELECTED_REAL_KIND} --- Choose real kind
9505
@fnindex SELECTED_REAL_KIND
9506
@cindex real kind
9507
@cindex kind, real
9508
 
9509
@table @asis
9510
@item @emph{Description}:
9511
@code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
9512
with decimal precision of at least @code{P} digits and exponent
9513
range greater at least @code{R}.
9514
 
9515
@item @emph{Standard}:
9516
Fortran 95 and later
9517
 
9518
@item @emph{Class}:
9519
Transformational function
9520
 
9521
@item @emph{Syntax}:
9522
@code{RESULT = SELECTED_REAL_KIND([P, R])}
9523
 
9524
@item @emph{Arguments}:
9525
@multitable @columnfractions .15 .70
9526
@item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9527
@item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9528
@end multitable
9529
At least one argument shall be present.
9530
 
9531
@item @emph{Return value}:
9532
 
9533
@code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
9534
a real data type with decimal precision of at least @code{P} digits and a
9535
decimal exponent range of at least @code{R}. If more than one real data
9536
type meet the criteria, the kind of the data type with the smallest
9537
decimal precision is returned. If no real data type matches the criteria,
9538
the result is
9539
@table @asis
9540
@item -1 if the processor does not support a real data type with a
9541
precision greater than or equal to @code{P}
9542
@item -2 if the processor does not support a real type with an exponent
9543
range greater than or equal to @code{R}
9544
@item -3 if neither is supported.
9545
@end table
9546
 
9547
@item @emph{Example}:
9548
@smallexample
9549
program real_kinds
9550
  integer,parameter :: p6 = selected_real_kind(6)
9551
  integer,parameter :: p10r100 = selected_real_kind(10,100)
9552
  integer,parameter :: r400 = selected_real_kind(r=400)
9553
  real(kind=p6) :: x
9554
  real(kind=p10r100) :: y
9555
  real(kind=r400) :: z
9556
 
9557
  print *, precision(x), range(x)
9558
  print *, precision(y), range(y)
9559
  print *, precision(z), range(z)
9560
end program real_kinds
9561
@end smallexample
9562
@end table
9563
 
9564
 
9565
 
9566
@node SET_EXPONENT
9567
@section @code{SET_EXPONENT} --- Set the exponent of the model
9568
@fnindex SET_EXPONENT
9569
@cindex real number, set exponent
9570
@cindex floating point, set exponent
9571
 
9572
@table @asis
9573
@item @emph{Description}:
9574
@code{SET_EXPONENT(X, I)} returns the real number whose fractional part
9575
is that that of @var{X} and whose exponent part is @var{I}.
9576
 
9577
@item @emph{Standard}:
9578
Fortran 95 and later
9579
 
9580
@item @emph{Class}:
9581
Elemental function
9582
 
9583
@item @emph{Syntax}:
9584
@code{RESULT = SET_EXPONENT(X, I)}
9585
 
9586
@item @emph{Arguments}:
9587
@multitable @columnfractions .15 .70
9588
@item @var{X} @tab Shall be of type @code{REAL}.
9589
@item @var{I} @tab Shall be of type @code{INTEGER}.
9590
@end multitable
9591
 
9592
@item @emph{Return value}:
9593
The return value is of the same type and kind as @var{X}.
9594
The real number whose fractional part
9595
is that that of @var{X} and whose exponent part if @var{I} is returned;
9596
it is @code{FRACTION(X) * RADIX(X)**I}.
9597
 
9598
@item @emph{Example}:
9599
@smallexample
9600
PROGRAM test_setexp
9601
  REAL :: x = 178.1387e-4
9602
  INTEGER :: i = 17
9603
  PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
9604
END PROGRAM
9605
@end smallexample
9606
 
9607
@end table
9608
 
9609
 
9610
 
9611
@node SHAPE
9612
@section @code{SHAPE} --- Determine the shape of an array
9613
@fnindex SHAPE
9614
@cindex array, shape
9615
 
9616
@table @asis
9617
@item @emph{Description}:
9618
Determines the shape of an array.
9619
 
9620
@item @emph{Standard}:
9621
Fortran 95 and later
9622
 
9623
@item @emph{Class}:
9624
Inquiry function
9625
 
9626
@item @emph{Syntax}:
9627
@code{RESULT = SHAPE(SOURCE)}
9628
 
9629
@item @emph{Arguments}:
9630
@multitable @columnfractions .15 .70
9631
@item @var{SOURCE} @tab Shall be an array or scalar of any type.
9632
If @var{SOURCE} is a pointer it must be associated and allocatable
9633
arrays must be allocated.
9634
@end multitable
9635
 
9636
@item @emph{Return value}:
9637
An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
9638
has dimensions. The elements of the resulting array correspond to the extend
9639
of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
9640
the result is the rank one array of size zero.
9641
 
9642
@item @emph{Example}:
9643
@smallexample
9644
PROGRAM test_shape
9645
  INTEGER, DIMENSION(-1:1, -1:2) :: A
9646
  WRITE(*,*) SHAPE(A)             ! (/ 3, 4 /)
9647
  WRITE(*,*) SIZE(SHAPE(42))      ! (/ /)
9648
END PROGRAM
9649
@end smallexample
9650
 
9651
@item @emph{See also}:
9652
@ref{RESHAPE}, @ref{SIZE}
9653
@end table
9654
 
9655
 
9656
 
9657
@node SIGN
9658
@section @code{SIGN} --- Sign copying function
9659
@fnindex SIGN
9660
@fnindex ISIGN
9661
@fnindex DSIGN
9662
@cindex sign copying
9663
 
9664
@table @asis
9665
@item @emph{Description}:
9666
@code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
9667
 
9668
@item @emph{Standard}:
9669
Fortran 77 and later
9670
 
9671
@item @emph{Class}:
9672
Elemental function
9673
 
9674
@item @emph{Syntax}:
9675
@code{RESULT = SIGN(A, B)}
9676
 
9677
@item @emph{Arguments}:
9678
@multitable @columnfractions .15 .70
9679
@item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
9680
@item @var{B} @tab Shall be of the same type and kind as @var{A}
9681
@end multitable
9682
 
9683
@item @emph{Return value}:
9684
The kind of the return value is that of @var{A} and @var{B}.
9685
If @math{B\ge 0} then the result is @code{ABS(A)}, else
9686
it is @code{-ABS(A)}.
9687
 
9688
@item @emph{Example}:
9689
@smallexample
9690
program test_sign
9691
  print *, sign(-12,1)
9692
  print *, sign(-12,0)
9693
  print *, sign(-12,-1)
9694
 
9695
  print *, sign(-12.,1.)
9696
  print *, sign(-12.,0.)
9697
  print *, sign(-12.,-1.)
9698
end program test_sign
9699
@end smallexample
9700
 
9701
@item @emph{Specific names}:
9702
@multitable @columnfractions .20 .20 .20 .25
9703
@item Name              @tab Arguments      @tab Return type    @tab Standard
9704
@item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
9705
@item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
9706
@end multitable
9707
@end table
9708
 
9709
 
9710
 
9711
@node SIGNAL
9712
@section @code{SIGNAL} --- Signal handling subroutine (or function)
9713
@fnindex SIGNAL
9714
@cindex system, signal handling
9715
 
9716
@table @asis
9717
@item @emph{Description}:
9718
@code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
9719
@var{HANDLER} to be executed with a single integer argument when signal
9720
@var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
9721
turn off handling of signal @var{NUMBER} or revert to its default
9722
action.  See @code{signal(2)}.
9723
 
9724
If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
9725
is supplied, it is set to the value returned by @code{signal(2)}.
9726
 
9727
@item @emph{Standard}:
9728
GNU extension
9729
 
9730
@item @emph{Class}:
9731
Subroutine, function
9732
 
9733
@item @emph{Syntax}:
9734
@multitable @columnfractions .80
9735
@item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
9736
@item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
9737
@end multitable
9738
 
9739
@item @emph{Arguments}:
9740
@multitable @columnfractions .15 .70
9741
@item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
9742
@item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
9743
@code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
9744
@code{INTEGER}. It is @code{INTENT(IN)}.
9745
@item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
9746
integer. It has @code{INTENT(OUT)}.
9747
@end multitable
9748
@c TODO: What should the interface of the handler be?  Does it take arguments?
9749
 
9750
@item @emph{Return value}:
9751
The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
9752
 
9753
@item @emph{Example}:
9754
@smallexample
9755
program test_signal
9756
  intrinsic signal
9757
  external handler_print
9758
 
9759
  call signal (12, handler_print)
9760
  call signal (10, 1)
9761
 
9762
  call sleep (30)
9763
end program test_signal
9764
@end smallexample
9765
@end table
9766
 
9767
 
9768
 
9769
@node SIN
9770
@section @code{SIN} --- Sine function
9771
@fnindex SIN
9772
@fnindex DSIN
9773
@fnindex CSIN
9774
@fnindex ZSIN
9775
@fnindex CDSIN
9776
@cindex trigonometric function, sine
9777
@cindex sine
9778
 
9779
@table @asis
9780
@item @emph{Description}:
9781
@code{SIN(X)} computes the sine of @var{X}.
9782
 
9783
@item @emph{Standard}:
9784
Fortran 77 and later
9785
 
9786
@item @emph{Class}:
9787
Elemental function
9788
 
9789
@item @emph{Syntax}:
9790
@code{RESULT = SIN(X)}
9791
 
9792
@item @emph{Arguments}:
9793
@multitable @columnfractions .15 .70
9794
@item @var{X} @tab The type shall be @code{REAL} or
9795
@code{COMPLEX}.
9796
@end multitable
9797
 
9798
@item @emph{Return value}:
9799
The return value has same type and kind as @var{X}.
9800
 
9801
@item @emph{Example}:
9802
@smallexample
9803
program test_sin
9804
  real :: x = 0.0
9805
  x = sin(x)
9806
end program test_sin
9807
@end smallexample
9808
 
9809
@item @emph{Specific names}:
9810
@multitable @columnfractions .20 .20 .20 .25
9811
@item Name            @tab Argument          @tab Return type       @tab Standard
9812
@item @code{DSIN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
9813
@item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
9814
@item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
9815
@item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
9816
@end multitable
9817
 
9818
@item @emph{See also}:
9819
@ref{ASIN}
9820
@end table
9821
 
9822
 
9823
 
9824
@node SINH
9825
@section @code{SINH} --- Hyperbolic sine function
9826
@fnindex SINH
9827
@fnindex DSINH
9828
@cindex hyperbolic sine
9829
@cindex hyperbolic function, sine
9830
@cindex sine, hyperbolic
9831
 
9832
@table @asis
9833
@item @emph{Description}:
9834
@code{SINH(X)} computes the hyperbolic sine of @var{X}.
9835
 
9836
@item @emph{Standard}:
9837
Fortran 95 and later, for a complex argument Fortran 2008 or later
9838
 
9839
@item @emph{Class}:
9840
Elemental function
9841
 
9842
@item @emph{Syntax}:
9843
@code{RESULT = SINH(X)}
9844
 
9845
@item @emph{Arguments}:
9846
@multitable @columnfractions .15 .70
9847
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
9848
@end multitable
9849
 
9850
@item @emph{Return value}:
9851
The return value has same type and kind as @var{X}.
9852
 
9853
@item @emph{Example}:
9854
@smallexample
9855
program test_sinh
9856
  real(8) :: x = - 1.0_8
9857
  x = sinh(x)
9858
end program test_sinh
9859
@end smallexample
9860
 
9861
@item @emph{Specific names}:
9862
@multitable @columnfractions .20 .20 .20 .25
9863
@item Name            @tab Argument          @tab Return type       @tab Standard
9864
@item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
9865
@end multitable
9866
 
9867
@item @emph{See also}:
9868
@ref{ASINH}
9869
@end table
9870
 
9871
 
9872
 
9873
@node SIZE
9874
@section @code{SIZE} --- Determine the size of an array
9875
@fnindex SIZE
9876
@cindex array, size
9877
@cindex array, number of elements
9878
@cindex array, count elements
9879
 
9880
@table @asis
9881
@item @emph{Description}:
9882
Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
9883
or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
9884
 
9885
@item @emph{Standard}:
9886
Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9887
 
9888
@item @emph{Class}:
9889
Inquiry function
9890
 
9891
@item @emph{Syntax}:
9892
@code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
9893
 
9894
@item @emph{Arguments}:
9895
@multitable @columnfractions .15 .70
9896
@item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
9897
a pointer it must be associated and allocatable arrays must be allocated.
9898
@item @var{DIM}   @tab (Optional) shall be a scalar of type @code{INTEGER}
9899
and its value shall be in the range from 1 to n, where n equals the rank
9900
of @var{ARRAY}.
9901
@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9902
expression indicating the kind parameter of the result.
9903
@end multitable
9904
 
9905
@item @emph{Return value}:
9906
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9907
@var{KIND} is absent, the return value is of default integer kind.
9908
 
9909
@item @emph{Example}:
9910
@smallexample
9911
PROGRAM test_size
9912
  WRITE(*,*) SIZE((/ 1, 2 /))    ! 2
9913
END PROGRAM
9914
@end smallexample
9915
 
9916
@item @emph{See also}:
9917
@ref{SHAPE}, @ref{RESHAPE}
9918
@end table
9919
 
9920
 
9921
@node SIZEOF
9922
@section @code{SIZEOF} --- Size in bytes of an expression
9923
@fnindex SIZEOF
9924
@cindex expression size
9925
@cindex size of an expression
9926
 
9927
@table @asis
9928
@item @emph{Description}:
9929
@code{SIZEOF(X)} calculates the number of bytes of storage the
9930
expression @code{X} occupies.
9931
 
9932
@item @emph{Standard}:
9933
GNU extension
9934
 
9935
@item @emph{Class}:
9936
Intrinsic function
9937
 
9938
@item @emph{Syntax}:
9939
@code{N = SIZEOF(X)}
9940
 
9941
@item @emph{Arguments}:
9942
@multitable @columnfractions .15 .70
9943
@item @var{X} @tab The argument shall be of any type, rank or shape.
9944
@end multitable
9945
 
9946
@item @emph{Return value}:
9947
The return value is of type integer and of the system-dependent kind
9948
@var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
9949
number of bytes occupied by the argument.  If the argument has the
9950
@code{POINTER} attribute, the number of bytes of the storage area pointed
9951
to is returned.  If the argument is of a derived type with @code{POINTER}
9952
or @code{ALLOCATABLE} components, the return value doesn't account for
9953
the sizes of the data pointed to by these components.
9954
 
9955
@item @emph{Example}:
9956
@smallexample
9957
   integer :: i
9958
   real :: r, s(5)
9959
   print *, (sizeof(s)/sizeof(r) == 5)
9960
   end
9961
@end smallexample
9962
The example will print @code{.TRUE.} unless you are using a platform
9963
where default @code{REAL} variables are unusually padded.
9964
 
9965
@item @emph{See also}:
9966
@ref{C_SIZEOF}
9967
@end table
9968
 
9969
 
9970
@node SLEEP
9971
@section @code{SLEEP} --- Sleep for the specified number of seconds
9972
@fnindex SLEEP
9973
@cindex delayed execution
9974
 
9975
@table @asis
9976
@item @emph{Description}:
9977
Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
9978
 
9979
@item @emph{Standard}:
9980
GNU extension
9981
 
9982
@item @emph{Class}:
9983
Subroutine
9984
 
9985
@item @emph{Syntax}:
9986
@code{CALL SLEEP(SECONDS)}
9987
 
9988
@item @emph{Arguments}:
9989
@multitable @columnfractions .15 .70
9990
@item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
9991
@end multitable
9992
 
9993
@item @emph{Example}:
9994
@smallexample
9995
program test_sleep
9996
  call sleep(5)
9997
end
9998
@end smallexample
9999
@end table
10000
 
10001
 
10002
 
10003
@node SNGL
10004
@section @code{SNGL} --- Convert double precision real to default real
10005
@fnindex SNGL
10006
@cindex conversion, to real
10007
 
10008
@table @asis
10009
@item @emph{Description}:
10010
@code{SNGL(A)} converts the double precision real @var{A}
10011
to a default real value. This is an archaic form of @code{REAL}
10012
that is specific to one type for @var{A}.
10013
 
10014
@item @emph{Standard}:
10015
Fortran 77 and later
10016
 
10017
@item @emph{Class}:
10018
Elemental function
10019
 
10020
@item @emph{Syntax}:
10021
@code{RESULT = SNGL(A)}
10022
 
10023
@item @emph{Arguments}:
10024
@multitable @columnfractions .15 .70
10025
@item @var{A} @tab The type shall be a double precision @code{REAL}.
10026
@end multitable
10027
 
10028
@item @emph{Return value}:
10029
The return value is of type default @code{REAL}.
10030
 
10031
@item @emph{See also}:
10032
@ref{DBLE}
10033
@end table
10034
 
10035
 
10036
 
10037
@node SPACING
10038
@section @code{SPACING} --- Smallest distance between two numbers of a given type
10039
@fnindex SPACING
10040
@cindex real number, relative spacing
10041
@cindex floating point, relative spacing
10042
 
10043
@table @asis
10044
@item @emph{Description}:
10045
Determines the distance between the argument @var{X} and the nearest
10046
adjacent number of the same type.
10047
 
10048
@item @emph{Standard}:
10049
Fortran 95 and later
10050
 
10051
@item @emph{Class}:
10052
Elemental function
10053
 
10054
@item @emph{Syntax}:
10055
@code{RESULT = SPACING(X)}
10056
 
10057
@item @emph{Arguments}:
10058
@multitable @columnfractions .15 .70
10059
@item @var{X} @tab Shall be of type @code{REAL}.
10060
@end multitable
10061
 
10062
@item @emph{Return value}:
10063
The result is of the same type as the input argument @var{X}.
10064
 
10065
@item @emph{Example}:
10066
@smallexample
10067
PROGRAM test_spacing
10068
  INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
10069
  INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
10070
 
10071
  WRITE(*,*) spacing(1.0_SGL)      ! "1.1920929E-07"          on i686
10072
  WRITE(*,*) spacing(1.0_DBL)      ! "2.220446049250313E-016" on i686
10073
END PROGRAM
10074
@end smallexample
10075
 
10076
@item @emph{See also}:
10077
@ref{RRSPACING}
10078
@end table
10079
 
10080
 
10081
 
10082
@node SPREAD
10083
@section @code{SPREAD} --- Add a dimension to an array
10084
@fnindex SPREAD
10085
@cindex array, increase dimension
10086
@cindex array, duplicate elements
10087
@cindex array, duplicate dimensions
10088
 
10089
@table @asis
10090
@item @emph{Description}:
10091
Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
10092
dimension @var{DIM}.
10093
 
10094
@item @emph{Standard}:
10095
Fortran 95 and later
10096
 
10097
@item @emph{Class}:
10098
Transformational function
10099
 
10100
@item @emph{Syntax}:
10101
@code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
10102
 
10103
@item @emph{Arguments}:
10104
@multitable @columnfractions .15 .70
10105
@item @var{SOURCE}  @tab Shall be a scalar or an array of any type and
10106
a rank less than seven.
10107
@item @var{DIM}     @tab Shall be a scalar of type @code{INTEGER} with a
10108
value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
10109
@item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
10110
@end multitable
10111
 
10112
@item @emph{Return value}:
10113
The result is an array of the same type as @var{SOURCE} and has rank n+1
10114
where n equals the rank of @var{SOURCE}.
10115
 
10116
@item @emph{Example}:
10117
@smallexample
10118
PROGRAM test_spread
10119
  INTEGER :: a = 1, b(2) = (/ 1, 2 /)
10120
  WRITE(*,*) SPREAD(A, 1, 2)            ! "1 1"
10121
  WRITE(*,*) SPREAD(B, 1, 2)            ! "1 1 2 2"
10122
END PROGRAM
10123
@end smallexample
10124
 
10125
@item @emph{See also}:
10126
@ref{UNPACK}
10127
@end table
10128
 
10129
 
10130
 
10131
@node SQRT
10132
@section @code{SQRT} --- Square-root function
10133
@fnindex SQRT
10134
@fnindex DSQRT
10135
@fnindex CSQRT
10136
@fnindex ZSQRT
10137
@fnindex CDSQRT
10138
@cindex root
10139
@cindex square-root
10140
 
10141
@table @asis
10142
@item @emph{Description}:
10143
@code{SQRT(X)} computes the square root of @var{X}.
10144
 
10145
@item @emph{Standard}:
10146
Fortran 77 and later
10147
 
10148
@item @emph{Class}:
10149
Elemental function
10150
 
10151
@item @emph{Syntax}:
10152
@code{RESULT = SQRT(X)}
10153
 
10154
@item @emph{Arguments}:
10155
@multitable @columnfractions .15 .70
10156
@item @var{X} @tab The type shall be @code{REAL} or
10157
@code{COMPLEX}.
10158
@end multitable
10159
 
10160
@item @emph{Return value}:
10161
The return value is of type @code{REAL} or @code{COMPLEX}.
10162
The kind type parameter is the same as @var{X}.
10163
 
10164
@item @emph{Example}:
10165
@smallexample
10166
program test_sqrt
10167
  real(8) :: x = 2.0_8
10168
  complex :: z = (1.0, 2.0)
10169
  x = sqrt(x)
10170
  z = sqrt(z)
10171
end program test_sqrt
10172
@end smallexample
10173
 
10174
@item @emph{Specific names}:
10175
@multitable @columnfractions .20 .20 .20 .25
10176
@item Name             @tab Argument             @tab Return type          @tab Standard
10177
@item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab Fortran 95 and later
10178
@item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab Fortran 95 and later
10179
@item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
10180
@item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
10181
@end multitable
10182
@end table
10183
 
10184
 
10185
 
10186
@node SRAND
10187
@section @code{SRAND} --- Reinitialize the random number generator
10188
@fnindex SRAND
10189
@cindex random number generation, seeding
10190
@cindex seeding a random number generator
10191
 
10192
@table @asis
10193
@item @emph{Description}:
10194
@code{SRAND} reinitializes the pseudo-random number generator
10195
called by @code{RAND} and @code{IRAND}. The new seed used by the
10196
generator is specified by the required argument @var{SEED}.
10197
 
10198
@item @emph{Standard}:
10199
GNU extension
10200
 
10201
@item @emph{Class}:
10202
Subroutine
10203
 
10204
@item @emph{Syntax}:
10205
@code{CALL SRAND(SEED)}
10206
 
10207
@item @emph{Arguments}:
10208
@multitable @columnfractions .15 .70
10209
@item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
10210
@end multitable
10211
 
10212
@item @emph{Return value}:
10213
Does not return anything.
10214
 
10215
@item @emph{Example}:
10216
See @code{RAND} and @code{IRAND} for examples.
10217
 
10218
@item @emph{Notes}:
10219
The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
10220
initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
10221
to generate pseudo-random numbers. Please note that in
10222
GNU Fortran, these two sets of intrinsics (@code{RAND},
10223
@code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
10224
@code{RANDOM_SEED} on the other hand) access two independent
10225
pseudo-random number generators.
10226
 
10227
@item @emph{See also}:
10228
@ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
10229
 
10230
@end table
10231
 
10232
 
10233
 
10234
@node STAT
10235
@section @code{STAT} --- Get file status
10236
@fnindex STAT
10237
@cindex file system, file status
10238
 
10239
@table @asis
10240
@item @emph{Description}:
10241
This function returns information about a file. No permissions are required on
10242
the file itself, but execute (search) permission is required on all of the
10243
directories in path that lead to the file.
10244
 
10245
The elements that are obtained and stored in the array @code{VALUES}:
10246
@multitable @columnfractions .15 .70
10247
@item @code{VALUES(1)}   @tab  Device ID
10248
@item @code{VALUES(2)}   @tab  Inode number
10249
@item @code{VALUES(3)}   @tab  File mode
10250
@item @code{VALUES(4)}   @tab  Number of links
10251
@item @code{VALUES(5)}   @tab  Owner's uid
10252
@item @code{VALUES(6)}   @tab  Owner's gid
10253
@item @code{VALUES(7)}   @tab  ID of device containing directory entry for file (0 if not available)
10254
@item @code{VALUES(8)}   @tab  File size (bytes)
10255
@item @code{VALUES(9)}   @tab  Last access time
10256
@item @code{VALUES(10)}  @tab  Last modification time
10257
@item @code{VALUES(11)}  @tab  Last file status change time
10258
@item @code{VALUES(12)}  @tab  Preferred I/O block size (-1 if not available)
10259
@item @code{VALUES(13)}  @tab  Number of blocks allocated (-1 if not available)
10260
@end multitable
10261
 
10262
Not all these elements are relevant on all systems.
10263
If an element is not relevant, it is returned as 0.
10264
 
10265
This intrinsic is provided in both subroutine and function forms; however,
10266
only one form can be used in any given program unit.
10267
 
10268
@item @emph{Standard}:
10269
GNU extension
10270
 
10271
@item @emph{Class}:
10272
Subroutine, function
10273
 
10274
@item @emph{Syntax}:
10275
@code{CALL STAT(NAME, VALUES [, STATUS])}
10276
 
10277
@item @emph{Arguments}:
10278
@multitable @columnfractions .15 .70
10279
@item @var{NAME}   @tab The type shall be @code{CHARACTER}, of the
10280
default kind and a valid path within the file system.
10281
@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
10282
@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
10283
on success and a system specific error code otherwise.
10284
@end multitable
10285
 
10286
@item @emph{Example}:
10287
@smallexample
10288
PROGRAM test_stat
10289
  INTEGER, DIMENSION(13) :: buff
10290
  INTEGER :: status
10291
 
10292
  CALL STAT("/etc/passwd", buff, status)
10293
 
10294
  IF (status == 0) THEN
10295
    WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
10296
    WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
10297
    WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
10298
    WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
10299
    WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
10300
    WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
10301
    WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
10302
    WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
10303
    WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
10304
    WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
10305
    WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
10306
    WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
10307
    WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
10308
  END IF
10309
END PROGRAM
10310
@end smallexample
10311
 
10312
@item @emph{See also}:
10313
To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
10314
@end table
10315
 
10316
 
10317
 
10318
@node SUM
10319
@section @code{SUM} --- Sum of array elements
10320
@fnindex SUM
10321
@cindex array, sum
10322
@cindex array, add elements
10323
@cindex array, conditionally add elements
10324
@cindex sum array elements
10325
 
10326
@table @asis
10327
@item @emph{Description}:
10328
Adds the elements of @var{ARRAY} along dimension @var{DIM} if
10329
the corresponding element in @var{MASK} is @code{TRUE}.
10330
 
10331
@item @emph{Standard}:
10332
Fortran 95 and later
10333
 
10334
@item @emph{Class}:
10335
Transformational function
10336
 
10337
@item @emph{Syntax}:
10338
@multitable @columnfractions .80
10339
@item @code{RESULT = SUM(ARRAY[, MASK])}
10340
@item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
10341
@end multitable
10342
 
10343
@item @emph{Arguments}:
10344
@multitable @columnfractions .15 .70
10345
@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
10346
@code{REAL} or @code{COMPLEX}.
10347
@item @var{DIM}   @tab (Optional) shall be a scalar of type
10348
@code{INTEGER} with a value in the range from 1 to n, where n
10349
equals the rank of @var{ARRAY}.
10350
@item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL}
10351
and either be a scalar or an array of the same shape as @var{ARRAY}.
10352
@end multitable
10353
 
10354
@item @emph{Return value}:
10355
The result is of the same type as @var{ARRAY}.
10356
 
10357
If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
10358
is returned. Otherwise, an array of rank n-1, where n equals the rank of
10359
@var{ARRAY},and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
10360
dropped is returned.
10361
 
10362
@item @emph{Example}:
10363
@smallexample
10364
PROGRAM test_sum
10365
  INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
10366
  print *, SUM(x)                        ! all elements, sum = 15
10367
  print *, SUM(x, MASK=MOD(x, 2)==1)     ! odd elements, sum = 9
10368
END PROGRAM
10369
@end smallexample
10370
 
10371
@item @emph{See also}:
10372
@ref{PRODUCT}
10373
@end table
10374
 
10375
 
10376
 
10377
@node SYMLNK
10378
@section @code{SYMLNK} --- Create a symbolic link
10379
@fnindex SYMLNK
10380
@cindex file system, create link
10381
@cindex file system, soft link
10382
 
10383
@table @asis
10384
@item @emph{Description}:
10385
Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
10386
character (@code{CHAR(0)}) can be used to mark the end of the names in
10387
@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10388
names are ignored.  If the @var{STATUS} argument is supplied, it
10389
contains 0 on success or a nonzero error code upon return; see
10390
@code{symlink(2)}.  If the system does not supply @code{symlink(2)},
10391
@code{ENOSYS} is returned.
10392
 
10393
This intrinsic is provided in both subroutine and function forms;
10394
however, only one form can be used in any given program unit.
10395
 
10396
@item @emph{Standard}:
10397
GNU extension
10398
 
10399
@item @emph{Class}:
10400
Subroutine, function
10401
 
10402
@item @emph{Syntax}:
10403
@multitable @columnfractions .80
10404
@item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
10405
@item @code{STATUS = SYMLNK(PATH1, PATH2)}
10406
@end multitable
10407
 
10408
@item @emph{Arguments}:
10409
@multitable @columnfractions .15 .70
10410
@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10411
@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10412
@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10413
@end multitable
10414
 
10415
@item @emph{See also}:
10416
@ref{LINK}, @ref{UNLINK}
10417
 
10418
@end table
10419
 
10420
 
10421
 
10422
@node SYSTEM
10423
@section @code{SYSTEM} --- Execute a shell command
10424
@fnindex SYSTEM
10425
@cindex system, system call
10426
 
10427
@table @asis
10428
@item @emph{Description}:
10429
Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
10430
argument @var{STATUS} is present, it contains the value returned by
10431
@code{system(3)}, which is presumably 0 if the shell command succeeded.
10432
Note that which shell is used to invoke the command is system-dependent
10433
and environment-dependent.
10434
 
10435
This intrinsic is provided in both subroutine and function forms;
10436
however, only one form can be used in any given program unit.
10437
 
10438
@item @emph{Standard}:
10439
GNU extension
10440
 
10441
@item @emph{Class}:
10442
Subroutine, function
10443
 
10444
@item @emph{Syntax}:
10445
@multitable @columnfractions .80
10446
@item @code{CALL SYSTEM(COMMAND [, STATUS])}
10447
@item @code{STATUS = SYSTEM(COMMAND)}
10448
@end multitable
10449
 
10450
@item @emph{Arguments}:
10451
@multitable @columnfractions .15 .70
10452
@item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
10453
@item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
10454
@end multitable
10455
 
10456
@item @emph{See also}:
10457
@end table
10458
 
10459
 
10460
 
10461
@node SYSTEM_CLOCK
10462
@section @code{SYSTEM_CLOCK} --- Time function
10463
@fnindex SYSTEM_CLOCK
10464
@cindex time, clock ticks
10465
@cindex clock ticks
10466
 
10467
@table @asis
10468
@item @emph{Description}:
10469
Determines the @var{COUNT} of milliseconds of wall clock time since
10470
the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX},
10471
@var{COUNT_RATE} determines the number of clock ticks per second.
10472
@var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to
10473
@command{gfortran}.
10474
 
10475
If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
10476
@var{COUNT_RATE} and @var{COUNT_MAX} are set to zero
10477
 
10478
@item @emph{Standard}:
10479
Fortran 95 and later
10480
 
10481
@item @emph{Class}:
10482
Subroutine
10483
 
10484
@item @emph{Syntax}:
10485
@code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
10486
 
10487
@item @emph{Arguments}:
10488
@item @emph{Arguments}:
10489
@multitable @columnfractions .15 .70
10490
@item @var{COUNT}      @tab (Optional) shall be a scalar of type default
10491
@code{INTEGER} with @code{INTENT(OUT)}.
10492
@item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default
10493
@code{INTEGER} with @code{INTENT(OUT)}.
10494
@item @var{COUNT_MAX}  @tab (Optional) shall be a scalar of type default
10495
@code{INTEGER} with @code{INTENT(OUT)}.
10496
@end multitable
10497
 
10498
@item @emph{Example}:
10499
@smallexample
10500
PROGRAM test_system_clock
10501
  INTEGER :: count, count_rate, count_max
10502
  CALL SYSTEM_CLOCK(count, count_rate, count_max)
10503
  WRITE(*,*) count, count_rate, count_max
10504
END PROGRAM
10505
@end smallexample
10506
 
10507
@item @emph{See also}:
10508
@ref{DATE_AND_TIME}, @ref{CPU_TIME}
10509
@end table
10510
 
10511
 
10512
 
10513
@node TAN
10514
@section @code{TAN} --- Tangent function
10515
@fnindex TAN
10516
@fnindex DTAN
10517
@cindex trigonometric function, tangent
10518
@cindex tangent
10519
 
10520
@table @asis
10521
@item @emph{Description}:
10522
@code{TAN(X)} computes the tangent of @var{X}.
10523
 
10524
@item @emph{Standard}:
10525
Fortran 77 and later, for a complex argument Fortran 2008 or later
10526
 
10527
@item @emph{Class}:
10528
Elemental function
10529
 
10530
@item @emph{Syntax}:
10531
@code{RESULT = TAN(X)}
10532
 
10533
@item @emph{Arguments}:
10534
@multitable @columnfractions .15 .70
10535
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
10536
@end multitable
10537
 
10538
@item @emph{Return value}:
10539
The return value has same type and kind as @var{X}.
10540
 
10541
@item @emph{Example}:
10542
@smallexample
10543
program test_tan
10544
  real(8) :: x = 0.165_8
10545
  x = tan(x)
10546
end program test_tan
10547
@end smallexample
10548
 
10549
@item @emph{Specific names}:
10550
@multitable @columnfractions .20 .20 .20 .25
10551
@item Name            @tab Argument          @tab Return type       @tab Standard
10552
@item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
10553
@end multitable
10554
 
10555
@item @emph{See also}:
10556
@ref{ATAN}
10557
@end table
10558
 
10559
 
10560
 
10561
@node TANH
10562
@section @code{TANH} --- Hyperbolic tangent function
10563
@fnindex TANH
10564
@fnindex DTANH
10565
@cindex hyperbolic tangent
10566
@cindex hyperbolic function, tangent
10567
@cindex tangent, hyperbolic
10568
 
10569
@table @asis
10570
@item @emph{Description}:
10571
@code{TANH(X)} computes the hyperbolic tangent of @var{X}.
10572
 
10573
@item @emph{Standard}:
10574
Fortran 77 and later, for a complex argument Fortran 2008 or later
10575
 
10576
@item @emph{Class}:
10577
Elemental function
10578
 
10579
@item @emph{Syntax}:
10580
@code{X = TANH(X)}
10581
 
10582
@item @emph{Arguments}:
10583
@multitable @columnfractions .15 .70
10584
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
10585
@end multitable
10586
 
10587
@item @emph{Return value}:
10588
The return value has same type and kind as @var{X}. If @var{X} is
10589
complex, the imaginary part of the result is in radians. If @var{X}
10590
is @code{REAL}, the return value lies in the range
10591
@math{ - 1 \leq tanh(x) \leq 1 }.
10592
 
10593
@item @emph{Example}:
10594
@smallexample
10595
program test_tanh
10596
  real(8) :: x = 2.1_8
10597
  x = tanh(x)
10598
end program test_tanh
10599
@end smallexample
10600
 
10601
@item @emph{Specific names}:
10602
@multitable @columnfractions .20 .20 .20 .25
10603
@item Name            @tab Argument          @tab Return type       @tab Standard
10604
@item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
10605
@end multitable
10606
 
10607
@item @emph{See also}:
10608
@ref{ATANH}
10609
@end table
10610
 
10611
 
10612
 
10613
@node TIME
10614
@section @code{TIME} --- Time function
10615
@fnindex TIME
10616
@cindex time, current
10617
@cindex current time
10618
 
10619
@table @asis
10620
@item @emph{Description}:
10621
Returns the current time encoded as an integer (in the manner of the
10622
UNIX function @code{time(3)}). This value is suitable for passing to
10623
@code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10624
 
10625
This intrinsic is not fully portable, such as to systems with 32-bit
10626
@code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10627
the values returned by this intrinsic might be, or become, negative, or
10628
numerically less than previous values, during a single run of the
10629
compiled program.
10630
 
10631
See @ref{TIME8}, for information on a similar intrinsic that might be
10632
portable to more GNU Fortran implementations, though to fewer Fortran
10633
compilers.
10634
 
10635
@item @emph{Standard}:
10636
GNU extension
10637
 
10638
@item @emph{Class}:
10639
Function
10640
 
10641
@item @emph{Syntax}:
10642
@code{RESULT = TIME()}
10643
 
10644
@item @emph{Return value}:
10645
The return value is a scalar of type @code{INTEGER(4)}.
10646
 
10647
@item @emph{See also}:
10648
@ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
10649
 
10650
@end table
10651
 
10652
 
10653
 
10654
@node TIME8
10655
@section @code{TIME8} --- Time function (64-bit)
10656
@fnindex TIME8
10657
@cindex time, current
10658
@cindex current time
10659
 
10660
@table @asis
10661
@item @emph{Description}:
10662
Returns the current time encoded as an integer (in the manner of the
10663
UNIX function @code{time(3)}). This value is suitable for passing to
10664
@code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10665
 
10666
@emph{Warning:} this intrinsic does not increase the range of the timing
10667
values over that returned by @code{time(3)}. On a system with a 32-bit
10668
@code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
10669
it is converted to a 64-bit @code{INTEGER(8)} value. That means
10670
overflows of the 32-bit value can still occur. Therefore, the values
10671
returned by this intrinsic might be or become negative or numerically
10672
less than previous values during a single run of the compiled program.
10673
 
10674
@item @emph{Standard}:
10675
GNU extension
10676
 
10677
@item @emph{Class}:
10678
Function
10679
 
10680
@item @emph{Syntax}:
10681
@code{RESULT = TIME8()}
10682
 
10683
@item @emph{Return value}:
10684
The return value is a scalar of type @code{INTEGER(8)}.
10685
 
10686
@item @emph{See also}:
10687
@ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
10688
 
10689
@end table
10690
 
10691
 
10692
 
10693
@node TINY
10694
@section @code{TINY} --- Smallest positive number of a real kind
10695
@fnindex TINY
10696
@cindex limits, smallest number
10697
@cindex model representation, smallest number
10698
 
10699
@table @asis
10700
@item @emph{Description}:
10701
@code{TINY(X)} returns the smallest positive (non zero) number
10702
in the model of the type of @code{X}.
10703
 
10704
@item @emph{Standard}:
10705
Fortran 95 and later
10706
 
10707
@item @emph{Class}:
10708
Inquiry function
10709
 
10710
@item @emph{Syntax}:
10711
@code{RESULT = TINY(X)}
10712
 
10713
@item @emph{Arguments}:
10714
@multitable @columnfractions .15 .70
10715
@item @var{X} @tab Shall be of type @code{REAL}.
10716
@end multitable
10717
 
10718
@item @emph{Return value}:
10719
The return value is of the same type and kind as @var{X}
10720
 
10721
@item @emph{Example}:
10722
See @code{HUGE} for an example.
10723
@end table
10724
 
10725
 
10726
 
10727
@node TRAILZ
10728
@section @code{TRAILZ} --- Number of trailing zero bits of an integer
10729
@fnindex TRAILZ
10730
@cindex zero bits
10731
 
10732
@table @asis
10733
@item @emph{Description}:
10734
@code{TRAILZ} returns the number of trailing zero bits of an integer.
10735
 
10736
@item @emph{Standard}:
10737
Fortran 2008 and later
10738
 
10739
@item @emph{Class}:
10740
Elemental function
10741
 
10742
@item @emph{Syntax}:
10743
@code{RESULT = TRAILZ(I)}
10744
 
10745
@item @emph{Arguments}:
10746
@multitable @columnfractions .15 .70
10747
@item @var{I} @tab Shall be of type @code{INTEGER}.
10748
@end multitable
10749
 
10750
@item @emph{Return value}:
10751
The type of the return value is the default @code{INTEGER}.
10752
If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
10753
 
10754
@item @emph{Example}:
10755
@smallexample
10756
PROGRAM test_trailz
10757
  WRITE (*,*) TRAILZ(8)  ! prints 3
10758
END PROGRAM
10759
@end smallexample
10760
 
10761
@item @emph{See also}:
10762
@ref{BIT_SIZE}, @ref{LEADZ}
10763
@end table
10764
 
10765
 
10766
 
10767
@node TRANSFER
10768
@section @code{TRANSFER} --- Transfer bit patterns
10769
@fnindex TRANSFER
10770
@cindex bits, move
10771
@cindex type cast
10772
 
10773
@table @asis
10774
@item @emph{Description}:
10775
Interprets the bitwise representation of @var{SOURCE} in memory as if it
10776
is the representation of a variable or array of the same type and type
10777
parameters as @var{MOLD}.
10778
 
10779
This is approximately equivalent to the C concept of @emph{casting} one
10780
type to another.
10781
 
10782
@item @emph{Standard}:
10783
Fortran 95 and later
10784
 
10785
@item @emph{Class}:
10786
Transformational function
10787
 
10788
@item @emph{Syntax}:
10789
@code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
10790
 
10791
@item @emph{Arguments}:
10792
@multitable @columnfractions .15 .70
10793
@item @var{SOURCE} @tab Shall be a scalar or an array of any type.
10794
@item @var{MOLD}   @tab Shall be a scalar or an array of any type.
10795
@item @var{SIZE}   @tab (Optional) shall be a scalar of type
10796
@code{INTEGER}.
10797
@end multitable
10798
 
10799
@item @emph{Return value}:
10800
The result has the same type as @var{MOLD}, with the bit level
10801
representation of @var{SOURCE}.  If @var{SIZE} is present, the result is
10802
a one-dimensional array of length @var{SIZE}.  If @var{SIZE} is absent
10803
but @var{MOLD} is an array (of any size or shape), the result is a one-
10804
dimensional array of the minimum length needed to contain the entirety
10805
of the bitwise representation of @var{SOURCE}.   If @var{SIZE} is absent
10806
and @var{MOLD} is a scalar, the result is a scalar.
10807
 
10808
If the bitwise representation of the result is longer than that of
10809
@var{SOURCE}, then the leading bits of the result correspond to those of
10810
@var{SOURCE} and any trailing bits are filled arbitrarily.
10811
 
10812
When the resulting bit representation does not correspond to a valid
10813
representation of a variable of the same type as @var{MOLD}, the results
10814
are undefined, and subsequent operations on the result cannot be
10815
guaranteed to produce sensible behavior.  For example, it is possible to
10816
create @code{LOGICAL} variables for which @code{@var{VAR}} and
10817
@code{.NOT.@var{VAR}} both appear to be true.
10818
 
10819
@item @emph{Example}:
10820
@smallexample
10821
PROGRAM test_transfer
10822
  integer :: x = 2143289344
10823
  print *, transfer(x, 1.0)    ! prints "NaN" on i686
10824
END PROGRAM
10825
@end smallexample
10826
@end table
10827
 
10828
 
10829
 
10830
@node TRANSPOSE
10831
@section @code{TRANSPOSE} --- Transpose an array of rank two
10832
@fnindex TRANSPOSE
10833
@cindex array, transpose
10834
@cindex matrix, transpose
10835
@cindex transpose
10836
 
10837
@table @asis
10838
@item @emph{Description}:
10839
Transpose an array of rank two. Element (i, j) of the result has the value
10840
@code{MATRIX(j, i)}, for all i, j.
10841
 
10842
@item @emph{Standard}:
10843
Fortran 95 and later
10844
 
10845
@item @emph{Class}:
10846
Transformational function
10847
 
10848
@item @emph{Syntax}:
10849
@code{RESULT = TRANSPOSE(MATRIX)}
10850
 
10851
@item @emph{Arguments}:
10852
@multitable @columnfractions .15 .70
10853
@item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
10854
@end multitable
10855
 
10856
@item @emph{Return value}:
10857
The result has the same type as @var{MATRIX}, and has shape
10858
@code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
10859
@end table
10860
 
10861
 
10862
 
10863
@node TRIM
10864
@section @code{TRIM} --- Remove trailing blank characters of a string
10865
@fnindex TRIM
10866
@cindex string, remove trailing whitespace
10867
 
10868
@table @asis
10869
@item @emph{Description}:
10870
Removes trailing blank characters of a string.
10871
 
10872
@item @emph{Standard}:
10873
Fortran 95 and later
10874
 
10875
@item @emph{Class}:
10876
Transformational function
10877
 
10878
@item @emph{Syntax}:
10879
@code{RESULT = TRIM(STRING)}
10880
 
10881
@item @emph{Arguments}:
10882
@multitable @columnfractions .15 .70
10883
@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
10884
@end multitable
10885
 
10886
@item @emph{Return value}:
10887
A scalar of type @code{CHARACTER} which length is that of @var{STRING}
10888
less the number of trailing blanks.
10889
 
10890
@item @emph{Example}:
10891
@smallexample
10892
PROGRAM test_trim
10893
  CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
10894
  WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
10895
END PROGRAM
10896
@end smallexample
10897
 
10898
@item @emph{See also}:
10899
@ref{ADJUSTL}, @ref{ADJUSTR}
10900
@end table
10901
 
10902
 
10903
 
10904
@node TTYNAM
10905
@section @code{TTYNAM} --- Get the name of a terminal device.
10906
@fnindex TTYNAM
10907
@cindex system, terminal
10908
 
10909
@table @asis
10910
@item @emph{Description}:
10911
Get the name of a terminal device. For more information,
10912
see @code{ttyname(3)}.
10913
 
10914
This intrinsic is provided in both subroutine and function forms;
10915
however, only one form can be used in any given program unit.
10916
 
10917
@item @emph{Standard}:
10918
GNU extension
10919
 
10920
@item @emph{Class}:
10921
Subroutine, function
10922
 
10923
@item @emph{Syntax}:
10924
@multitable @columnfractions .80
10925
@item @code{CALL TTYNAM(UNIT, NAME)}
10926
@item @code{NAME = TTYNAM(UNIT)}
10927
@end multitable
10928
 
10929
@item @emph{Arguments}:
10930
@multitable @columnfractions .15 .70
10931
@item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
10932
@item @var{NAME} @tab Shall be of type @code{CHARACTER}.
10933
@end multitable
10934
 
10935
@item @emph{Example}:
10936
@smallexample
10937
PROGRAM test_ttynam
10938
  INTEGER :: unit
10939
  DO unit = 1, 10
10940
    IF (isatty(unit=unit)) write(*,*) ttynam(unit)
10941
  END DO
10942
END PROGRAM
10943
@end smallexample
10944
 
10945
@item @emph{See also}:
10946
@ref{ISATTY}
10947
@end table
10948
 
10949
 
10950
 
10951
@node UBOUND
10952
@section @code{UBOUND} --- Upper dimension bounds of an array
10953
@fnindex UBOUND
10954
@cindex array, upper bound
10955
 
10956
@table @asis
10957
@item @emph{Description}:
10958
Returns the upper bounds of an array, or a single upper bound
10959
along the @var{DIM} dimension.
10960
@item @emph{Standard}:
10961
Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10962
 
10963
@item @emph{Class}:
10964
Inquiry function
10965
 
10966
@item @emph{Syntax}:
10967
@code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
10968
 
10969
@item @emph{Arguments}:
10970
@multitable @columnfractions .15 .70
10971
@item @var{ARRAY} @tab Shall be an array, of any type.
10972
@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
10973
@item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
10974
expression indicating the kind parameter of the result.
10975
@end multitable
10976
 
10977
@item @emph{Return value}:
10978
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10979
@var{KIND} is absent, the return value is of default integer kind.
10980
If @var{DIM} is absent, the result is an array of the upper bounds of
10981
@var{ARRAY}.  If @var{DIM} is present, the result is a scalar
10982
corresponding to the upper bound of the array along that dimension.  If
10983
@var{ARRAY} is an expression rather than a whole array or array
10984
structure component, or if it has a zero extent along the relevant
10985
dimension, the upper bound is taken to be the number of elements along
10986
the relevant dimension.
10987
 
10988
@item @emph{See also}:
10989
@ref{LBOUND}
10990
@end table
10991
 
10992
 
10993
 
10994
@node UMASK
10995
@section @code{UMASK} --- Set the file creation mask
10996
@fnindex UMASK
10997
@cindex file system, file creation mask
10998
 
10999
@table @asis
11000
@item @emph{Description}:
11001
Sets the file creation mask to @var{MASK}. If called as a function, it
11002
returns the old value. If called as a subroutine and argument @var{OLD}
11003
if it is supplied, it is set to the old value. See @code{umask(2)}.
11004
 
11005
@item @emph{Standard}:
11006
GNU extension
11007
 
11008
@item @emph{Class}:
11009
Subroutine, function
11010
 
11011
@item @emph{Syntax}:
11012
@code{CALL UMASK(MASK [, OLD])}
11013
@code{OLD = UMASK(MASK)}
11014
 
11015
@item @emph{Arguments}:
11016
@multitable @columnfractions .15 .70
11017
@item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
11018
@item @var{OLD} @tab (Optional) Shall be a scalar of type
11019
@code{INTEGER}.
11020
@end multitable
11021
 
11022
@end table
11023
 
11024
 
11025
 
11026
@node UNLINK
11027
@section @code{UNLINK} --- Remove a file from the file system
11028
@fnindex UNLINK
11029
@cindex file system, remove file
11030
 
11031
@table @asis
11032
@item @emph{Description}:
11033
Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
11034
used to mark the end of the name in @var{PATH}; otherwise, trailing
11035
blanks in the file name are ignored.  If the @var{STATUS} argument is
11036
supplied, it contains 0 on success or a nonzero error code upon return;
11037
see @code{unlink(2)}.
11038
 
11039
This intrinsic is provided in both subroutine and function forms;
11040
however, only one form can be used in any given program unit.
11041
 
11042
@item @emph{Standard}:
11043
GNU extension
11044
 
11045
@item @emph{Class}:
11046
Subroutine, function
11047
 
11048
@item @emph{Syntax}:
11049
@multitable @columnfractions .80
11050
@item @code{CALL UNLINK(PATH [, STATUS])}
11051
@item @code{STATUS = UNLINK(PATH)}
11052
@end multitable
11053
 
11054
@item @emph{Arguments}:
11055
@multitable @columnfractions .15 .70
11056
@item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
11057
@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
11058
@end multitable
11059
 
11060
@item @emph{See also}:
11061
@ref{LINK}, @ref{SYMLNK}
11062
@end table
11063
 
11064
 
11065
 
11066
@node UNPACK
11067
@section @code{UNPACK} --- Unpack an array of rank one into an array
11068
@fnindex UNPACK
11069
@cindex array, unpacking
11070
@cindex array, increase dimension
11071
@cindex array, scatter elements
11072
 
11073
@table @asis
11074
@item @emph{Description}:
11075
Store the elements of @var{VECTOR} in an array of higher rank.
11076
 
11077
@item @emph{Standard}:
11078
Fortran 95 and later
11079
 
11080
@item @emph{Class}:
11081
Transformational function
11082
 
11083
@item @emph{Syntax}:
11084
@code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
11085
 
11086
@item @emph{Arguments}:
11087
@multitable @columnfractions .15 .70
11088
@item @var{VECTOR} @tab Shall be an array of any type and rank one. It
11089
shall have at least as many elements as @var{MASK} has @code{TRUE} values.
11090
@item @var{MASK}   @tab Shall be an array of type @code{LOGICAL}.
11091
@item @var{FIELD}  @tab Shall be of the same type as @var{VECTOR} and have
11092
the same shape as @var{MASK}.
11093
@end multitable
11094
 
11095
@item @emph{Return value}:
11096
The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
11097
of @var{MASK} replaced by values from @var{VECTOR} in array element order.
11098
 
11099
@item @emph{Example}:
11100
@smallexample
11101
PROGRAM test_unpack
11102
  integer :: vector(2)  = (/1,1/)
11103
  logical :: mask(4)  = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
11104
  integer :: field(2,2) = 0, unity(2,2)
11105
 
11106
  ! result: unity matrix
11107
  unity = unpack(vector, reshape(mask, (/2,2/)), field)
11108
END PROGRAM
11109
@end smallexample
11110
 
11111
@item @emph{See also}:
11112
@ref{PACK}, @ref{SPREAD}
11113
@end table
11114
 
11115
 
11116
 
11117
@node VERIFY
11118
@section @code{VERIFY} --- Scan a string for the absence of a set of characters
11119
@fnindex VERIFY
11120
@cindex string, find missing set
11121
 
11122
@table @asis
11123
@item @emph{Description}:
11124
Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
11125
 
11126
If @var{BACK} is either absent or equals @code{FALSE}, this function
11127
returns the position of the leftmost character of @var{STRING} that is
11128
not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
11129
is returned. If all characters of @var{SET} are found in @var{STRING}, the
11130
result is zero.
11131
 
11132
@item @emph{Standard}:
11133
Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11134
 
11135
@item @emph{Class}:
11136
Elemental function
11137
 
11138
@item @emph{Syntax}:
11139
@code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
11140
 
11141
@item @emph{Arguments}:
11142
@multitable @columnfractions .15 .70
11143
@item @var{STRING} @tab Shall be of type @code{CHARACTER}.
11144
@item @var{SET}    @tab Shall be of type @code{CHARACTER}.
11145
@item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
11146
@item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
11147
expression indicating the kind parameter of the result.
11148
@end multitable
11149
 
11150
@item @emph{Return value}:
11151
The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11152
@var{KIND} is absent, the return value is of default integer kind.
11153
 
11154
@item @emph{Example}:
11155
@smallexample
11156
PROGRAM test_verify
11157
  WRITE(*,*) VERIFY("FORTRAN", "AO")           ! 1, found 'F'
11158
  WRITE(*,*) VERIFY("FORTRAN", "FOO")          ! 3, found 'R'
11159
  WRITE(*,*) VERIFY("FORTRAN", "C++")          ! 1, found 'F'
11160
  WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.)  ! 7, found 'N'
11161
  WRITE(*,*) VERIFY("FORTRAN", "FORTRAN")      ! 0' found none
11162
END PROGRAM
11163
@end smallexample
11164
 
11165
@item @emph{See also}:
11166
@ref{SCAN}, @ref{INDEX intrinsic}
11167
@end table
11168
 
11169
 
11170
 
11171
@node XOR
11172
@section @code{XOR} --- Bitwise logical exclusive OR
11173
@fnindex XOR
11174
@cindex bitwise logical exclusive or
11175
@cindex logical exclusive or, bitwise
11176
 
11177
@table @asis
11178
@item @emph{Description}:
11179
Bitwise logical exclusive or.
11180
 
11181
This intrinsic routine is provided for backwards compatibility with
11182
GNU Fortran 77.  For integer arguments, programmers should consider
11183
the use of the @ref{IEOR} intrinsic and for logical arguments the
11184
@code{.NEQV.} operator, which are both defined by the Fortran standard.
11185
 
11186
@item @emph{Standard}:
11187
GNU extension
11188
 
11189
@item @emph{Class}:
11190
Function
11191
 
11192
@item @emph{Syntax}:
11193
@code{RESULT = XOR(I, J)}
11194
 
11195
@item @emph{Arguments}:
11196
@multitable @columnfractions .15 .70
11197
@item @var{I} @tab The type shall be either  a scalar @code{INTEGER}
11198
type or a scalar @code{LOGICAL} type.
11199
@item @var{J} @tab The type shall be the same as the type of @var{I}.
11200
@end multitable
11201
 
11202
@item @emph{Return value}:
11203
The return type is either a scalar @code{INTEGER} or a scalar
11204
@code{LOGICAL}.  If the kind type parameters differ, then the
11205
smaller kind type is implicitly converted to larger kind, and the
11206
return has the larger kind.
11207
 
11208
@item @emph{Example}:
11209
@smallexample
11210
PROGRAM test_xor
11211
  LOGICAL :: T = .TRUE., F = .FALSE.
11212
  INTEGER :: a, b
11213
  DATA a / Z'F' /, b / Z'3' /
11214
 
11215
  WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
11216
  WRITE (*,*) XOR(a, b)
11217
END PROGRAM
11218
@end smallexample
11219
 
11220
@item @emph{See also}:
11221
Fortran 95 elemental function: @ref{IEOR}
11222
@end table
11223
 
11224
 
11225
 
11226
@node Intrinsic Modules
11227
@chapter Intrinsic Modules
11228
@cindex intrinsic Modules
11229
 
11230
@menu
11231
* ISO_FORTRAN_ENV::
11232
* ISO_C_BINDING::
11233
* OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
11234
@end menu
11235
 
11236
@node ISO_FORTRAN_ENV
11237
@section @code{ISO_FORTRAN_ENV}
11238
@table @asis
11239
@item @emph{Standard}:
11240
Fortran 2003 and later; @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64},
11241
@code{REAL32}, @code{REAL64}, @code{REAL128} are Fortran 2008 or later
11242
@end table
11243
 
11244
The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
11245
named constants:
11246
 
11247
@table @asis
11248
@item @code{CHARACTER_STORAGE_SIZE}:
11249
Size in bits of the character storage unit.
11250
 
11251
@item @code{ERROR_UNIT}:
11252
Identifies the preconnected unit used for error reporting.
11253
 
11254
@item @code{FILE_STORAGE_SIZE}:
11255
Size in bits of the file-storage unit.
11256
 
11257
@item @code{INPUT_UNIT}:
11258
Identifies the preconnected unit identified by the asterisk
11259
(@code{*}) in @code{READ} statement.
11260
 
11261
@item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}
11262
Kind type parameters to specify an INTEGER type with a storage
11263
size of 16, 32, and 64 bits. It is negative if a target platform
11264
does not support the particular kind.
11265
 
11266
@item @code{IOSTAT_END}:
11267
The value assigned to the variable passed to the IOSTAT= specifier of
11268
an input/output statement if an end-of-file condition occurred.
11269
 
11270
@item @code{IOSTAT_EOR}:
11271
The value assigned to the variable passed to the IOSTAT= specifier of
11272
an input/output statement if an end-of-record condition occurred.
11273
 
11274
@item @code{NUMERIC_STORAGE_SIZE}:
11275
The size in bits of the numeric storage unit.
11276
 
11277
@item @code{OUTPUT_UNIT}:
11278
Identifies the preconnected unit identified by the asterisk
11279
(@code{*}) in @code{WRITE} statement.
11280
 
11281
@item @code{REAL32}, @code{REAL64}, @code{REAL128}
11282
Kind type parameters to specify a REAL type with a storage
11283
size of 32, 64, and 128 bits. It is negative if a target platform
11284
does not support the particular kind.
11285
@end table
11286
 
11287
 
11288
 
11289
@node ISO_C_BINDING
11290
@section @code{ISO_C_BINDING}
11291
@table @asis
11292
@item @emph{Standard}:
11293
Fortran 2003 and later, GNU extensions
11294
@end table
11295
 
11296
The following intrinsic procedures are provided by the module; their
11297
definition can be found in the section Intrinsic Procedures of this
11298
manual.
11299
 
11300
@table @asis
11301
@item @code{C_ASSOCIATED}
11302
@item @code{C_F_POINTER}
11303
@item @code{C_F_PROCPOINTER}
11304
@item @code{C_FUNLOC}
11305
@item @code{C_LOC}
11306
@end table
11307
@c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
11308
@c don't really know why.
11309
 
11310
The @code{ISO_C_BINDING} module provides the following named constants of
11311
type default integer, which can be used as KIND type parameters.
11312
 
11313
In addition to the integer named constants required by the Fortran 2003
11314
standard, GNU Fortran provides as an extension named constants for the
11315
128-bit integer types supported by the C compiler: @code{C_INT128_T,
11316
C_INT_LEAST128_T, C_INT_FAST128_T}.
11317
 
11318
@multitable @columnfractions .15 .35 .35 .35
11319
@item Fortran Type  @tab Named constant         @tab C type                                @tab Extension
11320
@item @code{INTEGER}@tab @code{C_INT}           @tab @code{int}
11321
@item @code{INTEGER}@tab @code{C_SHORT}         @tab @code{short int}
11322
@item @code{INTEGER}@tab @code{C_LONG}          @tab @code{long int}
11323
@item @code{INTEGER}@tab @code{C_LONG_LONG}     @tab @code{long long int}
11324
@item @code{INTEGER}@tab @code{C_SIGNED_CHAR}   @tab @code{signed char}/@code{unsigned char}
11325
@item @code{INTEGER}@tab @code{C_SIZE_T}        @tab @code{size_t}
11326
@item @code{INTEGER}@tab @code{C_INT8_T}        @tab @code{int8_t}
11327
@item @code{INTEGER}@tab @code{C_INT16_T}       @tab @code{int16_t}
11328
@item @code{INTEGER}@tab @code{C_INT32_T}       @tab @code{int32_t}
11329
@item @code{INTEGER}@tab @code{C_INT64_T}       @tab @code{int64_t}
11330
@item @code{INTEGER}@tab @code{C_INT128_T}      @tab @code{int128_t}                      @tab Ext.
11331
@item @code{INTEGER}@tab @code{C_INT_LEAST8_T}  @tab @code{int_least8_t}
11332
@item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
11333
@item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
11334
@item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
11335
@item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t}                @tab Ext.
11336
@item @code{INTEGER}@tab @code{C_INT_FAST8_T}   @tab @code{int_fast8_t}
11337
@item @code{INTEGER}@tab @code{C_INT_FAST16_T}  @tab @code{int_fast16_t}
11338
@item @code{INTEGER}@tab @code{C_INT_FAST32_T}  @tab @code{int_fast32_t}
11339
@item @code{INTEGER}@tab @code{C_INT_FAST64_T}  @tab @code{int_fast64_t}
11340
@item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t}                 @tab Ext.
11341
@item @code{INTEGER}@tab @code{C_INTMAX_T}      @tab @code{intmax_t}
11342
@item @code{INTEGER}@tab @code{C_INTPTR_T}      @tab @code{intptr_t}
11343
@item @code{REAL}   @tab @code{C_FLOAT}         @tab @code{float}
11344
@item @code{REAL}   @tab @code{C_DOUBLE}        @tab @code{double}
11345
@item @code{REAL}   @tab @code{C_LONG_DOUBLE}   @tab @code{long double}
11346
@item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
11347
@item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
11348
@item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
11349
@item @code{LOGICAL}@tab @code{C_BOOL}          @tab @code{_Bool}
11350
@item @code{CHARACTER}@tab @code{C_CHAR}        @tab @code{char}
11351
@end multitable
11352
 
11353
Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
11354
are defined.
11355
 
11356
@multitable @columnfractions .20 .45 .15
11357
@item Name                     @tab C definition    @tab Value
11358
@item @code{C_NULL_CHAR}       @tab null character  @tab @code{'\0'}
11359
@item @code{C_ALERT}           @tab alert           @tab @code{'\a'}
11360
@item @code{C_BACKSPACE}       @tab backspace       @tab @code{'\b'}
11361
@item @code{C_FORM_FEED}       @tab form feed       @tab @code{'\f'}
11362
@item @code{C_NEW_LINE}        @tab new line        @tab @code{'\n'}
11363
@item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
11364
@item @code{C_HORIZONTAL_TAB}  @tab horizontal tab  @tab @code{'\t'}
11365
@item @code{C_VERTICAL_TAB}    @tab vertical tab    @tab @code{'\v'}
11366
@end multitable
11367
 
11368
@node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
11369
@section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
11370
@table @asis
11371
@item @emph{Standard}:
11372
OpenMP Application Program Interface v3.0
11373
@end table
11374
 
11375
 
11376
The OpenMP Fortran runtime library routines are provided both in
11377
a form of two Fortran 90 modules, named @code{OMP_LIB} and
11378
@code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
11379
@file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
11380
in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
11381
the named constants defined in the @code{OMP_LIB_KINDS} module are listed
11382
below.
11383
 
11384
For details refer to the actual
11385
@uref{http://www.openmp.org/mp-documents/spec30.pdf,
11386
OpenMP Application Program Interface v3.0}.
11387
 
11388
@code{OMP_LIB_KINDS} provides the following scalar default-integer
11389
named constants:
11390
 
11391
@table @asis
11392
@item @code{omp_integer_kind}
11393
@item @code{omp_logical_kind}
11394
@item @code{omp_lock_kind}
11395
@item @code{omp_nest_lock_kind}
11396
@item @code{omp_sched_kind}
11397
@end table

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.