Fortran "Error: Two main PROGRAMs at (1) and (2)”

Fortran "Error: Two main PROGRAMs at (1) and (2)”

我在编码时运行遇到了这个错误,但找不到任何合理的原因。我以前调用过并执行过这样的函数。代码是:

implicit none
real et(5),k(5,4),v(5),f1,f2,f3,f4,f5,kk,t,h
integer i,j
do i=1,5
et(i)=i-1.0
v(i)=0.0
end do
h=0.01
kk=6.0
do j=1,1000
write(*,*) et(1),et(2),et(3),et(4),et(5),t
do i=1,5
et(i)=et(i)+h*v(i)
end do
k(1,1)=h*f1(et(1),et(2),t) !partcle,k_no
k(2,1)=h*f2(et(1),et(2),et(3),t)
k(3,1)=h*f3(et(2),et(3),et(4),t)
k(4,1)=h*f4(et(3),et(4),et(5),t)
k(5,1)=h*f5(et(4),et(5),t)  
k(1,2)=h*f1(et(1)+0.5*k(1,1),et(2)+0.5*k(2,1),t+0.5*h)  
k(2,2)=h*f2(et(1)+0.5*k(1,1),et(2)+0.5*k(2,1),et(3)+0.5*k(3,1),
 +      t+0.5*h)
k(3,2)=h*f3(et(2)+0.5*k(2,1),et(3)+0.5*k(3,1),et(4)+0.5*k(4,1),
 +  t+0.5*h)
k(4,2)=h*f4(et(3)+0.5*k(3,1),et(4)+0.5*k(4,1),et(5)+0.5*k(5,1),
 +  t+0.5*h)
k(5,2)=h*f5(et(4)+0.5*k(4,1),et(5)+0.5*k(5,1),t+0.5*h)
k(1,3)=h*f1(et(1)+0.5*k(1,2),et(2)+0.5*k(2,2),t+0.5*h)
k(2,3)=h*f2(et(1)+0.5*k(1,2),et(2)+0.5*k(2,2),et(3)+0.5*k(3,2),
 +  t+0.5*h)
k(3,3)=h*f3(et(2)+0.5*k(2,2),et(3)+0.5*k(3,2),et(4)+0.5*k(4,2),
 +  t+0.5*h)
k(4,3)=h*f4(et(3)+0.5*k(3,2),et(4)+0.5*k(4,2),et(5)+0.5*k(5,2),
 +  t+0.5*h)
k(5,3)=h*f5(et(4)+0.5*k(4,2),et(5)+0.5*k(5,2),t+0.5*h)
k(1,4)=h*f1(et(1)+k(1,1),et(2)+k(2,1),t+h)
k(2,4)=h*f2(et(1)+k(1,1),et(2)+k(2,1),et(3)+k(3,1),t+h)
k(3,4)=h*f3(et(2)+k(2,1),et(3)+k(3,1),et(4)+k(4,1),t+h)
k(4,4)=h*f4(et(3)+k(3,1),et(4)+k(4,1),et(5)+k(5,1),t+h)
k(5,4)=h*f5(et(4)+k(4,1),et(5)+k(5,1),t+h)

do i=1,5
v(i)=v(i)+(1.0/6.0)*(k(1,i)+2*k(2,i)+2*k(3,i)+k(4,i))
end do

end do

end program


real function f1(et(1),et(2),t)


f1=kk*(et(2)-et(1))+cos(2*t)
return
end function

real function f2(et(1),et(2),et(3),t)

f2=kk*(et(3)-2*et(2)+et(1))
return
end function


real function f3(et(2),et(3),et(4),t)

f3=kk*(et(4)-2*et(3)+et(2))
return
end function

real function f4(et(3),et(4),et(5),t)
f4=kk*(et(5)-2*et(4)+et(3))
return
end function

real function f5(et(4),et(5),t) 

f5=kk*(et(4)-et(5))
return
end function

编译时仅给出此错误:

  implicit none                                                     
                                                                    1


  real function f1(et(1),et(2),t)                                   
                                                                    2
Error: Two main PROGRAMs at (1) and (2)

你能建议调试吗?以数组为参数调用函数有什么问题吗?

你不能用括号命名你的变量或虚拟参数:

 real function f1(et(1),et(2),t)

您必须正常命名它们,只能使用字母字符和数字

 real function f1(et1,et2,t)