[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(1),W(1),x(11),y(11),z(11),H
Integer::i=1,k=0,a,b,c
CALL xyz_(x,y,z)
do
k=1+k
if (i==k)then
call G_Mii(G,W,M,x,y,z,a,b)
write(*,*)"G=",G
write(*,*)"W=",W
else
call G_Mik(G,W,M,x,y,z,a,b)
write(*,*)"z=",z(b)
write(*,*)"x=",x(a)
write(*,*)"G=",G
write(*,*)"M=",M
write(*,*)"H=",H
write(*,*)"W=",W
end if
end do
end Subroutine Wik_
Subroutine xyz_(x,y,z)
real*8::x(11),y(11),z(11)
Integer::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
end Subroutine xyz_
Subroutine G_Mii(G,W,M,x,y,z,a,b)
Implicit none
real*8::G(1),M(1),W(1),x(11),y(11),z(11)
Integer::i,k,a,b
a=i
b=k
G=product(x(a)-y,y/=x(a))
M=product(z(b)-y,y/=z(b))
W=1/G
end Subroutine G_Mii
Subroutine G_Mik(G,W,M,x,y,z,a,b)
Implicit none
real*8::G(1),M(1),W(1),x(11),y(11),z(11)
Integer::i,j,k,H,N,a,b
a=i
b=k
G=product(x(a)-y,y/=x(a))
M=product(z(b)-y,y/=z(b))
H=1/(x(i)-x(k))
W=H*G/M
end Subroutine G_Mik
end Module mod_xyz
program main_mik
use mod_xyz
end program main_mik