J3/02-137 Date: 21 February 2002 To: J3 From: John Reid Subject:
Dynamic arrays and interfacing with C The aim of this paper is
to ensure that 1. It is possible for a Fortran procedure, while
being called from C, to allocate an array and make that array
available to the C code; and 2. It is possible for a C function,
while being called from Fortran, to allocate an array and make
that array available to the Fortran code. We already have a
procedure for constructing a C pointer, but it is not applicable
to an allocatable array, so an allocatable array cannot be
passed to C. I propose to remove this restriction, while
continuing to disallow pointer arrays and assumed-shape arrays
since these need not be a contiguous subarray of the original
declared or allocated parent array. Explicit-shape and assumed-
size arrays are already interoperable with C. The underlying
assumption is that it is the address of the first element that
is passed. Thus an array allocated in C can be passed to an
explicit-shape or assumed-siz