[Fortran] 纯文本查看 复制代码
function func(a, b, c) result(output)
real(8), intent(in):: a, b, c
real(8), intent(inout):: output
...
end function func
[Fortran] 纯文本查看 复制代码
program main
implicit none
real, allocatable:: array(:)
array = linspace(0.,1.,11)
print '(*(f3.1,/))', array
contains
function linspace(arg1, arg2, N) result(output)
implicit none
real:: arg1, arg2
integer:: N
real(8),dimension(N):: output
integer:: i
output(1) = arg1
if (N>1) then
do i = 2, N
output(i) = arg1 + (i-1)*(arg2-arg1)/(N-1)
end do
end if
end function
end