[Fortran] 纯文本查看 复制代码
subroutine rhouv(f,rho,u,v,cx,cy,n,m)
real f(0:8,0:n,0:m),rho(0:n,0:m),u(0:n,0:m),v(0:n,0:m),cx(0:8),cy(0:8)
integer :: i, j, k
real :: ssum, usum, vsum
do j=0,m
do i=0,n
ssum = 0.0
usum = 0.0
vsum = 0.0
do k=0,8
ssum = ssum + f(k,i,j)
usum = usum + f(k,i,j)*cx(k)
vsum = vsum + f(k,i,j)*cy(k)
!print*,vsum,usum ! 可以输出数据
end do
!print*,ssum,usum,vsum ! 输出数据全部为零
rho(i,j) = ssum
if (ssum > 0.0) then
u(i,j) = usum / ssum
v(i,j) = vsum / ssum
else
u(i,j) = 0.0
v(i,j) = 0.0
end if
!print*,u(i,j),v(i,j)
end do
end do