我有编写的该程序试图测试是否可以定义用户输入的函数,然后让Fortran对其进行求和。这就是我所做的。
program test
real :: a,b,n,k,sum
integer, intent(out) :: func
print *, 'what are the values of a b n k?'
read *, a,b,n,k
print *, 'what is the function?'
read *, func
sum = 0
DO I= 1, 6
x = ((A)+I * ((b-a)/(n)))
sum = sum + func
END DO
print *, sum
end program test
作为返回,编译器表示:
sh-4.3$ gfortran -std=f95 *.f95 -o main
Newfile.f95:5:28:
integer, intent(out) :: func
1
Error: Symbol at (1) is not a DUMMY variable
有任何想法吗?
最佳答案
integer, intent(out) :: func
可以用来声明过程参数,但是您将其放入了主程序中。
那里的
intent(out)
没有意义。一个不同的问题是,不清楚程序中应该包含什么功能。
关于function - 函数输入进行求和运算的求和问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39499609/