gpt4 book ai didi

Fortran INTENT 属性,带有带向量下标的实参

转载 作者:行者123 更新时间:2023-12-04 17:37:32 31 4
gpt4 key购买 nike

the document about intent attribute

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).



我应该如何理解描述?

是不是说明下面的代码是错误的?
subroutine sub(a)
real, intent(out) :: a(:)
end subroutine sub

real :: arr(3,4)
call sub(arr(1,:))

最佳答案

那很好,它是一个数组部分而不是一个向量下标。后者是您对下标使用秩为一的整数数组表达式的地方。扩展您的示例:

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

关于Fortran INTENT 属性,带有带向量下标的实参,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56105863/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com