[問題] 我實在看不出fortran compiler說的錯誤是什麼@@

看板Programming作者 (人還挺多的嘛)時間18年前 (2006/08/30 20:34), 編輯推噓4(401)
留言5則, 3人參與, 最新討論串1/1
我檢查很多次了 但我實在看不出我錯在哪裡@@ 請各位高手能夠指教一下>< 唉~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
if的語法弄錯了 邏輯部份要用()包住
08/30 22:11, 1F

08/30 23:24, , 2F
是喔是喔@@ , 謝謝 好厲害~
08/30 23:24, 2F

08/30 23:26, , 3F
不過你的id好眼熟@@
08/30 23:26, 3F

09/13 22:22, , 4F
77的,if的=要用.eq.(77以後我就不知了)
09/13 22:22, 4F

09/13 22:25, , 5F
剛剛查了,90的等於==(兩個等號)
09/13 22:25, 5F
文章代碼(AID): #14zONHH0 (Programming)
文章代碼(AID): #14zONHH0 (Programming)