[Fortran] 纯文本查看 复制代码
Module mod_xyz
Implicit none
real,protected::pi=acos(-1.0)
real,protected::L=1
real,protected::N=11
Contains
Subroutine Wik_(G,W,M,x,y,z,H)
Implicit none
real*8::G(1),M(11),W(1,11),x(11),y(11),z(11),H
Integer::i=1,k=0,a,b,c
Do a=1,N,1
x(a)=(L/2)*(1-cos(((a-1.0)/(N-1.0))*pi))
END Do
Do b=1,N,1
z(b)=(L/2)*(1-cos(((b-1.0)/(N-1.0))*pi))
END Do
Do c=1,N,1
y(c)=(L/2)*(1-cos(((c-1.0)/(N-1.0))*pi))
END Do
Do
k=1+k
if (i==k)then
call G_Mii(G,W,M,x,y,z,a,b)
write(*,*)"G=",G(a)
write(*,*)"W=",W
end if
if(i/=k.and.k<12)then
call G_Mik(G,W,M,x,y,z,a,b)
write(*,*)"z=",z(b)
write(*,*)"x=",x(a)
write(*,*)"G=",G(a)
write(*,*)"M=",M(b)
write(*,*)"H=",H
write(*,*)"W=",W
end if
stop
end do
end Subroutine Wik_
Subroutine G_Mii(G,W,M,x,y,z,a,b)
Implicit none
real*8::G(1),M(11),W(1,11),x(11),y(11),z(11)
Integer::i,k,a,b
a=i
G(a)=product(x(a)-y,y/=x(a))
W(a,a)=1/G(a)
end Subroutine G_Mii
Subroutine G_Mik(G,W,M,x,y,z,a,b)
Implicit none
real*8::G(1),M(11),W(1,11),x(11),y(11),z(11),H
Integer::i,j,k,N,a,b
a=i
b=k
G(a)=product(x(a)-y,y/=x(a))
M(b)=product(z(b)-y,y/=z(b))
H=1/(x(a)-x(b))
W(a,b)=H*G(a)/M(b)
end Subroutine G_Mik
end Module mod_xyz
program main_mik
use mod_xyz
call Wik_(G,M,W,x,y,z,H)
end program main_mik