Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question on coarrays: codimensions with deferred shape?

49 views
Skip to first unread message

Ev. Drikos

unread,
Dec 25, 2020, 10:23:37 AM12/25/20
to

Is this dummy argument 'x' in function 'st' ok?

class(t) :: x[:,:]

Or I should see a message like:

error: Coarray variable 'x' at (^) shall not have codimensions with
deferred shape
subroutine st(x)
^


Thanks,
Ev. Drikos


PS: a reference ie to some draft will be further appreciated.


--------------------------------------------------------------
macbook:gcc-10.1.0 suser$ gfortran8 -fcoarray=single
gcc/testsuite/gfortran.dg/coarray/poly_run_2.f90
macbook:gcc-10.1.0 suser$ ./a.out
macbook:gcc-10.1.0 suser$
macbook:gcc-10.1.0 suser$ cat
gcc/testsuite/gfortran.dg/coarray/poly_run_2.f90
! { dg-do run }
!
! Test for polymorphic coarrays
!
type t
end type t
class(t), allocatable :: A[:,:]
allocate (A[1:4,-5:*])
if (allocated(A)) stop
if (any (lcobound(A) /= [1, -5])) STOP 1
if (num_images() == 1) then
if (any (ucobound(A) /= [4, -5])) STOP 2
else
if (ucobound(A,dim=1) /= 4) STOP 3
end if
if (allocated(A)) i = 5
call s(A)
call st(A)
contains
subroutine s(x)
class(t) :: x[4,2:*]
if (any (lcobound(x) /= [1, 2])) STOP 4
if (num_images() == 1) then
if (any (ucobound(x) /= [4, 2])) STOP 5
else
if (ucobound(x,dim=1) /= 4) STOP 6
end if
end subroutine s
subroutine st(x)
class(t) :: x[:,:]
if (any (lcobound(x) /= [1, -5])) STOP 7
if (num_images() == 1) then
if (any (ucobound(x) /= [4, -5])) STOP 8
else
if (ucobound(x,dim=1) /= 4) STOP 9
end if
end subroutine st
end

Steve Lionel

unread,
Dec 25, 2020, 1:23:25 PM12/25/20
to
On 12/25/2020 10:23 AM, Ev. Drikos wrote:
>
> Is this dummy argument 'x' in function 'st' ok?
>
>   class(t) :: x[:,:]
>
> Or I should see a message like:
>
> error: Coarray variable 'x' at (^) shall not have codimensions with
> deferred shape
> subroutine st(x)

The error message is correct. What you're trying to do is
"assumed-shape", which does not exist for coarrays. ifort's message is:

error #8357: A coarray that does not have the ALLOCATABLE attribute
shall have a coarray-spec that is an explicit coshape-spec. [X]
subroutine st(x)
--------------^

You can find the text of the F2018 standard at
https://j3-fortran.org/doc/year/18/18-007r1.pdf


--
Steve Lionel
ISO/IEC JTC1/SC22/WG5 (Fortran) Convenor
Retired Intel Fortran developer/support
Email: firstname at firstnamelastname dot com
Twitter: @DoctorFortran
LinkedIn: https://www.linkedin.com/in/stevelionel
Blog: https://stevelionel.com/drfortran
WG5: https://wg5-fortran.org

Ev. Drikos

unread,
Dec 25, 2020, 1:30:37 PM12/25/20
to
On 25/12/2020 20:23, Steve Lionel wrote:
> On 12/25/2020 10:23 AM, Ev. Drikos wrote:
>> ...

>
> The error message is correct. What you're trying to do is
> "assumed-shape", which does not exist for coarrays. ifort's message is:
>
> error #8357: A coarray that does not have the ALLOCATABLE attribute
> shall have a coarray-spec that is an explicit coshape-spec.   [X]
> subroutine st(x)
> --------------^
>
> You can find the text of the F2018 standard at
> https://j3-fortran.org/doc/year/18/18-007r1.pdf
>
>

Thanks a lot,
Ev. Drikos
0 new messages