【发布时间】:2016-01-02 09:39:32
【问题描述】:
这个问题与问题有关:如何检测子程序内部对intent(in)的违反。但是我在相关问题Enforce intent(in) declared variables in Fortran as constant also in called subroutines/functions中没有找到答案。
声明为intent(in) 的变量可以通过省略意图声明的另一个子程序/函数进行修改。
例如:
module test
implicit none
contains
subroutine fun1(x)
real(8), intent(in)::x
call fun2(x)
end subroutine
subroutine fun2(x)
real(8) :: x
x = 10
end subroutine
end module
gfortran 和 ifort 可以编译此代码而不会出现任何错误/警告。所以我的问题是:
- 是否可以禁止省略意图声明?
- 是否可以强制 Fortran 编译器将省略的意图解释为
intent(inout)?
【问题讨论】:
标签: fortran