HP MLIB User's Guide Vol. 1 7th Ed.
34 HP MLIB User’s Guide
What you need to know to use vector subprograms
Fortran storage of arrays
Two-dimensional arrays in Fortran are stored by columns. Consider the
following specifications:
DIMENSION A(N1,N2),B(N3)
EQUIVALENCE (A,B)
where N3 = N1 X N2. Then A(I,J) is associated with the same memory
location as B(K) where
K = I + (J−1) × N1
Successive elements of a column of A are adjacent in memory, while successive
elements of a row of A are stored with a difference of N1 storage units between
them. Remember that the size of a storage unit depends on the data type.
Fortran array argument association
When a Fortran subprogram is called with an array element as an argument,
the value is not passed. Instead, the subprogram receives the address in
memory of the element. Consider the following code segment:
REAL A(10,10)
J = 3
L = 10
CALL SUBR (A(1,J),L)
.
.
.
SUBROUTINE SUBR (X,N)
REAL X(N)
.
.
.
SUBR is given the address of the first element of the third column of A. Because
it treats that argument as a one-dimensional array, successive elements X(1),
X(2),..., occupy the same memory locations as the successive elements of the
third column of A, that is, A(1,3), A(2,3),... Hence, the entire third column
of A is available to the subprogram.