我正在为我的硕士论文编写代码,它是用于两个平行板之间的仿真。我想说明一下,当Y方向在j个元素中离散时,j = 1和j = cn(最后一个元素)就是墙。
类似的东西:
wall(i,j)=.false
wall(i,1)=.true.
wall(i,cn)=.true.
之所以这样做,是因为在代码中我会有一些:
if wall(i,j) then
do j=...
do i=...
与do嵌套。我知道if必须具有逻辑表达式。
这里是替代代码的尝试:
program wall
implicit none
integer :: i, j
real*8 cn,rn
real, dimension(:,:),allocatable :: f
logical::wall
write(*,*) 'How many elements in X direction?'
read(*,*) cn
write(*,*) 'How many elements in Y direction?'
read (*,*) rn
allocate(f(cn,rn))
do j=1,rn
do i=1,cn
wall(i,j)=.false.
wall(i,1)=.true.
wall(i,rn)=.true.
enddo
enddo
deallocate(f)
end program wall
以下是错误消息:
logical::wall
1
错误:(1)处的符号“ wall”不能具有类型
wall(i,j)=.false.
1
错误:(1)处的'wall'不是变量
wall(i,1)=.true.
1
错误:(1)处的'wall'不是变量
wall(i,rn)=.true.
1
错误:(1)处的'wall'不是变量