[J3] Passing an element of an assumed shape array to an assumed size dummy array
Pierre Hugonnet
pieru at ugo235.fr
Sat May 10 11:35:16 UTC 2025
Hello,
I encountered the following compilation error:
!============================
program foobar
implicit none
integer :: x(100)
x = 1
call foo(x)
contains
subroutine foo(x)
integer, contiguous :: x(:)
call bar( x(10) ) ! compilation error here
end subroutine
subroutine bar(x)
integer :: x(*)
print*, x(1)
end subroutine
end
!============================
The error message says : "If the actual argument is scalar, the dummy
argument shall be scalar unless the actual argument is of type character
or is an element of an array that is not assumed shape, pointer, or
polymorphic."
This is indeed consistent with the standard, which says in 15.5.2.5:
"If the actual argument is a noncoindexed scalar, the corresponding
dummy argument shall be scalar unless
• the actual argument is default character, of type character with the C
character kind (18.2.2), or is an element or substring of an element of
an array that is not an assumed-shape, pointer, or polymorphic array,
• the dummy argument has assumed-rank, or
• the dummy argument is an assumed-type assumed-size array."
Excluding the case where the element belongs to an assumed-shape or
pointer array makes sense, as these are potentially non-contiguous,
which means that sequence association cannot apply. However I think that
this restriction should be removed in the cases where the assumed-shape
or pointer array is declared as `contiguous`.
What do you think ?
Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250510/7620242d/attachment.htm>
More information about the J3
mailing list