Prevents access to module entities by use association.
Syntax
The
syntax of a type declaration statement with the PRIVATE attribute is:
type, attrib-list :: access-id-list |
- type
is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE ( name ), etc.).
- attrib-list
is a comma-separated list of attributes including PRIVATE and optionally those attributes compatible with
it, namely:
Table 10-45 Title not available (PRIVATE (statement and attribute))
ALLOCATABLE | INTRINSIC | SAVE |
DIMENSION | PARAMETER | TARGET |
EXTERNAL | POINTER | |
- access-id-list
is
a comma-separated list of one or more of the following:
The syntax of the PRIVATE statement is:
PRIVATE [[::] access-id-list] |
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
Related concepts
For related information, see the following: