HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
USE
Chapter 10 489
Entities made accessible by a USE statement include public entities from other modules
referenced by USE statements within the referenced module.
The same name or specifier may be made accessible by means of two or more USE statements.
Such an entity must not be referenced in the scoping unit containing the USE statements,
except where specific procedures can be distinguished by the overload rules. A rename or ONLY
clause may be used to restrict access to one name or to rename one entity so that both are
accessible.
Examples
MODULE rat_arith
TYPE rat
INTEGER n, d
END TYPE
! Make all entities public except zero.
TYPE(rat), PRIVATE, PARAMETER :: zero = rat(0,1)
TYPE(rat), PUBLIC, PARAMETER :: one = rat(1,1)
TYPE(rat) r1, r2
NAMELIST /nml_rat/ r1, r2
INTERFACE OPERATOR( + )
MODULE PROCEDURE rat_plus_rat, int_plus_rat
END INTERFACE
CONTAINS
FUNCTION rat_plus_rat(l, r)
END FUNCTION
END MODULE
PROGRAM Mine
! From the module rat_arith, access only the entities rat,
! one, r1, r2, nml_rat but use the name one_rat for the
! rational value one.
USE rat_arith, ONLY: rat, one_rat => one, r1, r2, nml_rat
! The OPERATOR + for rationals and the procedures rat_plus_rat
! and int_plus_rat are not available because of the ONLY clause
READ *, r2; r1 = one_rat
WRITE( *, NML = nml_rat)
END PROGRAM
Related statements
MODULE
Related concepts
For information about modules, see “Modules” on page 190.