LF Fortran 95

MODULE Statement

Description

The MODULE statement begins a module program unit. The module encapsulates data and procedures, provides a global data facility, which can be considered a replacement for COMMON, and establishes implicit interfaces for procedures contained in the module.

Syntax

MODULE module-name
Where:

module-name is the name of the module.

Remarks

The module name must not be the same as the name of another program unit, an external procedure, or a common block within the executable program, nor be the same as any local name in the module.

In LF95, a module program unit must be compiled before it is used.

Example

module m type mytype ! mytype available anywhere m is used real :: a,b(2,4) integer :: n,o,p end type mytype real :: r1=1 ! r1 available anywhere m is used contains subroutine sub1(i) ! implicit interface for sub1 integer :: i i=1 end subroutine function fun1() ! implicit interface for fun1 integer :: fun1 fun1=1 end function end module m program zee use m ! makes module available to program zee type (mytype) bee,dee integer :: i i=fun1() call sub1(i) end program zee