|
地板
楼主 |
发表于 2018-1-15 10:18:07
|
只看该作者
错误行应该是第20行(x=work(a,c,d,y,nmax))
[Fortran] 纯文本查看 复制代码 subroutine absorption(p0,p,m,lamda,kmax,mmax,nmax)
!solve the second part
implicit none
integer :: i,m
integer :: kmax,mmax,nmax
real,dimension(kmax,mmax,nmax) :: p,p0
real,dimension(nmax):: x,y
real,dimension(nmax):: a,c,d
real,external :: work
! y-p_m,x-p_m+1
real :: lamda
do i=1,nmax
a(i)=-lamda
c(i)=-lamda
d(i)=1+2*lamda
end do
do i=1,kmax
y=p0(i,m,:)
x=work(a,c,d,y,nmax)
p(i,m,:)=x(:)
end do
end subroutine absorption
另外work函数的代码是:
[Fortran] 纯文本查看 复制代码 function work(a,c,d,b,ranka)
! lamda-matrix A;y-right side;m-A(rank-1*rank-1)
implicit none
integer ranka,i
real,dimension(ranka):: a,c,d,work,y,b,r,delta,beta
!real :: lamda,d,c,a
!d=1+2*lamda
!a=-lamda
!c=-a
r(1)=d(1)
delta(1)=c(1)/r(1)
y(1)=b(1)/r(1)
do i=2,ranka
beta(i)=a(i)
r(i)=d(i)-beta(i)*delta(i-1)
delta(i)=c(i)/r(i)
y(i)=(b(i)-beta(i)*y(i-1))/r(i)
end do
! step1:Ly=b
work(ranka)=y(ranka)
do i=ranka-1,1,-1
work(i)=y(i)-delta(i)*work(i+1)
end do
! step2:Ux(work)=y
end function work |
|