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

Robert Corbett rpcorbett at att.net
Sun May 11 04:07:10 UTC 2025


There is no incompatibility with FORTRAN 66 or FORTRAN 77.  The restriction on passing a scalar actual argument to an array dummy arguments applies only to assumed-shape, pointer, or polymorphic arrays (see the first dotted item in paragraph 14 of Subclause 15.5.2.5).  Therefore, the only incompatibility with FORTRAN 66 or FORTRAN 77 codes is with FORTRAN 66 or FORTRAN 77 codes that include assumed-shape, pointer, or polymorphic arrays.

Bob Corbett

> On May 10, 2025, at 11:16 AM, Van Snyder via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> 
>> 
>> 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/14fa8e95/attachment.htm>


More information about the J3 mailing list