On 16.09.2011 01:08, Mikael Morin wrote:
How are cobounds passed to a coarray dummy?

For explicit shape, assumed-size and assumed shape coarrays: The value is not passed but is set for the dummy argument. While that's not surprising for explicit shape/assumed shape arrays, e.g.
  integer :: A(5,7,n)[1:4, 4:*]
  integer :: B(2:*)[*]
it might be slightly surprising for assumed-shape coarrays. However, also for normal assumed-shape arrays, only the rank and not the lower bound is preserved (default lbound value: 1). For coarrays, also the upper bound needs to be given:
  integer :: B(1:, 5:)[4,*]
Note: In all those cases, the corank can differ between actual and dummy argument.

The only case where the the cobounds are passed are deferred-shape coarrays, i.e. allocatable ones, e.g.
  integer, allocatable :: A(:)[:,:]
here, the corank needs to agree and the lower/upper bounds are kept.

For deferred-shape coarrays, the array descriptor contains behind the array dimension triplets, additional triplets for the cobounds.

Except for the small difference for deferred-shape coarrays, with -fcoarray=single the normal data as with noncoarrays is transferred. For -fcoarray=lib one transfers in all cases additional information: A token identifying the coarray and the offset between the first coarray memory location and the one one passes (e.g., for a coarray "A(5)[*]", the element A(3) is also a coarray and the offset would be the one between A(1) and A(3)). For deferred-shape coarrays, the token is part of the array descriptor and no offset exists. For all other cases, there is a hidden additional argument for offset and token. See CoarrayLib in the wiki for details.

However, what comes up from testing is that neither is needed.
I'm not submiting this patch for approval, I'm submitting it to understand why
it is not necessary.

I do not immediately see whether it is needed or not. However, as this is about the scalarizer: You cannot pass an allocatable array (coarray) to an (impure) elemental function which has a scalar *allocatable* dummy argument.* You can only do so if the dummy argument is not allocatable. However, in that case the cobounds are not taken from the actual argument but are constructed in the called procedure.

(* Separately allocating an single argument does not make sense. I have not checked the standard, but I don't think it can be valid.)

Does this answer the question?

Tobias

Reply via email to