看板 Programming 關於我們 聯絡資訊
我檢查很多次了 但我實在看不出我錯在哪裡@@ 請各位高手能夠指教一下>< 唉~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
latinboy:if的語法弄錯了 邏輯部份要用()包住 140.112.23.251 08/30 22:11
pianoboy:是喔是喔@@ , 謝謝 好厲害~ 59.115.119.6 08/30 23:24
pianoboy:不過你的id好眼熟@@ 59.115.119.6 08/30 23:26
onezillion:77的,if的=要用.eq.(77以後我就不知了)140.115.223.124 09/13 22:22
onezillion:剛剛查了,90的等於==(兩個等號)140.115.223.124 09/13 22:25