6.3.1.1 Generic References to Intrinsic Functions

Many of the Fortran intrinsic functions have generic (or common) names. If you refer to an intrinsic function by using its generic name, the selection of the library routine is based on the data type of the argument in the function reference.

For example, the generic name COS lists five intrinsic functions that calculate cosines: COS, DCOS, QCOS (VMS, U*X), CCOS, and CDCOS. These functions return different values: REAL*4, REAL*8, REAL*16 (VMS, U*X), COMPLEX*8, and COMPLEX*16, respectively.

To invoke the cosine function, you can refer to it generically as COS. The compiler then selects the appropriate routine, based on the arguments that you specify. For example, if the argument is REAL*4, COS is selected; if it is REAL*8, DCOS is selected; and if it is COMPLEX*8, CCOS is selected.

You can also explicitly refer to a particular routine. For example, to invoke the double-precision cosine function, you could specify DCOS rather than use the generic name.

The compiler lists the internal names of the intrinsic functions it has selected in the "FUNCTIONS AND SUBROUTINES REFERENCED" section of the source code listing.

Function selection occurs independently for each generic reference, so you can use a generic reference repeatedly in the same program unit to access different intrinsic functions.

Table 6-3 lists generic intrinsic function names. However, you cannot use the names in this table to generically select intrinsic functions if you use them in any of the following ways:

Using the generic name of an intrinsic function in an INTRINSIC statement does not affect function references. However, when you use a generic function name in an actual argument list as the name of a function to be passed, function selection does not occur because there is no argument list on which to base a selection. The generic name is treated according to the rules for handling specific intrinsic function names (see Section 6.3).

Generic function names are local to the program unit that refers to them, so they can be used for other purposes in other program units.

Table 6-3 Summary of Generic Intrinsic Function Names



Generic  Data Type of:
 
Generic  Data Type of:
 
Name  Argument  Result  Name  Argument  Result 
ABS  integer
real
COMPLEX*8 COMPLEX*16  
integer
real
COMPLEX*8
COMPLEX*16 
COSH  real  real 
ACOS  real  real  DBLE  integer
real
complex 
REAL*8
REAL*8
REAL*8 
ACOSD  real  real   DCMPLX  integer
real
complex 
COMPLEX*16
COMPLEX*16
COMPLEX*16 
AINT  real  real  DFLOAT   integer  REAL*8 
AMAX0  integer  REAL*4  DIM  integer
real 
integer
real 
AMIN0  integer  REAL*4  EXP  real
complex 
real
complex 
ANINT  real  real  FLOAT[1]  integer  REAL*4 
ASIN  real  real  IABS  integer  integer 
ASIND  real   real  IAND  integer  integer 
ATAN  real  real  IBCLR  integer  INTEGER*4 
ATAND  real  real   IBITS  integer  INTEGER*4 
ATAN2  real  real  IBSET  integer   integer 
ATAN2D  real  real  IDIM  integer  integer 
BTEST  integer  logical  IDINT[1]  REAL*8  integer 
CMPLX[1]  integer
real
complex 
COMPLEX*8
COMPLEX*8
COMPLEX*8 
IDNINT[1]  REAL*8  integer 
CONJG  complex  complex  IEOR  integer  integer 
COS  real  real  IFIX[1]  REAL*4  integer 
COSD  real  real   IMAG  complex  real 
INT[1]  integer
real
complex  
integer
integer
integer 
NINT[1]  real  integer 
IOR  integer  integer   NOT  integer  integer 
IQINT[1,2]   REAL*16  integer  QEXT[2]   integer
real
complex 
REAL*16
REAL*16
REAL*16 
IQNINT[1,2]   REAL*16  integer  QFLOAT[2]  integer  REAL*16 
ISHFT  integer  integer  REAL[1]  integer
real
complex 
REAL*4
REAL*4
REAL*4 
ISHFTC  integer  INTEGER*4  SIGN  integer
real 
integer
real 
ISIGN  integer  integer  SIN  real
complex  
real
complex 
LOG  real
complex 
real
complex  
SIND  real  real 
LOG10  real  real  SINH  real  real 
MAX  integer
real 
integer
real 
SNGL[1]  integer
real 
REAL*4
REAL*4 
MAX0  integer  integer   SQRT  real
complex 
real
complex 
MAX1[1]  REAL*4  integer  TAN  real  real 
MIN  integer
real 
integer
real  
TAND  real  real 
MIN0  integer  integer  TANH  real  real 
MIN1[1]  REAL*4  integer  ZEXT[1]  logical
integer  
integer
integer 
MOD  integer
real 
integer
real 
     

[1] The setting of compiler option REAL_SIZE affects the following generic functions: CMPLX, FLOAT, REAL, and SNGL (and specific function AIMAG). The setting of compiler option INTEGER_SIZE affects the following generic functions: IDINT, IDNINT, IFIX, INT, IQINT, IQNINT, MAX1, MIN1, NINT, and ZEXT.

[2] VAX only

For More Information:


Previous Page Next Page Table of Contents