Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran 90 Programmer's Reference: HP Series 700/800 Computers > Chapter 3 Data types and data objects

Derived types

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Fortran 90 allows the creation of new data types that are constructed from the intrinsic data types and previously defined new data types. These new data types are known as derived types.

For example, a derived type for manipulating coordinates consisting of two real numbers can be defined as follows:

TYPE coord
   REAL :: x,y
END TYPE coord

x and y are components of the derived type coord.

Variables of type coord, named a and b, can be declared as follows:

TYPE(coord) :: a, b

The assignment statement,

a = b

copies the values of all the defined components of b to those of a.

The individual components of a and b are referenced as a%x, a%y, b%x, and b%y. By coding appropriate procedures (as described in Chapter 7), the scope of the standard operators can be extended so that, for example,

a = a + b

could be defined to be equivalent to

a%x = a%x + b%x;  a%y = a%y + b%y

or to anything else, depending on the use procedure that is provided to implement the operation.

A derived-type entity can be used as an argument to a procedure and can be the result of a function— that is, a function of derived type can be defined.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.