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 />

TYPE (definition)<br />

TYPE (definition)<br />

The first statement of a derived type definition.<br />

Syntax<br />

TYPE [[, access-spec ] ::] derived-type-name<br />

access-spec<br />

derived-type-name<br />

Description<br />

450<br />

is the keyword PUBLIC or PRIVATE.<br />

is a legal <strong>Fortran</strong> 90 name.<br />

The TYPE statement introduces the definition of a derived type. A derived type name may be<br />

any legal <strong>Fortran</strong> 90 name, as long as it is not the same as an intrinsic type name or another<br />

local name (except component names and actual argument keyword names) in that scoping<br />

unit.<br />

A derived type may contain an access specification (PUBLIC or PRIVATE attribute) or an<br />

internal PRIVATE statement only if it is in a module.<br />

Examples<br />

! This is a simple example of a derived type<br />

! with two components, high and low.<br />

TYPE temp_range<br />

INTEGER high, low<br />

END TYPE temp_range<br />

! This type uses the previous definition for one of its<br />

! components<br />

TYPE temp_record<br />

CHARACTER(LEN=40) city<br />

TYPE (temp_range) extremes(1950:2050)<br />

END TYPE temp_record<br />

! This type has a pointer component to provide links to other<br />

! objects of the same type, thus providing linked lists.<br />

TYPE linked_list<br />

REAL value<br />

TYPE(linked_list),POINTER :: next<br />

END TYPE linked_list<br />

! This is a public type whose components are private; defined<br />

Chapter 10

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

Saved successfully!

Ooh no, something went wrong!