02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Array declarations<br />

An array is a data object with the dimension attribute. Its rank—and possibly the<br />

extents—are defined by an array specification. The array specification is enclosed in<br />

parentheses and can be attached either to the DIMENSION attribute, as in:<br />

INTEGER, DIMENSION(17) :: a, b<br />

or to the array name, as in:<br />

REAL :: y(3,25)<br />

Arrays<br />

Array declarations<br />

If the array specification is attached both to the DIMENSION attribute and to the array name in<br />

the same declaration statement, the specification attached to the name takes precedence. In<br />

the following example:<br />

INTEGER, DIMENSION(4,7) :: a, b, c(15)<br />

a and b are declared as two-dimensional arrays, but c is declared as a one-dimensional array.<br />

An array specification can declare an array as one of the following:<br />

Explicit-shape array<br />

Assumed-shape array<br />

Deferred-shape array<br />

Assumed-size array<br />

The following sections describe these types and the form of the array specification for each<br />

type. For information about initializing arrays with the array constructor, see “Array<br />

constructors” on page 73.<br />

Explicit-shape arrays<br />

An explicit-shape array has explicitly declared bounds for each dimension; the bounds are<br />

neither taken from an actual array argument (“assumed”) nor otherwise specified prior to use<br />

(“deferred”). Each dimension of an explicit-shape array has the following form:<br />

[lower-bound :] upper-bound<br />

where lower-bound and upper-bound are specification expressions and may be positive,<br />

negative, or zero. The default for lower-bound is 1.<br />

Chapter 4 57

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

Saved successfully!

Ooh no, something went wrong!