这取决于......因此functions,不可能有两个不同的功能结果.但是,您可以从函数返回一个长度为2的数组.
function myfunc(x, y)
implicit none
integer, intent(in) :: x,y
integer :: myfunc(2)
myfunc = [ 2*x, 3*y ]
end function
Run Code Online (Sandbox Code Playgroud)
如果需要两个返回值到两个不同的变量,请使用subroutine:
subroutine myfunc(x, y, a, b)
implicit none
integer, intent(in) :: x,y
integer, intent(out):: a,b
a = 2*x
b = 3*y
end subroutine
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3904 次 |
| 最近记录: |