良好实践规定Fortran中的子例程参数应该都具有指定的意图(即intent(in),intent(out)或者如此问题intent(inout)所描述的):
subroutine bar (a, b)
real, intent(in) :: a
real, intent(inout) :: b
b = b + a
...
Run Code Online (Sandbox Code Playgroud)
但是,未指定intent是有效的Fortran:
subroutine bar (a, b)
real, intent(in) :: a
real :: b
b = b + a
...
Run Code Online (Sandbox Code Playgroud)
在编译时检查指定intent(inout)的参数和没有指定意图的参数之间是否存在任何真正的差异?如果我正在改进对较旧的,无意图的代码的意图,我还有什么可担心的吗?