> On Mar 7, 2018, at 11:43 AM, Anton Shterenlikht <[log in to unmask]> wrote:
> From: Fortran 90 List [[log in to unmask]] on behalf of Bill Long [[log in to unmask]]
>> On Mar 7, 2018, at 11:08 AM, Anton Shterenlikht <[log in to unmask]> wrote:
>> The following program seems to be conforming in F2008 and F2018:
> I’m not so sure. In the argument association rules in the standard (18.104.22.168 Allocatable dummy variables, para 3) I see that for a dummy argument that is allocatable, we require:
> “ The corank of the actual argument shall be the same as that of the dummy argument.”
> This prevents the procedure from allocating or deallocating a dummy that is not a coarray when the actual is a coarray.
> Bill, thank you. I got lost in the document.
> There seems to be quite a diversity of compiler checking for this:
> Compiler 1. error:
> z.f90(12): error #8397: The corank of the actual argument must be the same as that of the dummy argument. [I]
> call s( i )
> Compiler 2. warning:
> Warning: Passing coarray at (1) to allocatable, noncoarray dummy argument 'a', which is invalid if the allocation status is modified [-Wsurprising]
> Compiler 3. compiles with no warning, and runs fine.
> I guess since the text you quote is not a constraint,
> than allowing this can be classed as compiler extension?
It would be a very dangerous extension since allocating the dummy variable with different sizes on different images would have bad side-effects. I’ve identified one instance of a compiler in the Compiler 3 class and filed a bug to get an error message issued.
> And what about non-allocatable actual/dummy?
> Is this conforming?
> module m
> subroutine s( a )
> integer, intent(inout) :: a(:)
> write (*,*) sum(a)
> end subroutine s
> end module m
> program p
> use m
> integer :: i(10)[*]
> i = this_image()
> call s( i )
> write (*,*) 'ok'
> end program p
This looks OK. The actual argument is just the coarray local to the image that is executing the subroutine, so nothing “bad” can happen.
> If so, any way to find out inside the procedure whether
> the passed variable was a coarray or not?
I don’t think so, at least in a portable way. The usual inquiry functions, like CORANK, that you would execute in the subroutine would apply to the dummy variable, which is not a coarray, independent of whether the actual argument is.
Bill Long [log in to unmask]
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425