Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fortran INTENT attribute with an actual argument with vector subscript

Intel's documentation about the intent attribute says

If an actual argument is an array section with a vector subscript, it cannot be associated with a dummy array that is defined or redefined (has intent OUT or INOUT).

How should I understand the description?

Does it mean that the following code is wrong?

subroutine sub(a)
    real, intent(out) :: a(:)
end subroutine sub

real :: arr(3,4)
call sub(arr(1,:))
like image 297
Rubin Avatar asked Sep 19 '25 19:09

Rubin


1 Answers

That is fine, it is an array section rather than a vector subscript. The latter is where you use a rank one integer array expression for the subscripts. Extending your example:

subroutine sub(a)
    real, intent(out) :: a(:)
end subroutine sub

real :: arr(3,4)
call sub(arr(1,:))           ! Legal
call sub(arr(1,[ 1, 2, 4 ] ) ! Illegal
like image 129
Ian Bush Avatar answered Sep 23 '25 07:09

Ian Bush