Next: Derived Types and Procedures Up: Derived Types Previous: Defininig Derived Types   Contents

# Arrays and Derived Types

In F90 is possible to have an array of derived-type objects. For example
```type(Point), dimension(4) :: tetrahedron
```

It is also possible for a derived type to contain array components.

```type Pnt
real, dimension(3) :: x
end type Pnt
type Volume
type(Point), dimension(4) :: tetrahedron
INTEGER :: label
end type Volume
type(Volume), dimension(100) :: diamond
```

The diamond is an object of type (``which has a'') Volume. Geometrically, the diamond has many facets, and we can conceptually ``create'' it (in a computer graphics program) by adjoining a number of tetrahedra. Each tetrahedron is described by its four corner points, and each corner point is given by its set of cartesian coordinates and .

We can reffer to a specific coordinate of one of the node points. For example

```diamond(5)%tetrahedron(2)%x(1)
```
means tetrahedron, node point, coordinate.

We can also reffer to a subsection of the array component, provided that there is only one non-scalar index in the reference. For example,

```diamond(:)%tetrahedron(2)%x(1)
diamond(5)%tetrahedron(:)%x(1)
diamond(5)%tetrahedron(2)%x(:)
```
are all correct, however the form
```diamond(:)%tetrahedron(:)%x(1)
diamond(5)%tetrahedron(:)%x(:)
diamond(:)%tetrahedron(2)%x(:)
```
are incorrect, since we can only section at most one component at a time.

Next: Derived Types and Procedures Up: Derived Types Previous: Defininig Derived Types   Contents