作者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