Interlanguage Communication [9]
9.3.2 Argument Passing
Because Fortran subroutines expect arguments to be passed by pointers rather
than by value, C and C++ functions called from Fortran subroutines must pass
pointers rather than values.
All argument passing in Cray Standard C is strictly by value. To prepare for a
function call between two Cray Standard C functions, a copy is made of each
actual argument. A function can change the values of its formal parameters, but
these changes cannot affect the values of the actual arguments. It is possible,
however, to pass a pointer. (All array arguments are passed by this method.) This
capability is analogous to the Fortran method of passing arguments.
In addition to passing by value, Cray Standard C++ also provides passing by
reference.
9.3.3 Array Storage
C and C++ arrays are stored in memory in row-major order; and Fortran arrays
are stored in memory in column-major order. For example, the C or C++ array
declaration int A[3][2] is stored in memory as:
A[0][0] A[0][1]
A[1][0] A[1][1]
A[2][0] A[2][1]
The previously defined array is viewed linearly in memory as:
A[0][0] A[0][1] A[1][0] A[1][1] A[2][0] A[2][1]
The Fortran array declaration INTEGER A(3,2) is stored in memory as:
A(1,1) A(2,1) A(3,1)
A(1,2) A(2,2) A(3,2)
The previously defined array is viewed linearly in memory as:
A(1,1) A(2,1) A(3,1) A(1,2) A(2,2) A(3,2)
When an array is shared between Cray Standard C, C++, and Fortran, its
dimensions are declared and referenced in C and C++ in the opposite order in
S–2179–36 127
Comments to this Manuals