作者t70349 (JAY)
看板Fortran
標題[請益] 關於TDMA的程式碼
時間Fri Aug 26 19:27:11 2011
以下是我的程式碼 COMPILE無錯誤
executing卻有問題
請各位高手幫忙
我是新手請大家多指教
program aaa
parameter n=5
dimension a(n),b(n),c(n),q(n),bb(n),x(n)
do 10 i=1,n
a(i)=1.
c(i)=1.
10 continue
b(1)=1
b(2)=2
b(3)=3
b(4)=4
b(5)=5
q(1)=3
q(2)=8
q(3)=15
q(4)=24
q(5)=29
call trdiaq(5,a,b,c,x,q)
write(*,*)x
stop
end
subroutine trdiaq(n,a,b,c,x,q)
dimension a(n),b(n),c(n),q(n),bb(n),x(n)
do 1 i=1,n
bb(i)=b(i)
1 continue
do 2 i=2,n
t=a(i)/bb(i-1)
bb(i)=bb(i)-c(i-1)*t
q(i)=q(i)-q(i-1)*t
2 continue
x(n)=q(n)/bb(n)
do 3 i=1,n-1
j=n-i
x(j)=(q(j)-c(j)*x(j+1))/bb(j)
3 continue
return
end
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.33.174
1F:推 terryys:有什麼問題?起碼說明一下吧 08/26 19:57
2F:→ t70349:一個error,但完全不知道錯在哪^^ 08/26 20:14
3F:推 terryys:我編譯(ifort test.f90)執行沒有問題,輸出為1 2 3 4 5 08/26 20:36
4F:→ terryys:不知道你編譯有沒有加上別的檔案? 08/26 20:36
5F:→ t70349:我用compaq怎跑不出來 08/26 20:39
6F:→ t70349:完全沒加其他檔案 08/26 20:42
7F:→ t70349:terryys謝謝你...確實加上其他檔案了 08/26 20:49