TYPE RATIONAL ! This defines the type RATIONAL. INTEGER :: NUMERATOR INTEGER :: DENOMINATOR END TYPE RATIONAL ... TYPE (RATIONAL) :: X, Y(100,100) ! X and Y are variables of ! type RATIONAL.
This might be the type defined in connection with a complete rational arithmetic data abstraction. Such an abstraction requires, in addition to the type definition, an appropriate set of operator definitions. These are done by specifying operator interfaces for user-defined functions. The following example illustrates extending the ``+" operator to addition between objects of type RATIONAL.
INTERFACE OPERATOR (+) FUNCTION RAT_ADD(X,Y) TYPE (RATIONAL) :: RAT_ADD TYPE (RATIONAL) :: X, Y END FUNCTION RAT_ADD END INTERFACE
More details on user-defined types and operators will be discussed in sections of the next release of this chapter.