The Fortran standard defines intrinsic procedures, which consist of intrinsic functions and intrinsic subroutines. The compiler includes several more intrinsic procedures as extensions to the standard.
Intrinsic procedures can be called from any program unit or subprogram. However, a user-written function or subroutine with the same name as an intrinsic function or subroutine takes precedence over the intrinsic procedure in a given scoping unit if one of the following is true:
Its interface is explicit.
It is listed in an EXTERNAL statement in that scoping unit.
It is a statement function.
A module or internal procedure, for example, overrides an intrinsic procedure with the same name, in the absence of an applicable INTRINSIC statement, because its interface is explicit. If a module or internal procedure is accessible by the same name as a name specified on an INTRINSIC statement, it is an error in a program unit.
This chapter introduces all of the intrinsic procedures supported by the compiler. Each procedure is described in detail on an online man page. For more information on any of the intrinsic procedures introduced in this chapter, enter man intrinsic_name at your system prompt.
![]() | Note: All intrinsic functions that are defined in the Fortran standard can be assumed to be pure functions. |
Intrinsic procedures are predefined by the language. They conform to the principles and rules for procedures as described in the MIPSpro Fortran Language Reference Manual, Volume 1. Intrinsic procedures are invoked in the same way as other procedures and employ the same argument association mechanism. The intrinsic procedure interfaces, including the argument keywords (dummy argument names) and argument options, are all described partially in this section and are described further in the man pages.
The four classes of intrinsic procedures are as follows:
Inquiry functions.
Elemental functions.
Transformational functions.
Subroutines. One intrinsic subroutine, MVBITS, is elemental and pure.
The compiler also includes the following types of intrinsic procedures:
Intrinsic procedures to support IEEE floating-point arithmetic.
Miscellaneous procedures. All procedures in this group are extensions to the Fortran standard.
An inquiry function returns information about something. The results of these functions depend on the properties of the principal argument rather than the value of this argument. The argument can be undefined.
The Fortran standard inquiry functions are as follows (in the following list, the numeric model referred to is described in Section 5.3):
Name | Information returned | |
ALLOCATED | Array allocation status | |
ASSOCIATED | Pointer association status or comparison | |
BIT_SIZE | Number of bits in the bit manipulation model | |
DIGITS | Number of significant digits in the numeric model | |
EPSILON | Number that is almost negligible compared to one | |
HUGE | Largest number in the numeric model | |
KIND | Kind type parameter value | |
LBOUND | Lower dimension bounds of an array | |
LEN | Length of a character entity | |
MAXEXPONENT | Maximum exponent in the numeric model | |
MINEXPONENT | Minimum exponent in the numeric model | |
PRECISION | Decimal precision of the numeric model | |
PRESENT | Dummy argument presence | |
RADIX | Base of the numeric model | |
RANGE | Decimal exponent range of the numeric model | |
SHAPE | Shape of an array or scalar | |
SIZE | Total number of elements in an array | |
TINY | Smallest positive number in the numeric model | |
UBOUND | Upper dimension bounds of an array |
Many intrinsic functions, and the MVBITS subroutine, can be referenced elementally; that is, the intrinsic is called with one or more array arguments and yields an array result.
The Fortran standard elemental functions are as follows:
Name | Information returned or operation | |
ABS | Absolute value | |
ACHAR | Character in given position in ASCII collating sequence | |
ACOS | Arccosine | |
ADJUSTL | Adjust a string left | |
ADJUSTR | Adjust a string right | |
AIMAG | Imaginary part of a complex number | |
AINT | Truncation to whole number | |
ANINT | Nearest whole number | |
ASIN | Arcsine | |
ATAN | Arctangent | |
ATAN2 | Arctangent of a nonzero complex value | |
BTEST | Bit testing | |
CEILING | Least integer greater than or equal to a given real number | |
CHAR | Character in given position in the collating sequence used by this compiler | |
CMPLX | Conversion to complex type | |
CONJG | Conjugate of a complex number | |
COS | Cosine | |
COSH | Hyperbolic cosine | |
DBLE | Conversion to double-precision real type | |
DIM | Positive difference | |
DPROD | Double-precision real product | |
EXP | Exponential | |
EXPONENT | Exponent part of a numeric model number | |
FLOOR | Greatest integer less than or equal to a given real number | |
FRACTION | Fraction part of a numeric model number | |
IACHAR | Position of a character in the ASCII collating sequence | |
IAND | Logical AND | |
IBCLR | Clear a bit | |
IBITS | Bit extraction | |
IBSET | Set a bit | |
ICHAR | Position of a character in the collating sequence used by the compiler | |
IEOR | Exclusive OR | |
INDEX | Starting position of a substring | |
INT | Conversion to integer type | |
IOR | Inclusive OR | |
ISHFT | Logical shift | |
ISHFTC | Circular shift | |
LEN_TRIM | Length without trailing blank characters | |
LGE | Lexically greater than or equal | |
LGT | Lexically greater than | |
LLE | Lexically less than or equal | |
LLT | Lexically less than | |
LOG | Natural logarithm | |
LOG10 | Common logarithm (base 10) | |
LOGICAL | Convert between objects of type logical with different kind type parameters | |
MAX | Maximum value | |
MERGE | Merge under mask | |
MIN | Minimum value | |
MOD | Remainder function | |
MODULO | Modulo function | |
NEAREST | Nearest different machine-representable number in given direction | |
NINT | Nearest integer | |
NOT | Logical complement | |
REAL | Conversion to real type | |
RRSPACING | Reciprocal of the relative spacing of numeric model numbers near given number | |
SCALE | Multiply a real by its base to an integer power | |
SCAN | Scan a string for a character in a set | |
SET_EXPONENT | Set exponent part of a numeric model number | |
SIGN | Transfer of sign | |
SIN | Sine | |
SINH | Hyperbolic sine | |
SPACING | Absolute spacing of numeric model numbers near a given number | |
SQRT | Square root | |
TAN | Tangent | |
TANH | Hyperbolic tangent | |
VERIFY | Verify the set of characters in a string |
Transformational procedures have either a dummy argument that is array valued (for example, the SUM function) or an actual argument that is array valued without causing an elemental interpretation (for example, the SHAPE function). A transformational function transforms an array actual argument into a scalar result or another array, rather than applying the operation element-by-element.
The Fortran standard transformational functions are as follows:
Name | Information returned or operation | |
ALL | True if all values are true | |
ANY | True if any value is true | |
COUNT | Number of true elements in an array | |
CSHIFT | Circular shift | |
DOT_PRODUCT | Dot product of two rank one arrays | |
EOSHIFT | End-off shift | |
MATMUL | Matrix multiplication | |
MAXLOC | Location of a maximum value in an array | |
MAXVAL | Maximum value in an array | |
MINLOC | Location of a minimum value in an array | |
MINVAL | Minimum value in an array | |
NULL | Return a disassociated pointer | |
PACK | Pack an array into an array of rank one | |
PRODUCT | Product of array elements | |
REPEAT | Repeated concatenation | |
RESHAPE | Reshape an array | |
SELECTED_INT_KIND | Integer kind type parameter, given range | |
SELECTED_REAL_KIND | Real kind type parameter, given range | |
SPREAD | Replicates array by adding a dimension | |
SUM | Sum of array elements | |
TRANSFER | Treat first argument as if of type of second argument | |
TRANSPOSE | Transpose an array of rank two | |
TRIM | Remove trailing blank characters | |
UNPACK | Unpack an array of rank one into an array under a mask |
An intrinsic subroutine is referenced by the CALL statement that uses its name explicitly. The name of an intrinsic subroutine cannot be used as an actual argument. MVBITS is an elemental subroutine.
The Fortran standard intrinsic subroutines are as follows:
Name | Purpose | |
CPU_TIME | Returns the processor time | |
DATE_AND_TIME | Obtains date and time | |
MVBITS | Copies bits from one bit manipulation model integer to another | |
RANDOM_NUMBER | Returns pseudorandom number | |
RANDOM_SEED | Initializes or restarts the pseudorandom number generator | |
SYSTEM_CLOCK | Obtains data from the system clock |
The intrinsic procedures described in this section support the IEEE Standard for Binary Floating-point Arithmetic.
![]() | Note: The intrinsic procedures to support IEEE floating-point arithmetic are supported on all IRIX platforms. See the man pages for each routine for more implementation information. |
The IEEE intrinsic procedures allow you to obtain, alter, and restore the floating-point status flags. For example, they allow a procedure to save the current floating-point state as a single word on entry to a procedure and to restore the floating-point state before returning to the caller.
The IEEE intrinsic procedures are as follows:
Name | Information returned or operation |
CLEAR_IEEE_EXCEPTION | Clears floating-point exception indicator |
DISABLE_IEEE_INTERRUPT | Disables floating-point interrupt |
ENABLE_IEEE_INTERRUPT | Enables floating-point interrupt |
GET_IEEE_EXCEPTIONS | Retrieves flags that represent the current floating-point exception status |
GET_IEEE_INTERRUPTS | Retrieves flags that represent the current floating-point interrupt status |
GET_IEEE_ROUNDING_MODE | Returns current floating-point rounding mode |
GET_IEEE_STATUS | Retrieves flags that represent the current floating-point status |
IEEE_BINARY_SCALE | Returns y multiplied by 2 n |
IEEE_CLASS | Returns the class to which x belongs |
IEEE_COPY_SIGN | Returns x with the sign of y |
IEEE_EXPONENT | Returns the unbiased exponent of x |
IEEE_FINITE | Tests for x being greater than negative infinity and less than positive infinity |
IEEE_IS_NAN | Tests for x being a NaN |
IEEE_INT | Converts x to an integral value according to the rounding mode in effect |
IEEE_NEXT_AFTER | Returns the next representable neighbor of x in the direction toward y |
IEEE_REAL | Converts x to a real value according to the rounding mode in effect |
IEEE_REMAINDER | Returns the remainder of the operation x/ y |
IEEE_UNORDERED | Tests for x or y being a NaN |
INT_MULT_UPPER | Multiplies unsigned integers and returns the uppermost bits |
SET_IEEE_EXCEPTION | Sets floating-point exception indicator |
SET_IEEE_EXCEPTIONS | Restores the floating-point status |
SET_IEEE_INTERRUPTS | Restores floating-point interrupt status |
SET_IEEE_ROUNDING_MODE | Restores floating-point rounding mode |
SET_IEEE_STATUS | Restores floating-point status before |
TEST_IEEE_EXCEPTION | Returns the state of a floating-point exception |
TEST_IEEE_INTERRUPT | Returns the state of a floating-point interrupt |
A number of the procedures named in Section 5.1.5, use named constants. On systems that support IEEE floating-point arithmetic, the named constants are provided in module FTN_IEEE_DEFINITIONS. To use this module, include the following statement in your program:
USE FTN_IEEE_DEFINITIONS |
The FTN_IEEE_DEFINITIONS module must be used if you want to use named constants to pass values to IEEE intrinsic procedures or to interpret return values. The named constants should always be used as arguments to the appropriate procedures, as opposed to using hard-coded values, because the values represented by the named constants might not be the same on all architectures. SGI reserves the right to change the values represented by the named constants.
The named constants are available to you if the scoping unit from which they are referenced (or a parent scoping unit) has used the module FTN_IEEE_DEFINITIONS. The following paragraphs describe the named constants that are available to you and the systems upon which they are supported.
The following named constants allow you to access floating-point exception flags:
IEEE_XPTN_CRI_INVALID_OPND (supported only on Cray T90 systems that support IEEE floating-point arithmetic)
IEEE_XPTN_INEXACT_RESULT
IEEE_XPTN_UNDERFLOW
IEEE_XPTN_OVERFLOW
IEEE_XPTN_DIV_BY_ZERO
IEEE_XPTN_INVALID_OPR
IEEE_XPTN_ALL
The following named constants allow you to access floating-point interrupt flags:
IEEE_NTPT_CRI_INVALID_OPND (supported only on Cray T90 systems that support IEEE floating-point arithmetic)
IEEE_NTPT_INEXACT_RESULT
IEEE_NTPT_UNDERFLOW
IEEE_NTPT_OVERFLOW
IEEE_NTPT_DIV_BY_ZERO
IEEE_NTPT_INVALID_OPR
IEEE_NTPT_ALL
The following named constants allow you to access the floating-point rounding mode:
IEEE_RM_NEAREST
IEEE_RM_POS_INFINITY
IEEE_RM_ZERO
IEEE_RM_NEG_INFINITY
The following named constants allow you to determine the class of a floating-point value:
IEEE_CLASS_SIGNALING_NAN
IEEE_CLASS_QUIET_NAN
IEEE_CLASS_NEG_INFINITY
IEEE_CLASS_NEG_NORM_NONZERO
IEEE_CLASS_NEG_DENORM
IEEE_CLASS_NEG_ZERO
IEEE_CLASS_POS_ZERO
IEEE_CLASS_POS_DENORM
IEEE_CLASS_POS_NORM_NONZERO
IEEE_CLASS_POS_INFINITY
Some of the IEEE intrinsic procedure names are long. This was done to avoid creating names that might be identical to names that already exist in user programs. If, however, an IEEE intrinsic procedure name conflicts with an existing user identifier, you can use the Fortran renaming capabilities to provide your own local name by following these steps:
Create a module that contains an INTRINSIC statement for each intrinsic procedure you wish to rename.
Reference this module name in a USE statement in a context in which you want to reference the intrinsic procedure. Use a rename clause on the USE statement for the intrinsic procedures you want to rename.
For example, to rename IEEE_IS_NAN to IS_NAN :
MODULE MY_NAMES INTRINSIC IEEE_IS_NAN END MODULE PROGRAM MAIN USE MY_NAMES, IS_NAN => IEEE_IS_NAN ... ! REFERENCES TO IS_NAN HERE ! ARE ACTUALLY TO IEEE_IS_NAN .... END PROGRAM |
The compiler implements many intrinsic procedures that are extensions to the Fortran standard. Consult the man page for each intrinsic to determine whether individual intrinsics are elemental, inquiry, transformational, or are an intrinsic subroutine.
Not all of the miscellaneous procedures are implemented on all platforms. See the man pages for each routine for more implementation information.
The following functions are extensions to the Fortran standard:
Name | Information returned or operation |
ACOSD | Accepts cosine, returns degrees. |
ADD_AND_FETCH, AND_AND_FETCH, NAND_AND_FETCH, OR_AND_FETCH, SUB_AND_FETCH , XOR_AND_FETCH | Performs full barrier operations with the second argument on the first arguments and returns the new value of the second argument. |
ASIND | Accepts sine, returns degrees. |
ATAND | Accepts tangent, returns degrees. |
ATAN2D | Accepts tangent numerator and denominator, returns degrees. |
C_LOC | Provides the address of a C or C++ language entity. |
CLOC | Obtains the address of a character entity. |
COMPARE_AND_SWAP | Compares arguments. If they are equal, the value of the third argument is stored into the first and the return value is TRUE. Otherwise, the return value is FALSE. |
COSD | Accepts degrees as argument, returns cosine. |
COT | Returns cotangent. |
CVMGM | Test for minus (negative). |
CVMGN | Test for nonzero. |
CVMGP | Test for positive (or zero). |
CVMGZ | Test for zero. |
CVMGT | Test for TRUE. |
DSHIFTL | Shifts double word left. |
DSHIFTR | Shifts double word right. |
DSM_CHUNKSIZE | Returns the chunk size (ignoring partial chunks) in the given dimension for each of BLOCK, CYCLIC, and asterisk (*) distributions. |
DSM_DISTRIBUTION_BLOCK | Returns 0 (FALSE) or 1 (TRUE) for a query on whether or not the specified dimension has a BLOCK distribution. |
DSM_DISTRIBUTION_CYCLIC | Returns 0 (FALSE) or 1 (TRUE) for a query on whether or not the specified dimension has a CYCLIC distribution. |
DSM_DISTRIBUTION_STAR | Returns 0 (FALSE) or 1 (TRUE) for a query on whether or not the specified dimension has an asterisk ( *) distribution. |
DSM_ISDISTRIBUTED | Returns 0 (FALSE) or 1 (TRUE) for a query on whether or not array is distributed (regular or reshaped) or not. |
DSM_ISRESHAPED | Returns 0 (FALSE) or 1 (TRUE) for a query on whether or not array is reshaped or not. |
DSM_NUMCHUNKS | Returns the number of chunks (including partial chunks) in the given dim for each of BLOCK, CYCLIC, and asterisk (*) distributions. |
DSM_NUMTHREADS | Returns the number of threads in the specified dimension of a distributed array. |
DSM_REM_CHUNKSIZE | Returns the remaining chunk size from index to the end of the current chunk, inclusive of each end point. Essentially it is the distance from index to the end of that contiguous block, inclusive. |
DSM_THIS_CHUNKSIZE | Returns the chunk size for the chunk containing the specified index for each of BLOCK, CYCLIC, and asterisk (*). This value may be different from DSM_CHUNKSIZE due to edge effects that can lead to a partial chunk. |
DSM_THIS_STARTINGINDEX | Returns the starting index value of the chunk containing the supplied index. |
DSM_THIS_THREADNUM | Returns the thread number for the chunk containing the given index value for each of BLOCK, CYCLIC, and asterisk (*) distributions. |
EQV | Performs logical equivalence. |
EXIT | Terminates program execution. |
FCD | Constructs a character pointer in Fortran Character Descriptor (FCD) format. |
FETCH_AND_ADD, FETCH_AND_AND, FETCH_AND_NAND, FETCH_AND_OR, FETCH_AND_SUB , FETCH_AND_XOR | Performs full barrier operations with the second argument on the first arguments and returns the old value of the first argument. |
FREE | Deallocates memory. |
FP_CLASS | Returns the class of an IEEE real argument. |
GETPOS | Obtains file position. |
IBCHNG | Reverses the value of a specified bit in an integer. |
IDATE | Return date or time in numerical form. |
ILEN | Returns the length of the two's complement representation of an integer. |
IMAG | Returns imaginary part of a complex number. |
IRTC | Returns clock register contents. |
ISHA | Performs an arithmetic shift. |
ISHC | Rotates an integer left or right. |
ISHL | Performs a logical shift. |
ISNAN | Tests for NaNs. |
LEADZ | Counts number of leading 0 bits. |
LENGTH | Returns the number of words successfully transferred. |
LOC | Returns address of a variable. |
LOCK_TEST_AND_SET | Performs lock-acquire operations. |
LOCK_RELEASE | Performs lock-release operations. |
LOG2_IMAGES | Returns the base 2 logarithm of the number of excecuting images. |
LONG | Returns an INTEGER(KIND=4) value. |
LSHIFT | Performs a left shift with zero fill. |
M@CLR | Clears BML bit. |
M@LD | Loads transposed bit matrix. |
M@LDMX | Loads bit matrix and multiplies. |
M@MX | Multiplies bit matrix. |
M@UL | Unloads bit matrix. |
MALLOC | Allocates memory on the heap. |
MY_PE | Returns the number of the processing element (PE) that is executing. |
MEMORY_BARRIER | Blocks memory loads and stores until processes finish. |
NUMARG | Returns the number of arguments in a function or subprogram call. |
NUM_IMAGES | Returns the number of images that are executing. |
POPCNT | Counts number of set bits. |
POPPAR | Computes bit population parity. |
QEXT | Converts a number to quad precision. |
REM_IMAGES | Returns MOD(NUM_IMAGES(), 2**LOG2_IMAGES()). |
REMOTE_WRITE_BARRIER | Blocks processor until remote writes have finished. |
RSHIFT | Performs a right shift with zero fill. |
SECNDS | Returns the time in seconds. |
SHIFTA | Performs an arithmetic shift. |
SHORT | Returns an INTEGER(KIND=2) value. |
SIND | Accepts degrees, returns sine. |
SIZEOF | Returns bytes of storage. |
SYNC_IMAGES | Synchronizes images. |
SYNCHRONIZE | Performs full barrier atomic synchronization. |
TAND | Accepts degrees, returns tangent. |
THIS_IMAGE | Returns an image number. |
TIME | Returns the current time as set within the system. |
UNIT | Performs I/O functions. |
WRITE_MEMORY_BARRIER | Blocks processor until remote writes have finished. |
ZEXT | Extends the argument with zeros. |
Intrinsic procedure references can use keyword arguments, as described in Section 4.7.4 in Chapter 4. A number of Fortran intrinsic procedure arguments are optional. Using keywords allows you to omit corresponding actual arguments. In the following example, the keyword form shown is used because the optional first argument SIZE is omitted:
CALL RANDOM_SEED(PUT=SEED_VALUE) |
If you are using argument keywords, the position at which the first argument keyword appears determines whether others in the call must also appear in keyword form. If an argument keyword is used, any other required arguments to the right of that argument must also appear in keyword form.
The following examples show correct use of actual arguments:
CALL DOT_PRODUCT(VECTOR_A=ARRAY1, VECTOR_B=ARRAY2) CALL DOT_PRODUCT(ARRAY1, VECTOR_B=ARRAY2) CALL DOT_PRODUCT(ARRAY1, ARRAY2) |
The following examples show incorrect use of actual arguments:
CALL DOT_PRODUCT(VECTOR_A=ARRAY1, ARRAY2) CALL DOT_PRODUCT(ARRAY2) |
Intrinsic procedure keywords (dummy argument names) have been made as consistent as possible, including using the same name in different intrinsic procedures for dummy arguments that play a corresponding or identical role. These include DIM, MASK, KIND , and BACK.
DIM is used, mostly in the array reduction functions and in some of the other array functions, to specify the array dimension involved. DIM must be a scalar integer value and usually is optional.
MASK is used, mostly, in the array functions, to mask out elements of an array that are not to be involved in the operation. For example, in the function SUM, any element of the array that is not to be included in the sum of the elements can be excluded by using an appropriate mask. The MASK must be a logical array with the same shape as the array it is masking; it usually is an optional argument.
KIND is an argument that is used mainly in the transfer and conversion functions to specify the kind type parameter of the function result. The KIND actual argument must be a scalar integer initialization expression, even in elemental references; it usually is optional.
BACK is an optional logical argument used in several of the intrinsic functions to specify reverse order (backward) processing. For example, if BACK=.TRUE. in the INDEX function, then the search is performed beginning from the right end of the string rather than the left end.
Some intrinsic functions compute values in relationship to how data is represented. These values are based upon and determined by the underlying representation model. There are three such models:
The bit model
The integer number system model
The real number system model
These models, and the corresponding functions that return values related to the models, allow development of robust and portable code. For example, by obtaining information about the spacing of real numbers, you can control the convergence of a numerical algorithm so that the code achieves maximum accuracy while attaining convergence.
The models themselves apply to the compilers running on any platform. The values that go into these models, however, are platform-specific. Please see the models(3i) man page for information about how these models apply to the various platforms that the compiler supports.
This section summarizes the syntax of each intrinsic procedure. These tables are meant to supplement, not replace, the intrinsic procedure man pages. For more information on any of the intrinsics listed in these tables, enter man intrinsic_name at your system prompt.
Some intrinsic functions have both generic and specific names. The intrinsic functions that have specific names can be called with those names as well as with the generic names. To pass an intrinsic procedure as an actual argument, however, you must use the specific name. The following table shows the specific intrinsic procedure names available in the compiler. Some of the specific intrinsic names are the same as the generic names.
The argument names shown are the keywords for keyword argument calls. All of the optional arguments are enclosed in brackets ( [ ] ).
The following table shows the intrinsic procedures that the compiler supports both as part of the Fortran standard and as extensions to the standard. If the procedure has both a generic and a specific name, the generic name is shown first, and the specific names are listed underneath.
Table 5-1. Intrinsic procedures
These man pages can be accessed online through the man(1) command.
![]() | Note: Many intrinsic procedures have both a vector and a scalar version. If a vector version of an intrinsic procedure exists, and the intrinsic is called within a vectorizable loop, the compiler uses the vector version of the intrinsic. For information on which intrinsic procedures vectorize, see intro_intrin(3i). |