[問題] 我實在看不出fortran compiler說的錯誤是什麼@@
我檢查很多次了
但我實在看不出我錯在哪裡@@
請各位高手能夠指教一下><
唉~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
推
08/30 22:11, , 1F
08/30 22:11, 1F
推
08/30 23:24, , 2F
08/30 23:24, 2F
→
08/30 23:26, , 3F
08/30 23:26, 3F
推
09/13 22:22, , 4F
09/13 22:22, 4F
推
09/13 22:25, , 5F
09/13 22:25, 5F
Programming 近期熱門文章
PTT數位生活區 即時熱門文章