[J3] Polymorphic dummy arrays

Robert Corbett rpcorbett at att.net
Mon Jan 7 20:36:45 EST 2019


The original question was whether a polymorphic array dummy argument had to be an assumed-shape array.  If assumed-size polymorphic array dummy arguments are permitted, the answer to that question is no.

As you say, explicit-shape dummy arguments passed as actual arguments can require copies.  Unlike the case of an assumed-size array, the shape of an explicit-shape array is known by the calling routine, which allows the copy to be done.  In the case of an assumed-size array, most implementations do not know the size of the array, and so they cannot know how many elements to copy.

Bob Corbett

> On Jan 7, 2019, at 3:18 PM, Bill Long via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> The original example did not have any assumed-size arrays.  However, in the case of the dummy being explicit-shape  (dimension(1:2)) it is still possible that copy-in/copy-out is required, since the elements of the dummy array correspond to elements of the actual that are (most likely) not contiguous in memory. 
> 
> Cheers,
> Bill
> 
>> On Jan 7, 2019, at 5:14 PM, Robert Corbett via J3 <j3 at mailman.j3-fortran.org> wrote:
>> 
>> I am not aware of such a restriction.  I recall that Oracle Fortran allows assumed-size polymorphic dummy arguments.  At the time, they were tricky to implement.  The ability to pass a polymorphic actual argument to a dummy argument that is not polymorphic requires making a copy.  That meant Oracle's implementation had to pass the size of assumed-size polymorphic arrays.  Later, the standard was modified via corrigenda to eliminate the need to make copies.
>> 
>> Robert Corbett



More information about the J3 mailing list