fortran求找错program dsdimplicit nonereal(8) ::a(2,2)data a/1,3,2,4/call brinv(a,2)print*,aend program dsdsubroutine brinv(a,n)dimension a(n,n),is(n),js(n)double precision a,t,dl=1do 100 k=1,nd=0.0do 10 i=k,ndo 10 j=k,nif(abs(a(i,j)).gt.d) thend=a
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/14 11:16:57
fortran求找错program dsdimplicit nonereal(8) ::a(2,2)data a/1,3,2,4/call brinv(a,2)print*,aend program dsdsubroutine brinv(a,n)dimension a(n,n),is(n),js(n)double precision a,t,dl=1do 100 k=1,nd=0.0do 10 i=k,ndo 10 j=k,nif(abs(a(i,j)).gt.d) thend=a
fortran求找错
program dsd
implicit none
real(8) ::a(2,2)
data a/1,3,2,4/
call brinv(a,2)
print*,a
end program dsd
subroutine brinv(a,n)
dimension a(n,n),is(n),js(n)
double precision a,t,d
l=1
do 100 k=1,n
d=0.0
do 10 i=k,n
do 10 j=k,n
if(abs(a(i,j)).gt.d) then
d=abs(a(i,j))
is(k)=i
is(K)=j
end if
10 continue
if(d+1.0.eq.1.0) then
l=0
write(*,20)
return
end if
20 format(1x,'err**not inv')
do 30 j=1,n
t=a(k,j)
a(k,j)=a(is(k),j)
a(is(k),j)=t
30 continue
do 40 i=1,n
t=a(i,k)
a(i,k)=a(i,js(k))
a(i,js(k))=t
40 continue
a(k,k)=1/a(k,k)
do 50 j=1,n
if(j.ne.k)then
a(k,j)=a(k,j)*a(k,k)
end if
50 continue
do 70 i=1,n
if(i.ne.k)then
do 60 j=1,n
if(j.ne.k)then
a(i,j)=a(i,j)-a(i,k)*a(k,j)
end if
60 continue
end if
70 continue
do 80 i=1,n
if(i.ne.k)then
a(i,k)=-a(i,k)*a(k,k)
end if
80 continue
100 continue
do 130 k=n,1,-1
do 110 j=1,n
t=a(k,j)
a(k,j)=a(js(k),j)
a(js(k),j)=t
110 continue
do 120 i=1,n
t=a(i,k)
a(i,k)=a(i,is(k))
a(i,is(k))=t
120 continue
130 continue
return
end
fortran求找错program dsdimplicit nonereal(8) ::a(2,2)data a/1,3,2,4/call brinv(a,2)print*,aend program dsdsubroutine brinv(a,n)dimension a(n,n),is(n),js(n)double precision a,t,dl=1do 100 k=1,nd=0.0do 10 i=k,ndo 10 j=k,nif(abs(a(i,j)).gt.d) thend=a
不知道你这程序是干什么的
但感觉你里边的一个 is(K)=j 应该改成 js(K)=j
改了后可以运行