https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102456

--- Comment #2 from G. Steinmetz <gs...@t-online.de> ---

It compiles when using "size(shape(x))" as a synonym for "rank(x)".
And indeed, that scalar x (from image 1) has rank 0.

$ cat z2.f90
program p
   type t
      integer :: a
   end type
   type(t) :: x[*]
   print *, size(shape(x[1]))
end

$ gfortran-12 -c z2.f90 -fcoarray=lib
$

---

Simplified a bit with "integer" instead of "type(t)".
All of the following variants work i.e. with -fcoarray=single :


$ cat z4.f90
program p
   integer :: a
   integer :: b(2)
   integer :: c(2,3)
   integer :: d(2,3,5)
   print *, rank(a), size(shape(a))
   print *, rank(b), size(shape(b))
   print *, rank(c), size(shape(c))
   print *, rank(d), size(shape(d))
end


$ cat z5.f90
program p
   integer :: a[*]
   integer :: b(2)[*]
   integer :: c(2,3)[*]
   integer :: d(2,3,5)[*]
   print *, rank(a), size(shape(a))
   print *, rank(b), size(shape(b))
   print *, rank(c), size(shape(c))
   print *, rank(d), size(shape(d))
end


$ cat z6.f90
program p
   integer :: a[*]
   integer :: b(2)[*]
   integer :: c(2,3)[*]
   integer :: d(2,3,5)[*]
   print *, rank(a[1]), size(shape(a[1]))
   print *, rank(b(:)[1]), size(shape(b(:)[1]))
   print *, rank(c(:,:)[1]), size(shape(c(:,:)[1]))
   print *, rank(d(:,:,:)[1]), size(shape(d(:,:,:)[1]))
end


$ gfortran-12 z4.f90 && ./a.out
           0           0
           1           1
           2           2
           3           3

$ gfortran-12 z5.f90 -fcoarray=single && ./a.out
           0           0
           1           1
           2           2
           3           3

$ gfortran-12 z6.f90 -fcoarray=single && ./a.out
           0           0
           1           1
           2           2
           3           3

Reply via email to