Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP Fortran statements

MODULE

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Introduces a module.

Syntax

MODULE module-name
module-name

is a unique module name.

Description

Modules are nonexecutable program units that can contain type definitions, object declarations, procedure definitions (module procedures), external procedure interfaces, user-defined generic names, and user-defined operators and assignments. Any such definitions not specified to be private to the module containing them are available to those program units that specify the module in a USE statement. Modules provide a convenient sharing and encapsulation mechanism for data, types, procedures, and procedure interfaces.

Examples

! Make data objects and a data type sharable via a module
MODULE shared
COMPLEX gtx (100, 6)
REAL, ALLOCATABLE :: y(:), z(:,:)
TYPE peak_item
REAL peak_val, energy
TYPE(peak_item), POINTER :: next
END TYPE peak_item
END MODULE shared

! Define a data abstraction for rational arithmetic via a module
MODULE rational_arithmetic
TYPE rational
PRIVATE
INTEGER numerator, denominator
END TYPE rational ! Generic extension of =
INTERFACE ASSIGNMENT (=)
MODULE PROCEDURE eqrr, eqri, eqir
END INTERFACE
INTERFACE OPERATOR (+) ! Generic extension of +
MODULE PROCEDURE addrr, addri, addir
END INTERFACE
...
CONTAINS
FUNCTION eqrr (. . .) ! A specific definition of =
...
FUNCTION addrr (. . .) ! A specific definition of +
...
END MODULE rational_arithmetic

Related statements

CONTAINS, END, PRIVATE, PUBLIC, and USE

Related concepts

For more information about modules, see “Modules”.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.