[J3] Vector subscripts and INTENT(INOUT)
Bill Long
longb at cray.com
Thu May 10 18:46:13 EDT 2018
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
More information about the J3
mailing list