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.

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

EQUIVALENCE<br />

As a result of this EQUIVALENCE statement, the fourth character in a, the first character in b,<br />

and the first character in c(2) share the same storage.<br />

Strings of the same or different lengths can be equivalenced to start on the first element, and<br />

you can use substring notation to specify other associations, as in the following:<br />

CHARACTER (10) :: s1, s2<br />

EQUIVALENCE (s1(2:2), s2(3:3)<br />

Substring subscripts must be integer initialization expressions, and the substring length<br />

must be nonzero.<br />

Equivalencing arrays<br />

To determine equivalence between arrays with different dimensions, <strong>HP</strong> <strong>Fortran</strong> views all<br />

elements of an array in linear sequence. Each array is stored as if it were a one-dimensional<br />

array. Array elements are stored in ascending sequential, column-major order; for<br />

information about how arrays are laid out in memory, see “Array fundamentals” on page 55.<br />

Array elements can be equivalenced with elements of a different array or with scalars. No<br />

equivalence occurs outside the bounds of any of the equivalenced arrays.<br />

If equivalenced arrays are not of the same type, they may not line up element by element.<br />

If an array name appears without subscripts in an EQUIVALENCE statement, it has the same<br />

effect as specifying an array name with the subscript of its first element.<br />

It is illegal to equivalence different elements of the same array to the same storage area. For<br />

example, the following is illegal:<br />

INTEGER :: a(2), b<br />

EQUIVALENCE (a(1), b), (a(2), b)<br />

Likewise, it is illegal to use the EQUIVALENCE statement to force consecutive array elements to<br />

be noncontiguous, as in the following example:<br />

REAL :: a(2), r(3)<br />

EQUIVALENCE (a(1), r(1)), (a(2), r(3))<br />

Array subscripts must be integer initialization expressions.<br />

Equivalence in common blocks<br />

An EQUIVALENCE statement must not cause two common blocks to be associated. However,<br />

you can use the EQUIVALENCE statement to place objects in common by equivalencing them to<br />

objects already in common. If one element of an array is equivalenced to an object in common,<br />

the whole array is placed in common with equivalence maintained for storage units preceding<br />

and following the data element in common. The common block is always extended when it is<br />

necessary to fit an array that shares storage space in the common block. It may be extended<br />

after the last entry, but not before the first.<br />

Chapter 10 321

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

Saved successfully!

Ooh no, something went wrong!