我可以使用带有intent(in)和的子程序的Fortran可选intent(inout)参数,但是函数可选参数只能用于intent(in),对吗?随着intent(inout)我得到了下面的代码段错误:
real function foo(x, tol)
real, intent(in) :: x
real, optional, intent(inout) :: tol
if( .not. present(tol) ) tol = 1e-6
!...
end function foo
Run Code Online (Sandbox Code Playgroud)