[J3] Vector subscripts and INTENT(INOUT)

Bill Long longb at cray.com
Fri May 11 16:15:32 EDT 2018


Thanks to Bob for the interesting history.


> On May 10, 2018, at 8:48 PM, Malcolm Cohen via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> > This pretty flatly says the CALL is not conforming,
>  
> Yes…


I agree that this is a good rule to have.  As noted, the user can get around this if needed by making a temp explicitly. And the copy-out is messy, at least on most hardware. 


>  
> > and says directly that any array section with a vector subscript is not definable. 
> 
> No it does not.  Read it again: it says the *dummy* is not definable.  A dummy argument is not any kind of array section, let alone one with a vector subscript – it is a whole array.  This has no bearing whatsoever on whether an array section with a vector subscript is definable.


So, “A dummy argument is definable if and only if the corresponding actual argument is definable” is a false statement. 


>  
> >Since the rules for INTENT(INOUT) (8.5.10 p4)
> >
> >• The INTENT (INOUT) attribute for a nonpointer dummy argument specifies that any actual argument that corresponds to the dummy argument shall be definable.
> >
> >hinge on whether the actual argument is definable
>  
> No they don’t.  This is what it specifies.  However, there are other requirements that interact with INTENT(INOUT), one of which you have found.

This seems incomplete, and forces the reader into theorem-proving to know the actual restriction.  Since the subclause on INTENT is inherently about dummy arguments and association rules thereof, it would seem reasonable to add “ and shall not be an array section with a vector subscript” to the end of the sentence.  That way all the relevant information is in one place.  


>  
> > Is an array section with a vector subscript that has no repeated values definable?
>  
> Only if the base array is definable (not always the case!).  This is perfectly straightforward – a vector-subscripted array variable is itself a variable, and therefore definable unless there is a rule otherwise, which there is not.

So, if I remove the INTENT(INOUT) from the example code  [hence no INTENT specified], then the code should be conforming.  Although trying that version, which does compile, results in all zero values being printed, as if the subroutine was not executed. I.e. copy-in, but no copy-out.  That is the case for multiple compilers. 

If we intend that no INTENT specified has a special restriction that the dummy argument corresponding to an actual that is an array section with a vector subscript has to, effectively, have the INTENT(IN) or VALUE attribute, then it would be useful to say that.  Particularly if we add INTENT(NONE) in the next revision, and have to specify what that means.   It would be simple to add this to 15.5.2.4 p6, if that is want is intended. 

> 

Cheers,
Bill

> From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Bill Long via J3
> Sent: Friday, May 11, 2018 7:46 AM
> To: General J3 interest list <j3 at mailman.j3-fortran.org>
> Cc: Bill Long <longb at cray.com>
> Subject: [J3] Vector subscripts and INTENT(INOUT)
>  
> Consider this example code:
> 
> program test_vector
> implicit none
> integer :: iv(5) = [1,3,5,7,9]
> integer :: dat(10) = 0
> 
> call sub (dat(iv))
> print *, dat
> 
> contains
> 
> subroutine sub (array)
> integer,intent(inout) :: array(:)
> 
> array = 1
> end subroutine sub
> 
> 
> Multiple compilers reject this code based on this requirement in Clause 15:
> 
> 
> 15.5.2.4 p19
> 
> • If the procedure is nonelemental, the dummy argument does not have the VALUE attribute, and the actual argument is an array section having a vector subscript, the dummy argument is not definable and shall not have the ASYNCHRONOUS, INTENT (OUT), INTENT (INOUT), or VOLATILE attributes.
> 
> This pretty flatly says the CALL is not conforming, and says directly that any array section with a vector subscript is not definable. 
> 
> 
> However, we have in 9.5.3.3.2:
> 
> " • If a vector subscript has two or more elements with the same value, an array section with that vector subscript
> is not definable and shall not be defined or become undefined.”
> 
> which is more limited, and suggests that a vector subscript that does NOT have repeated values produces an array section that COULD BE definable, 
> 
> 
> Since the rules for INTENT(INOUT) (8.5.10 p4)
> 
> • The INTENT (INOUT) attribute for a nonpointer dummy argument specifies that any actual argument that corresponds to the dummy argument shall be definable.
> 
> hinge on whether the actual argument is definable, there seems to be an inconsistency.
> 
> 
> So: Is an array section with a vector subscript that has no repeated values definable? If not, why does the limitation in 9.5.3.3.2 have the qualification on ‘same value’?
> 
> Cheers,
> Bill
> 
> 
> Bill Long longb at cray.com
> Principal Engineer, Fortran Technical Support & voice: 651-605-9024
> Bioinformatics Software Development fax: 651-605-9143
> Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
> 
> 
> Disclaimer
> The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
> 
> This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.

Bill Long                                                                       longb at cray.com
Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
Bioinformatics Software Development                      fax:  651-605-9143
Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425




More information about the J3 mailing list