| 5 | 1/1 | 返回列表 |
| 查看: 997 | 回復(fù): 3 | ||
| 當(dāng)前只顯示滿足指定條件的回帖,點擊這里查看本話題的所有回帖 | ||
[求助]
找不出毛病不知怎么改? 已有1人參與
|
||
|
計算系數(shù)矩陣為上三角的線性方程組Ax=b的解,N維 代碼: !############################################## module tri_eq contains subroutine uptri(A,b,x,N) implicit real*8(a-z) !a到z開頭的變量都視為雙精度浮點數(shù) integer::i,j,k,N real*8::A(N,N),b(N),x(N) x(N)=b(N)/A(N,N) !回代部分 do i=N-1,1,-1 do j=i+1,N x(i)=b(i)-a(i,j)*x(j) end do x(i)=x(i)/A(i,i) end do end subroutine uptri end module tri_eq !############################################ module driver contains subroutine dri_main() implicit real*8(a-z) integer::ioerr !ioerr=0 character(20)::uptr open(unit=11,file='fin.txt',iostat=ioerr) open(unit=12,file='fout.txt') do read(11,*) uptr !讀輸入文件 if(uptr(1:5)=='uptri') !提示這里有錯誤 call dri_up() if(ioerr/=0) exit end do end subroutine dri_main subroutine dri_up() use tri_eq implicit real*8(a-z) integer,parameter::N=4 integer::i,j real*8::A(N,N),b(N),x(N) read(11,*)((A(i,j),j=1,N),i=1,N) !讀入b向量 read(11,*) b call uptri(A,b,x,N) write(12,101) x 101 format(T5,'上三角方程組的解',/,T4,'x='4(/f12.8)) end subroutine dri_up end module driver !################################################ program main use driver call dri_main() end program main !################################################# 其中fin.txt如下 uptri 2 1 4 3 0 3 2 5 0 0 7 3 0 0 0 2 50 49 53 12 編譯信息: D:\fortran_programming\myfirst\main.f95:31.34: if(uptr(1:5)=='uptri') 1 Error: Cannot assign to a named constant at (1) D:\fortran_programming\myfirst\main.f95:51.8: use driver 1 Fatal Error: Can't open module file 'driver.mod' for reading at (1): No such file or directory Process terminated with status 1 (0 minute(s), 0 second(s)) 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) |


| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 一志愿北京科技大學(xué)085601材料工程英一數(shù)二初試總分335求調(diào)劑 +8 | 雙馬尾痞老板2 2026-04-01 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 337求調(diào)劑 +11 | 《樹》 2026-03-29 | 11/550 |
|
|
[考研] 324求調(diào)劑 +5 | 想上學(xué)求調(diào) 2026-04-01 | 6/300 |
|
|
[考研] 270調(diào)劑 +7 | maxjxbsk 2026-04-02 | 7/350 |
|
|
[考研] 343求調(diào)劑085601 +4 | 要努力學(xué)習(xí)x 2026-03-29 | 5/250 |
|
|
[考研] 08生物與醫(yī)藥專碩初試346找調(diào)劑 +6 | dianeeee 2026-04-01 | 7/350 |
|
|
[考研] 材料求調(diào)劑 +8 | 呢呢妮妮 2026-04-01 | 8/400 |
|
|
[考研] 282求調(diào)劑 +17 | ycy1201 2026-04-01 | 19/950 |
|
|
[考研] 285求調(diào)劑 +11 | AZMK 2026-04-01 | 11/550 |
|
|
[考研] 材料調(diào)劑 +14 | 一樣YWY 2026-04-01 | 14/700 |
|
|
[考研] 310分求調(diào)劑 +4 | 成功上岸wang 2026-04-01 | 4/200 |
|
|
[考研] 353求調(diào)劑 +4 | 拉鉤不許變 2026-04-01 | 4/200 |
|
|
[考研] 材料專業(yè)調(diào)劑 +5 | 啦啦啦哭 2026-03-31 | 6/300 |
|
|
[考研] 291求調(diào)劑 +3 | 迷蒙木木 2026-04-01 | 4/200 |
|
|
[考研] 375求調(diào)劑 +7 | 雨夏整夜 2026-03-29 | 7/350 |
|
|
[考研] 本科211安全工程,初試290分,求調(diào)劑 +3 | 2719846834 2026-03-28 | 3/150 |
|
|
[考研] 085600 286分 材料求調(diào)劑 +11 | 麻辣魷魚 2026-03-27 | 12/600 |
|
|
[考研] 求調(diào)劑 +10 | 家佳佳佳佳佳 2026-03-29 | 10/500 |
|
|
[考研] 環(huán)境科學(xué)與工程334分求調(diào)劑 +6 | 王一一依依 2026-03-30 | 8/400 |
|
|
[考研] 085602 化工專碩 338分 求調(diào)劑 +12 | 路癡小琪 2026-03-27 | 12/600 |
|