« previous next»

2.6    Intrinsic Functions

    Fortran 90 has a library of functions  available for many common mathematical operations.  Including in the available functions are absolute value (ABS(x)), exponential (EXP(x)), logarithm (LOG(x)), and square root (SQRT(x)).  A complete list of these functions can be found in the appendices of the reference books (Appendix A of Metcalf, Appendix D of Nyhoff).
    It is important to pay attention to the types of data that can be used with these functions.  For example, the argument (x) in ABS(x) can be real or integer.  The result of the function will be of the same data type as the argument.  ABS(9.0) = 9.0, but ABS(9) = 9.  Some functions require real arguments (EXP(x), COS (x), LOG(x), etc.), while others may have real arguments and integer results (INT(x) is one as it returns the integer portion of a real number, x).
    Some functions allow definition of the output type.  The default value for INT(x) is integer, but this can be changed as follows:

    INT(x, KIND = kind_number)

The output will be the integer portion of x, but it will be of type kind_number.  As discussed in 2.5 different data types have compiler-dependent (kind) numbers associated with them.   INT can be used to return the integer portion of a number, but the output can have double or single real precision if desired.  This is not an option on all functions.

« previous next»