[J3] Passing an element of an assumed shape array to an assumed size dummy array

Van Snyder van.snyder at sbcglobal.net
Sat May 10 18:15:55 UTC 2025


On Sat, 2025-05-10 at 11:35 +0000, Pierre Hugonnet via J3 wrote:
> 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 

In FORTRAN 66 and FORTRAN 77, this actually meant

 call bar ( x(10:))

in modern syntax. Did we explicitly remove this sequence association
without remarking about an incompatibility?

>     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/375625dd/attachment.htm>


More information about the J3 mailing list