Many Fortran-90/95/2003 and FORTRAN-77 functions are termed ``generic'' in that the type of the output value adjusts to match that of the input argument(s).
Older versions of Fortran included more than one function to do the same thing, but which function a programmer used depended on the data type of the argument(s) and which return type was desired. For example, ABS and IABS both are absolute value functions, each taking one argument, but ABS returns a real value and is used with a real argument, and IABS is used with an integer argument (returning an integer result).
The older, ``specific'' names, proper to each data type, may continue to be used (to enable older code to continue to run), although the use of these "specific" names is not recommended and the corresponding ``generic'' name is preferred.
The standard Fortran functions are listed below (with their argument type and output type). Some implementations have their own additional library functions and programmers should check the manuals of the version they are using for further information.
In the Argument Type and Output Type columns of the following tables, R indicates REAL, I indicates INTEGER, C indicates COMPLEX, Char indicates Character (String), and L indicates LOGICAL. (Double Precision is not listed, since in Fortran-90/95/2003, REAL may be specified to arbitrary precision.)
The functions listed below under the major heading of ``elemental'' can also be applied to arrays with an array as the output (cf. section 8.11).
ELEMENTAL FUNCTIONS
Numeric functions
| FUNCTION NAME | PURPOSE | ARGUMENT TYPE | OUTPUT TYPE |
| ABS(A) | Absolute value | I,R,C | same as arg. |
| AINT(A) | Greatest Integer (Truncate) | R | R |
| ANINT(A) | Nearist Integer (Round) | R | R |
| CONJG(A) | Complex Conjugate | C | C |
| MAX(A[,B,C,..]) | Largest Value | I,R (all arg. same) | same as arg. |
| MIN(A[,B,C,..]) | Smallest Value | I,R (all arg. same) | same as arg. |
| MOD(A,B) | Remainder after Division A/B | I,R | same as arg. |
| SIGN(A,B) | A receives the sign of B | I,R | same as arg. |
Type Conversion (Numeric) functions
(cf. Chapter 14, section 14.3 for the
discussion of Complex functions.)
| FUNCTION NAME | PURPOSE | ARGUMENT TYPE | OUTPUT TYPE |
| AIMAG(A) | Imag Part of Complex Numb. | C | R |
| CMPLX(A,B) | Converts to Complex | 2 args: I,R,C | C |
| INT(A) | Convert to Integer | I,R,C | I (depends on kind) |
| REAL(A) | Convert to Real | I,R,C | R (depends on kind) |
Mathematical functions
(cf. Chapter 14, section 14.3 for the
discussion of Complex functions.)
| FUNCTION NAME | PURPOSE | ARGUMENT TYPE | OUTPUT TYPE |
| EXP(A) | e=2.718281828... raised to a power | R,C | same as arg. |
| DIM(A,B) | Positive Difference (MAX(A_B,0)) | both I or R | same as arg. |
| SQRT(A) | Square Root | R,C | same as arg. |
| LOG(A) | Natural Log (base e) | R,C | same as arg. |
| LOG10(A) | Log Base 10 | R,C | same as arg. |
Trigonometric (Mathematical) functions
(Argument or answer is in radian measure.)
| FUNCTION NAME | PURPOSE | ARGUMENT TYPE | OUTPUT TYPE |
| SIN(A) | sin(A) | R,C | same as arg. |
| COS(A) | cos(A) | R,C | same as arg. |
| TAN(A) | cos(A) | R | same as arg. |
| ASIN(A) | inverse sin(A) | R | R |
| ACOS(A) | inverse cos(A) | R | R |
| ATAN(A) | inverse tan(A) | R | R |
| ATAN2(A,B) | inverse tan(A/B) | both R | R |
| SINH(A) | hyperbolic sin(A) | R | R |
| COSH(A) | hyperbolic cos(A) | R | R |
| TANH(A) | hyperbolic tan(A) | R | R |
Character Functions
(cf. Chapter 13, section 13.6 for more
discussion)
| FUNCTION NAME | PURPOSE | ARGUMENT TYPE | OUTPUT TYPE |
| LEN(A) | Length of String(A) | Char | I |
| INDEX(A,B) | Finds B in A | Char,Char | I |
| IACHAR(A) | Converts A to Integer | Char | I |
| CHAR(A) | Converts A to Character | I | Char |
| LGE(A,B) | Lexicograph. Greater Than or Equal | Char,Char | L |
| LGT(A,B) | Lexicographically Greater Than | Char,Char | L |
| LLE(A,B) | Lexicograph. Less Than or Equal | Char,Char | L |
| LLT(A,B) | Lexicographically Less Than | Char,Char | L |
TRANSFORMATIONAL (Array) FUNCTIONS
Fortran-90/95/2003 includes intrinsic functions for arrays that are not
applied element-wise. Information about these functions may be
found in section 8.13.
AROOT = (-B + SQRT(B*B-4*A*C))/(2*A) X = 2*SIN(THETA)*COS(THETA)Functions, with arguments, may also be used in WRITE statements or as parameters to other subprograms.
This page is maintained by Dennis C. Smolarski, S.J.
dsmolarski@math.scu.edu
© Copyright 1998-2005,
Dennis C. Smolarski, S.J., All rights reserved.
Last changed: 6 June 2005.