02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>HP</strong> <strong>Fortran</strong> statements<br />

USE<br />

Entities made accessible by a USE statement include public entities from other modules<br />

referenced by USE statements within the referenced module.<br />

ThesamenameorspecifiermaybemadeaccessiblebymeansoftwoormoreUSE statements.<br />

Such an entity must not be referenced in the scoping unit containing the USE statements,<br />

except where specific procedures can be distinguished by the overload rules. A rename or ONLY<br />

clause may be used to restrict access to one name or to rename one entity so that both are<br />

accessible.<br />

Examples<br />

MODULE rat_arith<br />

TYPE rat<br />

INTEGER n, d<br />

END TYPE<br />

! Make all entities public except zero.<br />

TYPE(rat), PRIVATE, PARAMETER :: zero = rat(0,1)<br />

TYPE(rat), PUBLIC, PARAMETER :: one = rat(1,1)<br />

TYPE(rat) r1, r2<br />

NAMELIST /nml_rat/ r1, r2<br />

INTERFACE OPERATOR( + )<br />

MODULE PROCEDURE rat_plus_rat, int_plus_rat<br />

END INTERFACE<br />

CONTAINS<br />

FUNCTION rat_plus_rat(l, r)<br />

END FUNCTION<br />

END MODULE<br />

PROGRAM Mine<br />

! From the module rat_arith, access only the entities rat,<br />

! one, r1, r2, nml_rat but use the name one_rat for the<br />

! rational value one.<br />

USE rat_arith, ONLY: rat, one_rat => one, r1, r2, nml_rat<br />

! The OPERATOR + for rationals and the procedures rat_plus_rat<br />

! and int_plus_rat are not available because of the ONLY clause<br />

READ *, r2; r1 = one_rat<br />

WRITE( *, NML = nml_rat)<br />

END PROGRAM<br />

Related statements<br />

MODULE<br />

Related concepts<br />

For information about modules, see “Modules” on page 158.<br />

Chapter 10 455

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!