【发布时间】:2021-11-12 14:11:25
【问题描述】:
我正在努力学习使用函数。我有以下代码:
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
【问题讨论】:
标签: fortran