|
在我的程序当中,调用子程序输出计算结果时,结果一直为0,不知道是哪里出现了问题,会是子例程出现了错误吗?
[Fortran] 纯文本查看 复制代码 Program workfile
Implicit none
integer , parameter :: q = 1000
real , parameter :: t1 = 3.12 , t2 = 0.29 , t3 = -0.0103
complex , parameter :: i = (0, 1) , t0 = (0,0)
real , parameter :: PI = acos(-1.0) , a0 = 1.42e-10
real :: b1(2), b2(2) , a1(2) , a2(2) , m1 , m2
real , allocatable :: k(:,:,:)
complex :: f1 , f2
integer :: x , y
complex :: f1_kx, f1_ky, f2_kx, f2_ky
allocate(k(2,q-1,q-1))
b1 = [ 2*PI/a0*sqrt(3.0) , 2*PI/a0 ]
b2 = [ 2*PI/a0*sqrt(3.0) , -2*PI/a0 ]
a1 = [ a0*sqrt(3.0)/2 , a0/2 ]
a2 = [ a0*sqrt(3.0)/2 , -a0/2 ]
Forall(x=1:size(k,2), y=1:size(k,3))
k(:,x,y) = (b1*x+b2*y)/q
End Forall
! print*,k(:,1,2)
m1 = dot_product(a1 , k(:,1,2))
m2 = dot_product(a2 , k(:,1,2))
f1 = 1+exp(i*m1)+exp(i*m2)
f2 = 1+exp(-i*m1)+exp(-i*m2)
call diff(i,a0,k(1,1,2),k(2,1,2))
print *, f1_kx,f1_ky, f2_kx, f2_ky
contains
subroutine diff(i,a,x,y)
implicit none
real,intent(in) :: a, x, y
complex :: i, f1_kx, f1_ky, f2_kx, f2_ky
f1_kx = (sqrt(3.0)/2)*a*i*exp(a*i*(sqrt(3.0)*x/2+y/2))+(sqrt(3.0)/2)*a*i*exp(a*i*(sqrt(3.0)*x/2-y/2))
f2_kx = -(sqrt(3.0)/2)*a*i*exp(a*i*(sqrt(3.0)*x/2+y/2))-(sqrt(3.0)/2)*a*i*exp(a*i*(sqrt(3.0)*x/2-y/2))
f1_ky = (-1/2)*a*i*exp(a*i*(sqrt(3.0)*x/2-y/2))+(1/2)*a*i*exp(a*i*(sqrt(3.0)*x/2+y/2))
f2_ky = (1/2)*a*i*exp(a*i*(sqrt(3.0)*x/2-y/2))-(1/2)*a*i*exp(a*i*(sqrt(3.0)*x/2+y/2))
return
endsubroutine
结果如下:
[Fortran] 纯文本查看 复制代码 (0.00000000,0.00000000) (0.00000000,0.00000000) (0.00000000,0.00000000) (0.00000000,0.00000000)
|
|