next up previous

3.3 Numeric Polymorphism

All of the computational intrinsic functions are generic over all of the type kinds provided by the implementation. Thus, for example, the result returned by COS(X) is the appropriate value of kind SINGLE, DOUBLE, IEEE, or P9, depending on whether X is of kind SINGLE, DOUBLE, IEEE, or P9, respectively. This generic property aids significantly in the development of portable robust application code. Intrinsic functions are similarly generic in Fortran 77, but a robustness deficiency of Fortran 77 is that user and implementation (and third party software vendor) supplied procedures cannot be made generic over argument types. Fortran 90 remedies this deficiency. (In this chapter ``polymorphism" can be assumed to mean that generic properties, familiar in regard to the Fortran 77 intrinsic functions, may be specified for and are therefore extended to user-defined procedures.)

The interface block can be used to specify a generic name for a set of user supplied procedures, or to add procedures to an existing generic name. In the following two examples, the first interface block defines a new generic name (SMOOTH) associated with four specific procedures, and the second interface block extends the COS intrinsic functions to arguments of type RATIONAL.