From owner-sc22wg5+sc22wg5-dom9=www.open-std.org@open-std.org  Tue Aug  2 19:59:30 2022
Return-Path: <owner-sc22wg5+sc22wg5-dom9=www.open-std.org@open-std.org>
X-Original-To: sc22wg5-dom9
Delivered-To: sc22wg5-dom9@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id 5AAD7358D56; Tue,  2 Aug 2022 19:59:30 +0200 (CEST)
Delivered-To: sc22wg5@open-std.org
Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127])
	by www.open-std.org (Postfix) with ESMTP id 0C582356DFA
	for <sc22wg5@open-std.org>; Tue,  2 Aug 2022 19:59:28 +0200 (CEST)
Received: from [192.168.1.17] ([86.215.161.154])
	by smtp.orange.fr with ESMTPA
	id IwAqoiC7MsL0zIwAxo4ny9; Tue, 02 Aug 2022 19:59:28 +0200
X-ME-Helo: [192.168.1.17]
X-ME-Auth: MDU4MTIxYWM4YWI0ZGE4ZTUwZWZmNTExZmI2ZWZlMThkM2ZhYiE5OWRkOGM=
X-ME-Date: Tue, 02 Aug 2022 19:59:28 +0200
X-ME-IP: 86.215.161.154
Message-ID: <8052c954-ffc1-9b66-63c4-cb4640694709@orange.fr>
Date: Tue, 2 Aug 2022 19:59:20 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.10.0
From: Mikael Morin <morin-mikael@orange.fr>
Subject: Request for interpretation of compile-time restrictions on ASSOCIATED
To: sc22wg5@open-std.org
Cc: Harald Anlauf <anlauf@gmx.de>
Content-Language: en-US
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Sender: owner-sc22wg5@open-std.org
Precedence: bulk

Hello,

we are contributors to gfortran.  We have been discussing the 
restrictions a processor is required to put on ASSOCIATED functions 
calls with regards to rank mismatch in the thread at:
> https://gcc.gnu.org/pipermail/fortran/2022-July/058012.html
The following discussions are on the same topic as well:
> https://groups.google.com/g/comp.lang.fortran/c/BQfpeDZxX3Q
> 
https://community.intel.com/t5/Intel-Fortran-Compiler/Intel-rejects-ASSOCIATED-pointer-target-for-non-equal-ranks/m-p/1402799/highlight/true#M162159

The position from Steve Lionel in the latter threads is that a processor 
is required to reject an ASSOCIATED function call with arguments of 
mismatching ranks as there is no bounds-remapping list.
Our understanding is that a processor shall accept it as long as it may 
accept a corresponding pointer association statement with additional 
bounds-remapping list.

Our poll of existing compilers shows the same disagreement, with two 
accepting mismatching ranks (cray 14.0, nvidia 22.5) and two rejecting 
them (NAG 7.0 & 7.1, Intel).

So we would like an official interpretation on this topic.
More specifically, for each program below, is a processor (at compile 
time) required to reject it, allowed to reject it but not required to, 
or required to accept it?

Thanks in advance.
Harald Anlauf, Mikael Morin

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Example 1
! matrix pointer vs array target
program p
   real, dimension(100),  target  :: array
   real, dimension(:,:),  pointer :: pmatrix => null()
   print *, associated(pmatrix, array)
end

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Example 2
! array pointer vs matrix target
program p
   real, dimension(20,5), target  :: matrix
   real, dimension(:),    pointer :: parray => null()
   print *, associated(parray, matrix)
end

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Example 3
! array pointer vs rank 2 non-contiguous target
program p
   real, dimension(20,5), target  :: matrix
   real, dimension(:),    pointer :: parray => null()
   print *, associated(parray, matrix(1:20:3, 1:5:2))
end

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Example 4
! array pointer vs scalar target
program p
   real, target :: scalar
   real, dimension(:), pointer :: parray => null()
   print *, associated(parray, scalar)
end

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Example 5
! scalar pointer vs array target
program p
   real, dimension(100), target :: array
   real, pointer :: pscalar => null()
   print *, associated(pscalar, array)
end

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Example 6
! assumed rank (array) pointer vs matrix target
program p
   real, dimension(20,5), target  :: matrix
   real, dimension(:),    pointer :: parray => null()
   call sub(parray)
contains
   subroutine sub(ptr)
     real, pointer :: ptr(..)
     print *, associated(ptr, matrix)
   end subroutine sub
end

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Example 7
! assumed rank (scalar) pointer vs array target
program p
   real, dimension(100), target :: array
   real, pointer :: pscalar => null()
   call sub(pscalar)
contains
   subroutine sub(ptr)
     real, pointer :: ptr(..)
     print *, associated(ptr, array)
   end subroutine sub
end

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Example 8
! assumed rank (array) pointer vs scalar target
program p
   real, target :: scalar
   real, dimension(:), pointer :: parray => null()
   call sub(parray)
contains
   subroutine sub(ptr)
     real, pointer :: ptr(..)
     print *, associated(ptr, scalar)
   end subroutine sub
end

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
