我正在尝试学习使用函数。我有以下代码:
program main
implicit none
write(*,*) test(4)
end program
integer function test(n)
implicit none
integer, intent(in) :: n
integer :: i, ans
ans=1
do i=1,n
ans=ans*i
enddo
test=ans
end function test
当我编译(使用 gfortran 4.1.2)时,出现以下错误:
In file test.f90:4
write(*,*) test(4)
1
Error: Function 'test' at (1) has no IMPLICIT type