| 4 | 1/1 | 返回列表 |
| 查看: 979 | 回復(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ā)表 | |
|---|---|---|---|---|
|
[考研] 材料工程(專)一志愿985 初試335求調(diào)劑 +3 | hiloiy 2026-03-17 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 328求調(diào)劑,英語六級551,有科研經(jīng)歷 +4 | 生物工程調(diào)劑 2026-03-17 | 8/400 |
|
|
[考研] 274求調(diào)劑 +10 | S.H1 2026-03-18 | 10/500 |
|
|
[考研] 330求調(diào)劑 +4 | 小材化本科 2026-03-18 | 4/200 |
|
|
[考研] 一志愿中南化學(xué)(0703)總分337求調(diào)劑 +8 | niko- 2026-03-19 | 9/450 |
|
|
[考研]
|
簡木ChuFront 2026-03-19 | 8/400 |
|
|
[考研] 一志愿華中農(nóng)業(yè)071010,總分320求調(diào)劑 +3 | 困困困困坤坤 2026-03-20 | 3/150 |
|
|
[考研] 353求調(diào)劑 +3 | 拉鉤不許變 2026-03-20 | 3/150 |
|
|
[基金申請]
學(xué)校已經(jīng)提交到NSFC,還能修改嗎?
40+4
|
babangida 2026-03-19 | 8/400 |
|
|
[考博] 招收博士1-2人 +3 | QGZDSYS 2026-03-18 | 3/150 |
|
|
[考研] 081700化工學(xué)碩調(diào)劑 +3 | 【1】 2026-03-16 | 3/150 |
|
|
[考研]
|
不想起名字112 2026-03-19 | 3/150 |
|
|
[考研] 材料與化工求調(diào)劑 +7 | 為學(xué)666 2026-03-16 | 7/350 |
|
|
[考研] 085600材料與化工求調(diào)劑 +6 | 緒幸與子 2026-03-17 | 6/300 |
|
|
[考研] 311求調(diào)劑 +11 | 冬十三 2026-03-15 | 12/600 |
|
|
[考研] 收復(fù)試調(diào)劑生 +4 | 雨后秋荷 2026-03-18 | 4/200 |
|
|
[考研] 304求調(diào)劑 +12 | 小熊joy 2026-03-14 | 13/650 |
|
|
[考研] 334求調(diào)劑 +3 | 志存高遠(yuǎn)意在機?/a> 2026-03-16 | 3/150 |
|
|
[考研] 268求調(diào)劑 +8 | 一定有學(xué)上- 2026-03-14 | 9/450 |
|
|
[考研] 321求調(diào)劑 +5 | 大米飯! 2026-03-15 | 5/250 |
|