作者pianoboy (人还挺多的嘛)
看板Programming
标题[问题] 我实在看不出fortran compiler说的错误是什麽@@
时间Wed Aug 30 20:37:43 2006
我检查很多次了
但我实在看不出我错在哪里@@
请各位高手能够指教一下><
唉~Fortran真是难搞....
***************Compiler出现的错误讯息*****************************
[chkao@linux3 ~]$ g77 0828.f
0828.f: In subroutine `trapz':
0828.f:24:
if n = 1 then
^
Invalid form for IF statement at (^)
0828.f:24:
if n = 1 then
1
0828.f:26: (continued):
else
2
Statement at (2) invalid in context established by
statement at (1)
0828.f:24:
if n = 1 then
1
0828.f:32: (continued):
END IF
2
Statement at (2) invalid in context established by
statement at (1)
***************附上原程式^^***************************************
program calculus
integer n , i
real h,a,b
double precision func,s,p
a = 0
b = 1.5
p = 0
write(*,*) 'choose the number you want to divide?'
read(*,*) n
call trapz(n ,h,s,p,a,b)
write(*,*) p
end
subroutine trapz(n ,h,s,p,a,b)
integer n , i
real h ,a,b
double precision func,s,p
if n = 1 then
p = (func(a)+func(b))*(b-a)/2
else
do 100 i = 1 , n
s = (func(a) + func(1.5/n*i))*(b-a)/n/2
p = p + s
100 continue
END IF
end
double precision function func(x)
real x
func = 0.84885406 + 31.51924706*x - 137.66731262*x**2
- +240.55831238*x**3 - 171.45245361*x**4 + 41.95066071*x**5
end
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.109.177.124
1F:推 latinboy:if的语法弄错了 逻辑部份要用()包住 140.112.23.251 08/30 22:11
2F:推 pianoboy:是喔是喔@@ , 谢谢 好厉害~ 59.115.119.6 08/30 23:24
3F:→ pianoboy:不过你的id好眼熟@@ 59.115.119.6 08/30 23:26
4F:推 onezillion:77的,if的=要用.eq.(77以後我就不知了)140.115.223.124 09/13 22:22
5F:推 onezillion:刚刚查了,90的等於==(两个等号)140.115.223.124 09/13 22:25