HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
PRIVATE (statement and attribute)
Chapter 10434
Description
The PRIVATE attribute may appear only in the specification part of a module. The default
accessibility in a module is PUBLIC; it can be changed to PRIVATE using a statement without a
list. However, only one PRIVATE accessibility statement without a list is permitted in a
module.
The PRIVATE attribute in a type statement or in an accessibility statement restricts the
accessibility of entities such as module variables, type definitions, functions, and named
constants. USE statements may restrict accessibility further.
A derived type may contain a PRIVATE attribute or an internal PRIVATE statement, if it is
defined in a module. The internal PRIVATE statement in a type definition makes the
components unavailable outside the module even though the type itself might be available.
The PRIVATE statement may also be used to restrict access to subroutines, generic specifiers,
and namelist groups.
The PRIVATE specification for a generic name, operator, or assignment does not apply to any
specific name unless the specific name is the same as the generic name.
Examples
MODULE fourier
REAL :: x, y, z ! PUBLIC (default)
COMPLEX, PRIVATE :: fft ! PRIVATE, accessible only in module
TYPE (structure_name), PRIVATE :: structure_a, structure_b
! a, b and c are accessible only within this module
PRIVATE a, b, c
! r, s, and t are accessible outside the module
PUBLIC r, s, t
END MODULE fourier
MODULE place
PRIVATE ! Change default accessibility to PRIVATE
INTERFACE OPERATOR (.st.)
MODULE PROCEDURE xst
END INTERFACE
! make .st. public; everything else is private
PUBLIC OPERATOR (.st.)
LOGICAL, DIMENSION (100) :: lt
CHARACTER(20) :: name
INTEGER ix, iy
END MODULE place
Related statements
PUBLIC and USE