[Fortran] 纯文本查看 复制代码 Module m_wik
Contains
Subroutine Wik_()
Implicit none
Integer,parameter::N=10
Integer::a=0,b=0,i,k,j,c,d
real*8::G(N),M(N),Wik(N,N),x(N),y(N),z(N),H,pi=acos(-1.0),L=16
Do i=1,N
x(i)=(L/2)*(1-cos(((i-1.0)/(N-1.0))*pi))
END Do
open(unit=16,file='X.txt')
write(16,105)x
105 format(T4,'x=',10(/F21.8))
close(16)
y=x
z=x
DO
100 a=a+1
Do
b=1+b
if (a==b)then
i=a
k=b
Wik(i,k)=sum(1/(x(i)-y),y/=x(i))
if(a==N.and.b==N)then
exit
end if
end if
if(a/=b.and.b<=N)then
i=a
k=b
G(i)=product(x(i)-y,y/=x(i))
M(k)=product(z(k)-y,y/=z(k))
H=1/(x(i)-x(k))
Wik(i,k)=H*G(i)/M(k)
end if
if (b==N)then
b=0
Goto 100
end if
end do
exit
end do
open(unit=15,file='Wik.txt')
write(15,104)((Wik(c,d),d=1,N),c=1,N)!写入Wik
104 format(10(F20.10,2x))
close(15)
end Subroutine Wik_
end Module m_wik
|