QQ图片20211125211345.png (59.59 KB, 下载次数: 195)
necrohan 发表于 2021-11-26 08:22
k声明为变量没有声明为二维数组,不能当数组用
(x/n)b1里,b1前缺运算符
两个整数除法会自动取整,可能你要 ...
Program workfile
Implicit None
integer , parameter :: n = 1000
real , parameter :: PI = acos(-1.0) , a = 1.42e-10
real :: b1(2), b2(2)
real , allocatable :: k(:,:,:)
integer :: x , y
allocate(k(2,n-1,n-1))
b1 = [ 2*PI/a*sqrt(3.0) , 2*PI/a ]
b2 = [ 2*PI/a*sqrt(3.0) ,-2*PI/a ]
Forall(x=1:size(k,2) , y=1:size(k,3))
k(:,x,y) = (b1*x+b2*y)/n
End Forall
End Program workfile
胡文刚 发表于 2021-11-26 22:28
这样是你想要的吗?
[mw_shl_code=fortran,true]Program workfile
胡文刚 发表于 2021-11-26 22:28
这样是你想要的吗?
[mw_shl_code=fortran,true]Program workfile
vvt 发表于 2021-12-9 12:24
1. 是的,三个维度的上限。(下限默认为1)
2. size(k,2) 是 k 数组第二个维度的大小。(上限-下线+1)
同 ...
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |