Sun Studio 12: Fortran Library Reference

# 2.1 Standard Fortran 95 Generic Intrinsic Functions

The generic Fortran 95 intrinsic functions are grouped in this section by functionality as they appear in the Fortran 95 standard.

The arguments shown are the names that can be used as argument keywords when using the keyword form, as in cmplx(Y=B, KIND=M, X=A).

Consult the Fortran 95 standard for the detailed specifications of these generic intrinsic procedures.

## 2.1.1 Argument Presence Inquiry Function

Generic Intrinsic Name

Description

PRESENT

Argument presence

## 2.1.2 Numeric Functions

Generic Intrinsic Name

Description

ABS (A)

Absolute value

AIMAG (Z)

Imaginary part of a complex number

AINT (A [, KIND])

Truncation to whole number

ANINT (A [, KIND])

Nearest whole number

CEILING (A [, KIND])

Least integer greater than or equal to number

CMPLX (X [, Y, KIND])

Conversion to complex type

CONJG (Z)

Conjugate of a complex number

DBLE (A)

Conversion to double precision real type

DIM (X, Y)

Positive difference

DPROD (X, Y)

Double precision real product

FLOOR (A [, KIND])

Greatest integer less than or equal to number

INT (A [, KIND])

Conversion to integer type

MAX (A1, A2 [, A3,...])

Maximum value

MIN (A1, A2 [, A3,...])

Minimum value

MOD (A, P)

Remainder function

MODULO (A, P)

Modulo function

NINT (A [, KIND])

Nearest integer

REAL (A [, KIND])

Conversion to real type

SIGN (A, B)

Transfer of sign

## 2.1.3 Mathematical Functions

Generic Intrinsic Name

Description

ACOS (X)

Arccosine

ASIN (X)

Arcsine

ATAN (X)

Arctangent

ATAN2 (Y, X)

Arctangent

COS (X)

Cosine

COSH (X)

Hyperbolic cosine

EXP (X)

Exponential

LOG (X)

Natural logarithm

LOG10 (X)

Common logarithm (base 10)

SIN (X)

Sine

SINH (X)

Hyperbolic sine

SQRT (X)

Square root

TAN (X)

Tangent

TANH (X)

Hyperbolic tangent

## 2.1.4 Character Functions

Generic Intrinsic Name

Description

ACHAR (I)

Character in given position in ASCII collating sequence

CHAR (I [, KIND])

Character in given position in processor collating sequence

IACHAR (C)

Position of a character in ASCII collating sequence

ICHAR (C)

Position of a character in processor collating sequence

INDEX (STRING, SUBSTRING [, BACK])

Starting position of a substring

LEN_TRIM (STRING)

Length without trailing blank characters

LGE (STRING_A, STRING_B)

Lexically greater than or equal

LGT (STRING_A, STRING_B)

Lexically greater than

LLE (STRING_A, STRING_B)

Lexically less than or equal

LLT (STRING_A, STRING_B)

Lexically less than

REPEAT (STRING, NCOPIES)

Repeated concatenation

SCAN (STRING, SET [, BACK])

Scan a string for a character in a set

TRIM (STRING)

Remove trailing blank characters

VERIFY (STRING, SET [, BACK])

Verify the set of characters in a string

## 2.1.5 Character Inquiry Function

Generic Intrinsic Name

Description

LEN (STRING)

Length of a character entity

## 2.1.6 Kind Functions

Generic Intrinsic Name

Description

KIND (X)

Kind type parameter value

SELECTED_INT_KIND (R)

Integer kind type parameter value, given range

SELECTED_REAL_KIND ([P, R])

Real kind type parameter value, given precision and range

## 2.1.7 Logical Function

Generic Intrinsic Name

Description

LOGICAL (L [, KIND])

Convert between objects of type logical with different kind type parameters

## 2.1.8 Numeric Inquiry Functions

Generic Intrinsic Name

Description

DIGITS (X)

Number of significant digits of the model

EPSILON (X)

Number that is almost negligible compared to one

HUGE (X)

Largest number of the model

MAXEXPONENT (X)

Maximum exponent of the model

MINEXPONENT (X)

Minimum exponent of the model

PRECISION (X)

Decimal precision

Base of the model

RANGE (X)

Decimal exponent range

TINY (X)

Smallest positive number of the model

## 2.1.9 Bit Inquiry Function

Generic Intrinsic Name

Description

BIT_SIZE (I)

Number of bits of the model

## 2.1.10 Bit Manipulation Functions

Generic Intrinsic Name

Description

BTEST (I, POS)

Bit testing

IAND (I, J)

Logical AND

IBCLR (I, POS)

Clear bit

IBITS (I, POS, LEN)

Bit extraction

IBSET (I, POS)

Set bit

IEOR (I, J)

Exclusive OR

IOR (I, J)

Inclusive OR

ISHFT (I, SHIFT)

Logical shift

ISHFTC (I, SHIFT [, SIZE])

Circular shift

NOT (I)

Logical complement

## 2.1.11 Transfer Function

Generic Intrinsic Name

Description

TRANSFER (SOURCE, MOLD [, SIZE])

Treat first argument as if of type of second argument

## 2.1.12 Floating-Point Manipulation Functions

Generic Intrinsic Name

Description

EXPONENT (X)

Exponent part of a model number

FRACTION (X)

Fractional part of a number

NEAREST (X, S)

Nearest different processor number in given direction

RRSPACING (X)

Reciprocal of the relative spacing of model numbers near given number

SCALE (X, I)

Multiply a real by its base to an integer power

SET_EXPONENT (X, I)

Set exponent part of a number

SPACING (X)

Absolute spacing of model numbers near given number

## 2.1.13 Vector and Matrix Multiply Functions

Generic Intrinsic Name

Description

DOT_PRODUCT (VECTOR_A, VECTOR_B)

Dot product of two rank-one arrays

MATMUL (MATRIX_A, MATRIX_B)

Matrix multiplication

## 2.1.14 Array Reduction Functions

Generic Intrinsic Name

Description

True if all values are true

True if any value is true

Number of true elements in an array

Maximum value in an array

Minimum value in an array

Product of array elements

Sum of array elements

## 2.1.15 Array Inquiry Functions

Generic Intrinsic Name

Description

ALLOCATED (ARRAY)

Array allocation status

LBOUND (ARRAY [, DIM])

Lower dimension bounds of an array

SHAPE (SOURCE)

Shape of an array or scalar

SIZE (ARRAY [, DIM])

Total number of elements in an array

UBOUND (ARRAY [, DIM])

Upper dimension bounds of an array

## 2.1.16 Array Construction Functions

Generic Intrinsic Name

Description

Pack an array into an array of rank one under a mask

Replicates array by adding a dimension

Unpack an array of rank one into an array under a mask

## 2.1.17 Array Reshape Function

Generic Intrinsic Name

Description

Reshape an array

## 2.1.18 Array Manipulation Functions

Generic Intrinsic Name

Description

CSHIFT (ARRAY, SHIFT [, DIM])

Circular shift

EOSHIFT (ARRAY, SHIFT [, BOUNDARY, DIM]

End-off shift

TRANSPOSE (MATRIX)

Transpose of an array of rank two

## 2.1.19 Array Location Functions

Generic Intrinsic Name

Description

Location of a maximum value in an array

Location of a minimum value in an array

## 2.1.20 Pointer Association Status Functions

Generic Intrinsic Name

Description

ASSOCIATED (POINTER [, TARGET])

Association status inquiry or comparison

NULL ([MOLD])

Returns disassociated pointer

## 2.1.21 System Environment Procedures

Generic Intrinsic Name

Description

COMMAND_ARGUMENT_COUNT ()

Returns number of command arguments

GET_COMMAND ([COMMAND, LENGTH, STATUS])

Returns entire command that invoked the program

GET_COMMAND_ARGUMENT (NUMBER [, VALUE, LENGTH, STATUS])

Returns a command argument

GET_ENVIRONMENT_VARIABLE (NAME [, VALUE, LENGTH, STATUS, TRIM_NAME])

Obtain the value of an environment variable.

## 2.1.22 Intrinsic Subroutines

Generic Intrinsic Name

Description

CPU_TIME (TIME)

Obtain processor time

DATE_AND_TIME ([DATE, TIME,

ZONE, VALUES])

Obtain date and time

MVBITS (FROM, FROMPOS,

LEN, TO, TOPOS)

Copies bits from one integer to another

RANDOM_NUMBER (HARVEST)

Returns pseudorandom number

RANDOM_SEED ([SIZE, PUT, GET])

Initializes or restarts the pseudorandom number generator

SYSTEM_CLOCK ([COUNT,

COUNT_RATE, COUNT_MAX])

Obtain data from the system clock

## 2.1.23 Specific Names for Intrinsic Functions

Table 2–1 Specific and Generic Names for Fortran 95 Intrinsic Functions

Specific Name

Generic Name

Argument Type

ABS (A)

ABS (A)

default real

ACOS (X)

ACOS (X)

default real

AIMAG (Z)

AIMAG (Z)

default complex

AINT (A)

AINT (A)

default real

ALOG (X)

LOG (X)

default real

ALOG10 (X)

LOG10 (X)

default real

AMAX0 (A1, A2 [, A3,...])

REAL (MAX (A1, A2 [, A3,...]))

default integer

AMAX1 (A1, A2 [, A3,...])

MAX (A1, A2 [, A3,...])

default real

AMIN0 (A1, A2 [, A3,...])

REAL (MIN (A1, A2 [, A3,...]))

default integer

AMIN1 (A1, A2 [, A3,...])

MIN (A1, A2 [, A3,...])

default real

AMOD (A, P)

MOD (A, P)

default real

ANINT (A)

ANINT (A)

default real

ASIN (X)

ASIN (X)

default real

ATAN (X)

ATAN (X)

default real

ATAN2 (Y, X)

ATAN2 (Y, X)

default real

CABS (A)

ABS (A)

default complex

CCOS (X)

COS (X)

default complex

CEXP (X)

EXP (X)

default complex

CHAR (I)

CHAR (I)

default integer

CLOG (X)

LOG (X)

default complex

CONJG (Z)

CONJG (Z)

default complex

COS (X)

COS (X)

default real

COSH (X)

COSH (X)

default real

CSIN (X)

SIN (X)

default complex

CSQRT (X)

SQRT (X)

default complex

DABS (A)

ABS (A)

double precision

DACOS (X)

ACOS (X)

double precision

DASIN (X)

ASIN (X)

double precision

DATAN (X)

ATAN (X)

double precision

DATAN2 (Y, X)

ATAN2 (Y, X)

double precision

DCOS (X)

COS (X)

double precision

DCOSH (X)

COSH (X)

double precision

DDIM (X, Y)

DIM (X, Y)

double precision

DEXP (X)

EXP (X)

double precision

DIM (X, Y)

DIM (X, Y)

default real

DINT (A)

AINT (A)

double precision

DLOG (X)

LOG (X)

double precision

DLOG10 (X)

LOG10 (X)

double precision

DMAX1 (A1, A2 [, A3,...])

MAX (A1, A2 [, A3,...])

double precision

DMIN1 (A1, A2 [, A3,...])

MIN (A1, A2 [, A3,...])

double precision

DMOD (A, P)

MOD (A, P)

double precision

DNINT (A)

ANINT (A)

double precision

DPROD (X, Y)

DPROD (X, Y)

default real

DSIGN (A, B)

SIGN (A, B)

double precision

DSIN (X)

SIN (X)

double precision

DSINH (X)

SINH (X)

double precision

DSQRT (X)

SQRT (X)

double precision

DTAN (X)

TAN (X)

double precision

DTANH (X)

TANH (X)

double precision

EXP (X)

EXP (X)

default real

FLOAT (A)

REAL (A)

default integer

IABS (A)

ABS (A)

default integer

ICHAR (C)

ICHAR (C)

default character

IDIM (X, Y)

DIM (X, Y)

default integer

IDINT (A)

INT (A)

double precision

IDNINT (A)

NINT (A)

double precision

IFIX (A)

INT (A)

default real

INDEX (STRING, SUBSTRING)

INDEX (STRING, SUBSTRING)

default character

INT (A)

INT (A)

default real

ISIGN (A, B)

SIGN (A, B)

default integer

LEN (STRING)

LEN (STRING)

default character

LGE (STRING_A, STRING_B)

LGE (STRING_A, STRING_B)

default character

LGT (STRING_A, STRING_B)

LGT (STRING_A, STRING_B)

default character

LLE (STRING_A, STRING_B)

LLE (STRING_A, STRING_B)

default character

LLT (STRING_A, STRING_B)

LLT (STRING_A, STRING_B)

default character

MAX0 (A1, A2 [, A3,...])

MAX (A1, A2 [, A3,...])

default integer

MAX1 (A1, A2 [, A3,...])

INT (MAX (A1, A2 [, A3,...]))

default real

MIN0 (A1, A2 [, A3,...])

MIN (A1, A2 [, A3,...])

default integer

MIN1 (A1, A2 [, A3,...])

INT (MIN (A1, A2 [, A3,...]))

default real

MOD (A, P)

MOD (A, P)

default integer

NINT (A)

NINT (A)

default real

REAL (A)

REAL (A)

default integer

SIGN (A, B)

SIGN (A, B)

default real

SIN (X)

SIN (X)

default real

SINH (X)

SINH (X)

default real

SNGL (A)

REAL (A)

double precision

SQRT (X)

SQRT (X)

default real

TAN (X)

TAN (X)

default real

TANH (X)

TANH (X)

default real

Functions marked with # cannot be used as an actual argument. “double precision” means double-precision real.