Description
RFE:coarray allocate enhanced checks.
This has been crossposted to the gfortran mailing list.
Apparently, a Fortran compiler is not required to detect at runtime that the attached code violates the standard by having different lower/upper bounds in the allocation statement on different images. However it would be nice to have such a check enabled (at runtime) under one of the -fcheck= options (-fcheck=bounds ?)
program try_coarray
use iso_fortran_env
implicit none
integer, allocatable :: iv(:)[:]
integer :: me, np, info
me = this_image()
np = num_images()
allocate(iv(me)[*],stat=info)
write(*,*) me,'allocate(me):',info
if (info /= 0) write(*,*) size(iv)
if (allocated(iv)) deallocate(iv)
allocate(iv(me:me+1)[*],stat=info)
write(*,*) me,'allocate(me:me+1):',info
if (info /= 0) write(*,*) size(iv)
iv(me:me+1) = [me,me+1]
if (me>1) write(*,*) me,'Accessing left',iv(me)[me-1]
if (me<np) write(*,*) me,'Accessing right',iv(me+1)[me+1]
if (allocated(iv)) deallocate(iv)
end program try_coarray
which currently (gcc 6.3.0/ opencoarrays 1.8.4) results in
e802756@service1:/scratch/e802756> cafrun -np 2 ./a.out
1 allocate(me): 0
2 allocate(me): 0
2 allocate(me:me+1): 0
2 Accessing left 1
1 allocate(me:me+1): 0
1 Accessing right 3
It should be (relatively) easy to broadcast the bounds available on image 1, and then each image checks that they are the same as the local ones (and the broadcast being expensive is the obvious explanation why a compiler is not required to do it, and of why it is not advisable to have this enabled by default).
Thanks
Salvatore