| 4 | 1/1 | 返回列表 |
| 查看: 978 | 回復(fù): 3 | ||
[求助]
找不出毛病不知怎么改? 已有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)) |


| 4 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 【考研調(diào)劑】化學(xué)專業(yè) 281分,一志愿四川大學(xué),誠心求調(diào)劑 +8 | 吃吃吃才有意義 2026-03-19 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 一志愿 西北大學(xué) ,070300化學(xué)學(xué)碩,總分287,雙非一本,求調(diào)劑。 +3 | 晨昏線與星海 2026-03-18 | 3/150 |
|
|
[考研] 299求調(diào)劑 +4 | shxchem 2026-03-20 | 5/250 |
|
|
[考研] 材料專業(yè)求調(diào)劑 +6 | hanamiko 2026-03-18 | 6/300 |
|
|
[考研] 085600材料與化工 +8 | 安全上岸! 2026-03-16 | 8/400 |
|
|
[考研] 一志愿蘇州大學(xué)材料求調(diào)劑,總分315(英一) +5 | sbdksD 2026-03-19 | 5/250 |
|
|
[考研] 北科281學(xué)碩材料求調(diào)劑 +5 | tcxiaoxx 2026-03-20 | 5/250 |
|
|
[考研]
|
簡木ChuFront 2026-03-19 | 8/400 |
|
|
[基金申請]
學(xué)校已經(jīng)提交到NSFC,還能修改嗎?
40+4
|
babangida 2026-03-19 | 8/400 |
|
|
[考研] 梁成偉老師課題組歡迎你的加入 +9 | 一鴨鴨喲 2026-03-14 | 11/550 |
|
|
[考研] 0703化學(xué)調(diào)劑 +4 | 18889395102 2026-03-18 | 4/200 |
|
|
[考研] 085600材料與化工調(diào)劑 324分 +10 | llllkkkhh 2026-03-18 | 12/600 |
|
|
[考研] 085601專碩,總分342求調(diào)劑,地區(qū)不限 +5 | share_joy 2026-03-16 | 5/250 |
|
|
[考研] 收復(fù)試調(diào)劑生 +4 | 雨后秋荷 2026-03-18 | 4/200 |
|
|
[考研] 0703化學(xué)調(diào)劑 +3 | 妮妮ninicgb 2026-03-17 | 3/150 |
|
|
[考研] 268求調(diào)劑 +8 | 一定有學(xué)上- 2026-03-14 | 9/450 |
|
|
[碩博家園] 湖北工業(yè)大學(xué) 生命科學(xué)與健康學(xué)院-課題組招收2026級食品/生物方向碩士 +3 | 1喜春8 2026-03-17 | 5/250 |
|
|
[考研] 288求調(diào)劑 +4 | 奇點0314 2026-03-14 | 4/200 |
|
|
[考研] 中科大材料與化工319求調(diào)劑 +3 | 孟鑫材料 2026-03-14 | 3/150 |
|
|
[考研] 289求調(diào)劑 +4 | 這么名字咋樣 2026-03-14 | 6/300 |
|