next up previous

1 Overview of Fortran 90     continued...

A module can simultaneously contain both data related and procedure related entities. One typical such application of a module is to package a data abstraction- that is, to contain a type definition, interfaces defining operators to be used in conjunction with operands of that type, and possibly even the procedures defining operations on that type. For example the type definition for RATIONAL and the extension of ``+" to RATIONAL addition illustrated above could be packaged in a module as follows:
MODULE RATIONAL_ARITHMETIC

 TYPE RATIONAL
  INTEGER :: NUMERATOR
  INTEGER :: DENOMINATOR
 END TYPE RATIONAL

 INTERFACE OPERATOR (+)
  FUNCTION RAT_ADD(X,Y)
   TYPE (RATIONAL) :: RAT_ADD
   TYPE (RATIONAL) :: X, Y
  END FUNCTION RAT_ADD
 END INTERFACE

 ...   ! and other stuff for a complete rational arithmetic facility

END MODULE RATIONAL_ARITHMETIC
This sort of comprehensive use of modules for will be described in more detail in the next release.