original (Aug2006):
http://people.scs.fsu.edu/~burkardt/html/f90_intrinsics.html
by John Burkardt
F90_INTRINSICS
FORTRAN90 Intrinsic Functions
FORTRAN90 includes about 100 intrinsic functions (and a few
intrinsic subroutines). This document gives a short list of
the definitions of these intrinsic functions.
Most users are familiar with the
simpler arithmetic functions, such as abs, max
and sqrt. However, a great many new routines have been
added, and in some cases the definitions of the older functions have
been extended so that they can accept vectors and arrays as
arguments.
The FORTRAN90 intrinsic functions may be broadly divided into groups of
-
arithmetic functions
-
vector and matrix functions
-
logic and bit manipulation
-
character manipulation
-
data type conversion
-
arithmetic model inquiry
-
data type inquiry
Reference:
-
Jeanne Adams, Walter Brainerd, Jeanne Martin, Brian Smith,
Jerrold Wagener,
Fortran90 Handbook,
Complete ANSI/ISO Reference,
McGraw Hill, 1992,
ISBN: 0-07-000406-4.
-
Miles Ellis, Ivor Philips, Thomas Lahey,
Fortran90 Programming,
Addison-Wesley, 1994,
ISBN: 0-201-54446-6,
LC: QA76.73.F25E435
-
The F90_INTRINSICS directory contains a sample program
for carrying out some simple tests of FORTRAN90 intrinsic
functions.
FORTRAN90 Intrinsic Functions List:
-
result = abs ( a )
-
returns the absolute value of A.
-
A must be of type integer, real or complex;
-
RESULT is integer if A is integer;
RESULT is real if A is complex or real.
-
Note that if A is complex, the absolute value is defined
as the square root of the sum of the squares of the
real and imaginary parts.
-
result = achar ( i )
-
Returns the character whose ASCII index is I.
-
The value of I should satisfy 0 <= I <= 255.
-
RESULT is a character.
-
This is simply a version of the CHAR function that guarantees
that the ASCII representation is being used.
-
The IACHAR function is the inverse of the ACHAR function;
-
ACHAR(48) = '0', ACHAR(65) = 'A', ACHAR(97) = 'a'.
-
result = acos ( x )
-
returns the arc-cosine or inverse cosine of X.
-
X must be of type real;
-
RESULT is real.
-
The value of X must satisfy -1 <= X <= 1;
On many systems, the smallest deviation from this requirement
will cause a fatal error, with an unhelpful error message.
-
result = adjustl ( string )
-
returns a copy of the input string that has been "left justified".
-
The output string has the same length as the input string, but
the initial blanks have been moved to the end.
-
adjustl ( " FRED FLINTSTONE " ) = "FRED FLINTSTONE ";
The two initial blanks have been moved to the end.
-
result = adjustr ( string )
-
returns a copy of the input string that has been "right justified".
-
The output string has the same length as the input string, but
the final blanks have been moved to the beginning.
-
adjustr ( " FRED FLINTSTONE " ) = " FRED FLINTSTONE";
The two final blanks have been moved to the beginning.
-
result = aimag ( z )
-
returns the imaginary part of Z.
-
aimag ( 1.0, 2.0 ) = 2.0;
-
result = aint ( a, kind )
-
rounds a real number down (towards zero);
-
the input must be real, and the output will be real.
-
the KIND type is usually omitted; if it is included, it specifies
the KIND of the output value.
-
the input value is rounded down towards zero. Thus,
aint ( 9.7 ) = 9 and aint ( -9.7 ) = -9.
-
result = all ( mask, dim )
-
returns TRUE if ALL the conditions are true.
-
MASK is a vector or array of values (TRUE/FALSE),
or variables or expressions of type logical.
-
in the simplest usages, DIM is omitted, MASK is a vector,
and the value returned by ALL is a scalar. Thus,
to check that all entries of a vector are positive,
you might use the code:
if ( all ( x(1:n) > 0.0 ) ) then
-
In fancier applications, DIM is an integer between 1 and N,
where N is the rank of MASK, and ALL returns a logical
array of rank N-1, with the DIM-th dimension replaced by a TRUE or
FALSE value depending on whether "all" the entries of MASK in
that component were true.
-
For the matrix A =:
[ 2, 4, 6 ]
[ 1, 3, 2 ]
all ( mod ( A, 2 ) == 0 ) = FALSE;
all ( mod ( A, 2 ) == 0, DIM = 1 ) == (FALSE,FALSE,TRUE),
all ( mod ( A, 2 ) == 0, DIM = 2 ) == (TRUE,FALSE).
-
result = allocated ( array )
-
returns TRUE if an allocatable array is, in fact, currently
allocated. You declare an array to be ALLOCATABLE. You then
request storage for it with the ALLOCATE command. You free
that storage with the DEALLOCATE command. In between the
ALLOCATE and DEALLOCATE commands, the array is said to be
allocated.
-
result = anint ( a, kind )
-
rounds a real number to the nearest integer value;
-
the input must be real, and the output will be real.
-
the KIND type is usually omitted; if it is included, it specifies
the KIND of the output value.
-
the input value is rounded towards the nearest integer.
Thus,
anint ( 9.3 ) = 9, anint ( 9.7 ) = 10. "Ties" are rounded
upwards, or more correctly, away from 0.
anint ( 9.5 ) = 10 and anint ( -9.5 ) = -10.
-
result = any ( mask, dim )
-
returns TRUE if ANY of the conditions are true.
-
MASK is a vector or array of logical values, (TRUE/FALSE),
or logical variables, or logical expressions.
-
in the simplest usages, DIM is omitted, MASK is a vector,
and the value returned by ANY is a scalar. Thus,
to check whether any entries of a vector are zero,
you might use the code:
if ( any ( x(1:n) == 0.0 ) ) then
-
In fancier applications, DIM is an integer between 1 and N,
where N is the rank of MASK, and ANY returns a logical array
of rank N-1, with the DIM-th dimension replaced by a TRUE or
FALSE value depending on whether "any" the entries of MASK in
that component were true.
-
For the matrix A =:
[ 2, 4, 6 ]
[ 8, 3, 5 ]
any ( mod ( A, 2 ) == 0 ) = TRUE;
any ( mod ( A, 2 ) == 0, DIM = 1 ) == (FALSE,TRUE,TRUE),
any ( mod ( A, 2 ) == 0, DIM = 2 ) == (FALSE,TRUE).
-
result = asin ( x )
-
returns the arc-sine or inverse sine of X.
-
X must be of type real;
-
RESULT is real.
-
The value of X must satisfy -1 <= X <= 1;
On many systems, the smallest deviation from this requirement
will cause a fatal error, with an unhelpful error message.
-
result = associated ( pointer, target )
-
returns the association status of the pointer argument,
or indicates that the pointer is associated with the target.
-
result = atan ( x )
-
returns the arc-tangent or inverse tangent of X.
-
X must be of type real;
-
RESULT is real.
-
-pi/2 < RESULT < pi/2.
-
result = atan2 ( y, x )
-
returns the arc-tangent or inverse tangent of Y/X.
-
X and Y must be of type real;
-
RESULT is real.
-
-pi < RESULT <= pi.
-
result = bit_size ( i )
-
returns the number of bits associated with the storage
of an integer of the kind of the input argument I.
-
On most systems, the typical return value would be 32.
-
result = btest ( i, pos )
-
returns the value (0 or 1) of a given bit.
-
The argument I must be an integer;
-
The argument POS must be an integer
satisfying 0 <= POS < BIT_SIZE(I).
(Typically, 0 <= POS < 32.)
-
result = ceiling ( a )
-
Returns the smallest integer greater than or equal to A.
-
The argument A must be real;
-
The value I = ceiling ( A ) is the smallest
integer such that A <= I.
-
ceiling ( -9.8 ) = -9;
ceiling ( 3.6 ) = 4;
ceiling ( 4.0 ) = 4;
-
result = char ( i, kind )
-
Returns the character whose index is I.
-
The value of I must be an integer, and should satisfy
0 <= I <= 255.
-
It is usually true that CHAR(48) = '0', CHAR(65) = 'A',
CHAR(97) = 'a', but this will only happen if your computer
uses the ASCII coding convention.
-
The KIND argument is usually omitted, so the typical
invocation is C = char ( I );
-
The ICHAR function is the inverse of the CHAR function;
-
The ACHAR function is a version of CHAR that always uses
the ASCII coding convention.
-
result = cmplx ( x, y, kind )
-
returns a complex value with real part X and imaginary part Y,
with the specified KIND.
-
The arguments X and Y may be integer, real
or complex;
-
The square root of -1 is cmplx ( 0, 1 );
-
(Rarely used): If X is a real number, then cmplx ( x )
is the same as cmplx ( x, 0 ); if X is complex, then cmplx ( x )
is the same as cmplx ( real ( x ), aimag ( x ) );
-
(Rarely used): If both X and Y are specified, and either
value is complex, cmplx ( x, y ) is the same as
cmplx ( real ( x ), aimag ( y ) );
-
result = conjg ( z )
-
returns the conjugate of Z.
-
conjg ( 1.0, 2.0 ) = ( 1.0, -2.0 )
-
result = cos ( x )
-
returns the cosine of X.
-
X must be of type real or complex;
-
result = cosh ( x )
-
returns the hyperbolic cosine of X.
-
result = count ( mask, dim )
-
counts the number of TRUE elements of MASK in dimension DIM.
-
MASK is a vector or array of logical values, (TRUE/FALSE),
or logical variables, or logical expressions.
-
in the simplest usages, DIM is omitted, MASK is a vector,
and the value returned by COUNT is simply the number of
TRUE values. Thus, to check count the number of negative
entries in a vector, you could set:
negatives = count ( x(1:n) < 0.0 )
-
In fancier applications, DIM is an integer between 1 and N,
where N is the rank of MASK, and COUNT returns an integer array
of rank N-1, with the DIM-th dimension replaced by the
count of the number of entries of MASK in that component
which were true.
-
For the matrix A =:
[ 8, 2, 5 ]
[ 7, 4, 3 ]
count ( mod ( A, 2 ) == 0 ) = 3;
count ( mod ( A, 2 ) == 0, DIM = 1 ) == (1, 2, 0),
count ( mod ( A, 2 ) == 0, DIM = 2 ) == (2, 1).
-
result = cshift ( array, shift, dim )
-
performs a circular shift on an array.
-
In a circular shift, no elements are "lost". Elements
that are assigned to locations beyond the last available
location are "wrapped around" to the beginning of the array.
-
array may be of any type..
-
shift is the shift to the right to be applied to
every entry. If array is a vector, shift
is a scalar. Otherwise, the use of shift is
too complicated for these notes!
-
dim may be omitted, and defaults to 1.
Otherwise, it specifies the dimension along which
the shift takes place.
-
call date_and_time ( date, time zone, values )
-
returns date and time information.
-
DATE_AND_TIME is a subroutine, not a function.
-
All arguments are optional.
-
DATE is a character*8 variable that contains the date.
-
TIME is a character*10 variable that contains the time.
-
ZONE is a character*5 variable that contains the date.
-
VALUES is an integer array of dimensin 8, containing
the year, the month, the day, the time difference
with respect to UTC in minutes, the hour, the minutes,
the seconds, and the milliseconds of the current date.
-
result = dble ( a )
-
converts the value to the equivalent double precision value.
-
a may be integer, real or complex.
-
If a is complex, the real part of A is returned as a
double precision real value.
-
result = digits ( x )
-
returns the number of significant digits in numbers of the
type and kind of X.
-
X can be of type integer or real.
-
result = dim ( x, y )
-
returns max ( x - y, 0 );
-
X and Y must be integer or real.
-
(Rarely used!) In fact, no one uses this function!
-
result = dot_product ( a, b )
-
returns the dot product of vectors A and B.
-
A and B must both be logical, or both numeric
(complex, integer or real).
-
A and B must both be vectors, that is, arrays of rank 1.
-
The lengths of A and B must be the same.
-
If the first argument A is complex, then the dot product
is taken using the complex conjugate of A.
-
result = dprod ( x, y )
-
returns the double precision product of two real values;
-
the input arguments must be of type default real, and
the output argument will be of type double precision real.
-
this is an old function, and rarely used.
-
result = eoshift ( array, shift, boundary, dim )
-
performs an "end off" shift on an array.
-
In an "end off" shift, elements which are shifted to positions
before the first index or after the last index are lost.
Positions which have no element coming into them are set
to a "boundary value".
-
array may be of any type..
-
shift is the shift to the right to be applied to
every entry. If array is a vector, shift
is a scalar. Otherwise, the use of shift is
too complicated for these notes!
-
boundary may be omitted, and defaults to 0
(or FALSE for logical arrays, and blank for characters).
Otherwise, it specifies the "boundary value" that
is assigned to entries into which no element is shifted.
-
dim may be omitted, and defaults to 1.
Otherwise, it specifies the dimension along which
the shift takes place.
-
result = epsilon ( x )
-
returns the "machine precision" for numbers of the same type as X.
-
The value X must be of type real.
-
The value returned is typically the smallest power of 2
that can be added to 1 without disappearing because of roundoff.
-
For default real X, the value might be about 1.19E-7, and
for double precision real X, the value might be about 2.22E-16.
-
result = exp ( x )
-
returns the exponential function of X, that is, exp ( X ).
-
X must be of type real or complex;
-
result = exponent ( x )
-
returns the exponent part of the number.
-
result = floor ( a )
-
Returns the largest integer less than or equal to A.
-
The argument A must be real;
-
The value I = floor ( A ) is the largest
integer such that i <= A.
-
floor ( -9.8 ) = -10;
floor ( 3.6 ) = 3;
floor ( 4.0 ) = 4;
-
result = fraction ( x )
-
returns the fractional part of the model representation of X.
-
X must be of type real;
-
This is not the fractional part of the decimal
representation of X. In fact, it is probably the
fractional part of the binary representation of X.
-
Recall that the model representation of a real number
has the form S*F*2^E, (assuming that our base is 2!).
-
In the usual case, then, fraction(2.5) is 0.625.
-
result = huge ( x )
-
returns the largest number in the model.
-
X may be of type real or integer;
-
HUGE(X) will be of the same type as X;
-
HUGE(1) might be 2147483647;
HUGE(1.0) might be 3.4028235E+38;
HUGE(1.0D+00) might be 1.79E+308.
-
result = iachar ( c )
-
returns an integer representing the ASCII index of character C.
-
The value of IACHAR will always satisfy 0 <= IACHAR <= 255;
-
IACHAR of '0', 'A', and 'a' is 48, 65, and 97 respectively;
-
The ACHAR function is the inverse of the IACHAR function;
-
result = iand ( i, j )
-
returns the "and" of I and J.
-
I and J must be integers, and of the same kind;
-
IAND(I,J) is the value each of whose bits is obtained
as the "and" of the corresponding bits of I and J.
-
IAND(6,9) = 6;
IAND(6,6) = 6;
IAND(6,100) = 4.
-
result = ibclr ( i, pos )
-
sets one bit to zero.
-
I must be an integer;
-
POS must be a nonnegative integer that is strictly less
than BITSIZE(I). A common range for POS might be 0 to 31.
-
IBCLR(6,0) = 6;
IBCLR(6,1) = 4;
IBCLR(6,2) = 2;
IBCLR(6,3) = 6.
-
result = ibits ( i, pos, len )
-
extracts a sequence of bits.
-
I must be an integer;
-
POS must be a nonnegative integer, and POS+LEN must
be less than or equal to BITSIZE(I).
-
LEN must be a nonnegative integer.
-
The return value is created by copying bits
POS through POS+LEN-1 from I, and placing them
right-adjusted in an integer (of the same kind as I)
whose other bits are zero.
-
result = ibset ( i, pos )
-
sets one bit to one.
-
I must be an integer;
-
POS must be a nonnegative integer that is strictly less
than BITSIZE(I). A common range for POS might be 0 to 31.
-
IBSET(6,0) = 7;
IBSET(6,1) = 6;
IBSET(6,2) = 6;
IBSET(6,3) = 14.
-
result = ichar ( c )
-
returns an integer representing the index of character C.
-
The value of ICHAR will always satisfy 0 <= ICHAR <= 255;
-
ICHAR of '0', 'A', and 'a' is usually 48, 65, and 97 respectively,
however, these values are not guaranteed because your computer
might not be using the ASCII coding convention;
-
The CHAR function is the inverse of the ICHAR function;
-
The IACHAR function is a version of ICHAR that always uses
the ASCII coding convention.
-
result = ieor ( i, j )
-
returns the "exclusive or" of I and J.
-
I and J must be integers, and of the same kind;
-
IEOR(I,J) is the value each of whose bits is obtained
as the "exclusive or" of the corresponding bits of I and J.
-
IEOR(6,9) = 15;
IEOR(6,6) = 0;
IEOR(6,100) = 98.
-
result = index ( S1, S2, BACK )
-
returns the index of the beginning of a substring in a string.
-
S1 and S2 must be character strings;
-
BACK is an optional argument, of type logical.
-
If BACK is FALSE or BACK is not included in the argument
list, then the return value is the index in S1 of the
first occurrence of the substring S2.
-
If BACK is TRUE, then the return value is the index in S1 of the
last occurrence of the substring S2.
-
the index of the first or last occurrence of S2 means the
position in S1 of the first character of S2 (which is
followed by the rest of S2!).
-
the comparison is case sensitive.
-
index ( 'THE CATATONIC CAT', 'CAT' ) = 5;
index ( 'THE CATATONIC CAT', 'cat' ) = 0;
index ( 'THE CATATONIC CAT', 'CAT', .TRUE. ) = 15.
-
result = int ( a, kind )
-
converts to an integer value.
-
A must be an integer, real or complex value;
-
KIND is optional; if used, it specifies the KIND of the result.
-
If A is of type integer, then the integer value is simply
copied (unless there are issues because of a change in KIND).
-
If A is of type real, int(A) is the integer with the
same sign as A, whose magnitude does not exceed A. Note that,
in the case where -1 < A < 1, int(A) is 0.
-
If A is of type complex, int(A) is the result of
applying the conversion operation to the real part of A.
-
int ( 7 ) = 7;
int ( 7.0 ) = 7;
int ( 7.1 ) = 7;
int ( 6.9 ) = 6;
int ( 0.9 ) = 0;
int ( -0.9 ) = 0;
int ( -1.9 ) = -1;
int ( ( 93.8, 27.2) ) = 93.
-
result = ior ( i, j )
-
returns the "inclusive or" of I and J.
-
I and J must be integers, and of the same kind;
-
IOR(I,J) is the value each of whose bits is obtained
as the "inclusive or" of the corresponding bits of I and J.
-
IEOR(6,9) = 15;
IEOR(6,6) = 6;
IEOR(6,100) = 102.
-
result = ishft ( i, shift )
-
performs a logical shift.
-
I and SHIFT must be integers. The absolute value of
SHIFT must be less than or equal to BIT_SIZE(I).
-
RESULT is an integer obtained by shifting the
bits of I by SHIFT positions. A positive SHIFT moves
bits "to the left".
-
result = ishftc ( i, shift, size )
-
performs a circular shift.
-
I and SHIFT must be integers. The absolute value of
SHIFT must be less than or equal to SIZE.
-
SIZE is an optional argument. If it is specified, it
must not exceed BIT_SIZE(I). If it is not specified,
the default value of BIT_SIZE(I) is used.
-
RESULT is an integer obtained by circularly
shifting the SIZE rightmost bits of I by SHIFT positions.
A positive SHIFT moves bits "to the left". Because a
circular shift is used, bits that move out one end
are copied in at the other end. Only the rightmost SIZE
bits are affected in any way.
-
result = kind ( x )
-
returns the value of the KIND argument of X.
-
result = lbound ( a, dim )
-
returns the lower bounds of an array.
-
A may be of any type.
-
This function is useful, for example, in determining the
lower bound on the indices of an array declared
or allocated using the form a(l:u).
-
If DIM is omitted, then RESULT is a vector
containing the lower bound of each dimension of A.
-
If DIM is present, then RESULT is the lower
bound in the given dimension of A.
-
result = len ( string )
-
returns the "declared" length of STRING.
-
STRING must be a character variable or constant.
-
len ( 'Four' ) = 4;
len ( ' Four ' ) = 6;
len ( 'Four ' ) = 6.
-
result = len_trim ( string )
-
returns the "used" length of STRING, up to the last nonblank
character.
-
STRING must be a character variable or constant.
-
len ( 'Four' ) = 4;
len ( ' Four ' ) = 5;
len ( 'Four ' ) = 4.
-
result = lge ( string_a, string_b )
-
returns TRUE if STRING_A is lexically greater than or equal to
STRING_B. If the strings are of unequal length, the comparison
is made as though the shorter string was padded with blanks at
the end.
-
result = lgt ( string_a, string_b )
-
returns TRUE if STRING_A is lexically greater than
STRING_B. If the strings are of unequal length, the comparison
is made as though the shorter string was padded with blanks at
the end.
-
result = lle ( string_a, string_b )
-
returns TRUE if STRING_A is lexically less than or equal to
STRING_B. If the strings are of unequal length, the comparison
is made as though the shorter string was padded with blanks at
the end.
-
result = llt ( string_a, string_b )
-
returns TRUE if STRING_A is lexically less than
STRING_B. If the strings are of unequal length, the comparison
is made as though the shorter string was padded with blanks at
the end.
-
result = log ( x )
-
returns the (natural) logarithm of X.
-
The value of X must satisfy 0 < X;
-
result = log10 ( x )
-
returns the base 10 logarithm of X.
-
The value of X must satisfy 0 < X;
-
result = logical ( l, kind )
-
converts a logical value to a particular logical kind.
-
L is a logical constant, expression or variable.
-
KIND is an optional argument. If it is omitted, then the
value returned is a logical value of the default kind.
-
If KIND is included, then it may be used to specify a
particular logical KIND for the result.
-
(Especially because this function only accepts logical
arguments, and because there is hardly any reason to
use any but the default logical kind, this function
seems nearly worthless to me.)
-
result = matmul ( a, b )
-
returns the product of matrix a and matrix b.
-
The arguments A and B must be of type complex,
real, integer or logical(!).
-
If either matrix is logical type, then both must be;
but otherwise, it is permissible for the matrices to
be of different numeric types.
-
A and B must be vectors (rank 1) or matrices (rank 2).
At least one of A and B must be a matrix.
-
The dimensions of A and B must conform to the usual
rules that allow for matrix multiplication.
-
result = max ( a1, a2, a3, ... )
-
returns the maximum of A1, A2, A3...
-
The arguments must be all be of the same type and kind;
the arguments must be integer or real;
-
RESULT has the same type and kind as the arguments.
-
The most common use is A = max ( A1, A2 ), but the
number of arguments may be greater;
-
result = maxexponent ( X )
-
returns the maximum exponent in the model for numbers of the same type
and kind as X;
-
X must be of type real;
-
typically, the returned value is the maximum exponent base 2
for real numbers of the given kind.
-
result = maxloc ( array, mask )
-
returns the index of the maximum entry in the array.
-
ARRAY must be integer or real
-
MASK is an optional logical argument. If it
is included, it must be an array of the same shape
as ARRAY. Only elements of ARRAY for which the corresponding
entry of MASK is true will then be included in the
computation.
-
The output is a vector whose dimension is the rank of
ARRAY, and which contains the coordinates of the entry
of maximum value. If MASK has been supplied then the
value is the index of the maximum entry for which MASK
is TRUE.
-
Note that, even if ARRAY is a vector, the output is
a vector (in this case of length 1), and not a scalar.
-
result = maxval ( array, dim, mask )
-
returns the maximum entry in the array.
-
ARRAY must be integer or real
-
DIM is an optional integer argument. If it
is included, it must be between 1 and the rank of ARRAY.
-
MASK is an optional logical argument. If it
is included, it must be an array of the same shape
as ARRAY. Only elements of ARRAY for which the corresponding
entry of MASK is true will then be included in the
computation.
-
The output is a scalar if DIM is absent, or if ARRAY is
a vector (has rank 1). Otherwise, it is an array of
rank 1 less than ARRAY containing the maximum values
along the dimension DIM for which MASK is true.
-
result = merge ( tsource, fsource, mask )
-
chooses one value or the other depending on a mask.
TSOURCE and FSOURCE may be arrays, of the same shape,
of any type.
MASK is a logical array of the same shape.
RESULT is an array of the same shape, with the
value TSOURCE where MASK is TRUE, and FSOURCE where
MASK is false.
-
result = min ( a1, a2, a3, ... )
-
returns the minimum of A1, A2, A3, ...
-
The arguments must be all be of the same type and kind;
the arguments must be integer or real;
-
RESULT has the same type and kind as the arguments.
-
The most common use is A = min ( A1, A2 ), but the
number of arguments may be greater;
-
result = minexponent ( x )
-
returns the minimum exponent in the model for numbers of the same type
and kind as X;
-
X must be of type real;
-
typically, the returned value is the minimum exponent base 2
for real numbers of the given kind.
-
result = minloc ( array, mask )
-
returns the index of the minimum entry in the array.
-
ARRAY must be integer or real
-
MASK is an optional logical argument. If it
is included, it must be an array of the same shape
as ARRAY. Only elements of ARRAY for which the corresponding
entry of MASK is true will then be included in the
computation.
-
The output is a vector whose dimension is the rank of
ARRAY, and which contains the coordinates of the entry
of minimum value. If MASK has been supplied then the
value is the index of the minimum entry for which MASK
is TRUE.
-
Note that, even if ARRAY is a vector, the output is
a vector (in this case of length 1), and not a scalar.
-
result = minval ( array, dim, mask )
-
returns the minimum entry in the array.
-
ARRAY must be integer or real
-
DIM is an optional integer argument. If it
is included, it must be between 1 and the rank of ARRAY.
-
MASK is an optional logical argument. If it
is included, it must be an array of the same shape
as ARRAY. Only elements of ARRAY for which the corresponding
entry of MASK is true will then be included in the
computation.
-
The output is a scalar if DIM is absent, or if ARRAY is
a vector (has rank 1). Otherwise, it is an array of
rank 1 less than ARRAY containing the minimum values
along the dimension DIM for which MASK is true.
-
result = mod ( a, p )
-
returns the remainder after division.
-
A and P must be of the same type.
-
A and P must be real or integer.
-
RESULT is real or integer, depending on the
type of the arguments.
-
P should not be 0.
-
mod ( a, p ) = a - int ( a / p ) * p. This means
that RESULT always has the sign of A.
-
mod ( 17, 3 ) = 2,
mod ( 17, -3 ) = 2,
mod ( -17, 3 ) = -2,
mod ( -17, -3 ) = -2.
-
result = modulo ( a, p )
-
returns the remainder after division.
-
A and P must be of the same type.
-
A and P must be real or integer.
-
RESULT is real or integer, depending on the
type of the arguments.
-
P should not be 0.
-
mod ( a, p ) = a - floor ( a / p ) * p. This means
that RESULT always has the sign of P.
-
mod ( 17, 3 ) = 2,
mod ( 17, -3 ) = -1,
mod ( -17, 3 ) = 1,
mod ( -17, -3 ) = -2.
-
call mvbits ( from, frompos, len, to, topos )
-
copies a sequence of bits from one location to another.
-
MVBITS is a subroutine.
-
FROM, FROMPOS, LEN, TO and TOPOS are all integer.
-
FROM is the integer from which the bits are copied.
-
0 <= FROMPOS is the position of the first bit to be
copied from FROM.
-
LEN is the number of bits to be copied from FROM.
FROMPOS+LEN <= BITSIZE(FROM).
-
TO is the integer into which the copied bits are placed.
-
0 <= TOPOS is the position in TO where the first copied
bit will be placed. It is necessary that
TOPOS+LEN <= BITSIZE(TO).
-
result = nearest ( x, s )
-
returns the nearest distinct machine representable number in the
given direction.
-
X must be real;
-
S must be real, and may not equal zero;
-
result = nint ( a, kind )
-
returns the integer value nearest to A.
-
A must be real
-
RESULT is an integer;
-
KIND is an optional argument; if it is included,
it may be used to specify a nondefault kind for the
integer result.
-
result = not ( i )
-
returns the logical complement of the input argument.
-
the input argument and RESULT are both of type
logical.
-
if the input argument is true then RESULT
is false and vice versa.
-
result = pack ( array, mask, vector )
-
packs an array into a vector under control of a mask.
-
array may be of any type.
-
mask is a logical scalar, or array of the same shape
as array.
-
vector is an optional argument.
-
the output is a vector, of the same type as array,
containing all the elements of array for which the
corresponding entry of mask is TRUE.
-
if vector is included, then the output is a copy of
vector, in which the initial elements have been replaced
by the elements copied from array.
-
result = precision ( x )
-
returns the decimal precision of real numbers of the same
kind as X.
-
X must be real;
-
RESULT is an integer integer;
-
RESULT represents the number of decimal places
of accuracy in the storage of real numbers.
-
result = present ( a )
-
is TRUE if an optional argument is present.
-
Dummy arguments to a function or subroutine can be declared
to have the optional attribute. In that case, calls
to the routine may or may not include an actual argument.
PRESENT enables the routine to determine whether an actual
argument has been supplied.
-
A is the name of the optional dummy argument, and the
value returned is TRUE if an actual argument value for
A was supplied.
-
result = product ( array, dim, mask )
-
computes the product of the elements of ARRAY along dimension
DIM, for true elements of MASK.
-
DIM and MASK are optional arguments.
-
ARRAY is a vector or matrix, of type complex,
integer or real;
-
If supplied, DIM is of type integer, and is between
1 and the rank of ARRAy.
-
if supplied, MASK is an array of the same shape as ARRAY,
of type logical;
-
In the simplest case, PRODUCT(ARRAY(1:N)) returns the
product of the entries of ARRAY;
-
PRODUCT(ARRAY,MASK = MASK) returns the
product of the entries of ARRAY for which MASK is true;
-
PRODUCT(ARRAY,DIM) returns an array of rank one less than
ARRAY, whose elements are the products of elements of ARRAY
along dimension DIM.
-
PRODUCT(ARRAY,DIM,MASK) returns an array of rank one less than
ARRAY, whose elements are the products of elements of ARRAY
along dimension DIM for which MASK is true.
-
result = radix ( x )
-
returns the base of the model representing numbers of the
type and kind of X.
-
X may be of type integer or real;
-
On most machines, the retured value will be 2.
-
call random_number ( harvest )
-
returns uniformly distributed pseudorandom numbers.
-
RANDOM_NUMBER is a subroutine.
-
The argument HARVEST must be real.
-
The argument HARVEST may be a scalar or array.
-
It is intended that calling RANDOM_NUMBER repeatedly
will return different values. The values returned
are influenced by the value of the random seed array.
To alter the sequence, or in particular to force
the sequence to repeat, requires calling the
RANDOM_SEED routine.
-
call random_seed ( size, put, get )
-
can get the size of the random seed, get its value, or
reset its value.
-
RANDOM_SEED is a subroutine.
-
The output of the random_number routine is determined
by the value of the random seed. If the random seed is not
set by the user, then its value at the beginning of program
execution is arbitrary. The user is free to determine the
size of the random seed (it is an integer vector of some
dimension) and then set it to some known value. In this way,
the user can exercise some control over the random number
generator.
-
SIZE, PUT and GET are all optional arguments of type
integer; SIZE is a scalar, but PUT and GET are
vectors. The routine
may only be called with zero arguments, or exactly one
of the optional arguments.
-
-
call random_seed ( ) initializes the random number
generator.
-
-
call random_seed ( SIZE = n ) returns in N the dimension
of the random number seed.
-
-
call random_seed ( GET = seed ) returns in SEED(1:N)
the current value of the random number seed vector.
-
-
call random_seed ( PUT = seed ) sets the random
number seed vector to SEED(1:N).
-
-
result = range ( x )
-
returns the decimal exponent range for model numbers of the
same kind and type as X.
-
X may be complex, integer or real;
-
RESULT is an integer.
-
If the value returned is called E, then roughly speaking,
the magnitude of integers is between 1 and 10**E, while
real numbers range between about 10**(-E) and 10**E.
-
result = real ( a, kind )
-
converts a value to a real value of the given kind.
-
A may be complex, integer or real;
-
KIND is an optional integer argument, which can be
used to specify the kind of the result. If it is not present,
the default kind is used.
-
If A is an integer or real value, the result is the
equivalent real number of the specified or default kind;
If A is complex, then the result is the real part
of A, returned as a real number of the specified kind, or
(if KIND is not specified), the kind of A.
-
result = repeat ( string, ncopy )
-
concatenates several copies of a string.
-
STRING is the character string to be concatenated.
-
NCOPY is an integer, the number of copies
of STRING to make.
-
RESULT is a character string formed from NCOPY concatenated
copies of STRING.
-
result = reshape ( source, shape, pad, order )
-
rearranges a vector or array to form an array of the
given shape.
-
SOURCE is an array, of any type.
-
SHAPE is an integer vector of no more than 8 entries,
all of which are nonnegative, and which represent the
shape of the desired result.
-
PAD is an optional argument. If present, it must be
the same type as SOURCE.
-
ORDER is an optional argument. If present, it is an
integer of the same shape as SHAPE, and its values must
be a permutation of the values 1 through N, where N
is the size of SHAPE.
-
RESULT is an array whose shape is specified by SHAPE,
and whose values are taken from SOURCE, in the usual
order; if there are not enough values in SOURCE, then
subsequent entries come from PAD, and if PAD is exhausted,
it is used again and again. If ORDER is specified, then
instead of the natural ordering, the elements of SOURCE
are copied to the permuted indices ORDER(1), ..., ORDER(N).
-
result = rrspacing ( x )
-
returns the reciprocal of the relative spacing of model numbers
near the argument value X.
-
X must be real.
-
The value returned is generally the inverse of the relative
distance to the next model number.
-
result = scale ( x, i )
-
returns X*RADIX**I, where RADIX is the base of real arithmetic.
-
X must be real, and I must be an integer;
-
RESULT is a real value, of the same kind as X.
-
On almost all computers, RADIX is probably 2
-
result = scan ( string, set, back )
-
scans a string for the occurrence of one of the characters in a set.
-
STRING is the character string to be searched.
-
SET is a character string, each of whose characters is assumed
to be one of the set to be searched for.
-
BACK is an optional argument; if it is present, then the
search is carried out starting with the last character of STRING
and decreasing, rather than with the first.
-
RESULT is the index in STRING of the first (or last) occurrence
of an element of SET, or 0 if no element was found.
-
result = selected_int_kind ( r )
-
returns a value for the KIND parameter of the integer type
that represents all integers from -10**R to 10**R.
-
R is an integer (presumably positive!)
-
RESULT is an integer.
-
result = selected_real_kind ( p, r )
-
returns a value for the KIND parameger for the real type
that represents reals with at least P digits of precision
and a decimal exponent range of R.
-
P and R are integer variables, presumably positive.
-
RESULT is an integer.
-
result = set_exponent ( x, i )
-
constructs a number with the fractional part of X and the
exponent I.
-
X must be real.
-
I must be integer.
-
In the typical case, if X can be represented as
frac*2**power, where 1/2 <= frac < 1,
the function value returned
will be frac*2**i.
-
result = shape ( source )
-
returns the shape of an array.
-
A may be of any type.
-
RESULT is a vector, each of whose components is
the size or range of the array in that dimension.
-
result = sign ( a, b )
-
transfers the sign of B to the magnitude of A.
-
sign(a,b) = abs ( a ) if 0 <= B;
sign(a,b) = -abs ( a ) if B < 0.
-
A and B must be of the same type and kind.
The allowed types are integer and real.
RESULT is of the same type and kind as the arguments.
-
result = sin ( x )
-
returns the sine of X.
-
X must be of type real or complex;
-
result = sinh ( x )
-
returns the hyperbolic sine of X.
-
result = size ( array, dim )
-
returns the number of elements in an array.
-
A may be of any type.
-
SIZE is simply the product of the range of the array
in each dimension.
-
This function is useful, for example, in determining the
range of the indices of an array declared
or allocated using the form a(l:u).
-
DIM is an optional argument. If DIM is omitted, then
RESULT is the total size of the array.
-
If DIM is present, then RESULT is the size
of the array in the given dimension.
-
result = spacing ( x )
-
returns the absolute spacing of model numbers near the
argument value X.
-
X must be real.
-
RESULT is generally the distance to the
next model number.
-
result = spread ( source, dim, copies )
-
replicates an array by adding a dimension.
-
SOURCE may be a scalar or an array.
-
DIM indicates where the new dimension is to be added,
and must be between 1 and N+1, where the rank of SOURCE is N.
-
COPIES is the extent of the array in the new dimension,
and can be thought of as the number of copies of the array
to be made.
-
result = sqrt ( x )
-
returns the square root of X.
-
The value of X must satisfy 0 <= X;
-
result = sum ( array, dim, mask )
-
computes the sum of the elements of ARRAY along dimension
DIM, for true elements of MASK.
-
DIM and MASK are optional arguments.
-
ARRAY is a vector or matrix, of type complex,
integer or real;
-
If supplied, DIM is of type integer, and is between
1 and the rank of ARRAy.
-
if supplied, MASK is an array of the same shape as ARRAY,
of type logical;
-
In the simplest case, SUM(ARRAY(1:N)) returns the
sum of the entries of ARRAY;
-
SUM(ARRAY,MASK = MASK) returns the
sum of the entries of ARRAY for which MASK is true;
-
SUM(ARRAY,DIM) returns an array of rank one less than
ARRAY, whose elements are the sum of elements of ARRAY
along dimension DIM.
-
SUM(ARRAY,DIM,MASK) returns an array of rank one less than
ARRAY, whose elements are the sum of elements of ARRAY
along dimension DIM for which MASK is true.
-
call system_clock ( count, count_rate, count_max )
-
returns a reading from the system clock.
-
Note that this is a subroutine, not a function!
-
All three arguments are output quantities, and all are optional.
To specify any particular argument, you may use
a format like "COUNT = variable". The formal names of the
three variable are COUNT, COUNT_RATE and COUNT_MAX.
-
COUNT returns the current clock cycle count of the clock;
COUNT_RATE returns the number of clock cycles per second;
COUNT_MAX returns the maximum possible value for COUNT.
-
result = tan ( x )
-
returns the tangent of X.
-
X must be of type real or complex;
-
result = tanh ( x )
-
returns the hyperbolic tangent of X.
-
result = tiny ( x )
-
returns the smallest number in the model.
-
X may be of type real;
-
TINY(X) will be of the same type as X;
-
TINY(1.0) might be 1.17E-38;
TINY(1.0D+00) might be 2.22E-308.
-
result = transfer ( source, mold, size )
-
returns a result that has the same physical representation
of source but interpreted with the type of MOLD.
-
SOURCE may be of any type, and may be a scalar or array.
-
MOLD may be of any type, and may be a scalar or array.
-
SIZE is an optional argument. If present, it must be
a scalar integer
-
RESULT is the result of interpreting the physical representation
of SOURCE as though it were of the type of MOLD.
-
If A is a real array of size 20, and B is a complex variable,
then
result = transfer ( A, B )
is an array of 10 complex values,
in which the first 2 entries of A are the real and imaginary
parts of the first entry of RESULT.
-
result = transpose ( matrix )
-
returns the transpose of MATRIX.
-
MATRIX is an array of rank 2.
-
MATRIX can have any type.
-
result = trim ( string )
-
returns a copy of STRING up to the last nonblank character.
-
result = ubound ( a, dim )
-
returns the upper bounds of an array.
-
A may be of any type.
-
This function is useful, for example, in determining the
upper bound on the indices of an array declared
or allocated using the form a(l:u).
-
If DIM is omitted, then RESULT is a vector
containing the upper bound of each dimension of A.
-
If DIM is present, then RESULT is the upper
bound in the given dimension of A.
-
result = unpack ( vector, mask, field )
-
unpacks a vector into an array.
-
vector is an array of any type, but it must have rank 1.
-
mask must an array, and logical.
-
field must be of the same type as vector; it must be
a scalar, or else have the same shape as mask.
-
RESULT is an array of the same type as vector,
and the same shape as mask. For each entry of mask that
is true, the "next" entry of vector is copied into the
result. Where mask is false, the value of FIELD (if scalar)
or the corresponding entry of FIELD (if an array) is copied.
-
result = verify ( string, set, back )
-
verifies that a string contains only characters from a given set,
or else returns the location of the first character of string
that is not in the set.
-
STRING and SET are character strings, and BACK is an
optional logical variable.
-
Each character of STRING is examined. If every character
in STRING occurs in SET, then the return value is 0.
Otherwise, the return value is the first location in
STRING of a character not in SET.
-
If the argument BACK is included, and is TRUE, then
the return value is the LAST location in STRING of a
character that is not in SET.
You can return to the
HTML web page.
Last revised on 02 August 2006.