有格式读入文件中的数据出错
我准备通过文件读入u0y和n0这个量,编译后发现n0可以正常读入,但u0y报错。然而这两个变量从文件中读入的代码几乎是一样的,这是为什么呢?报错信息及源代码如下:
84 | read(29,*) (u0y(i,j),i=ypml_cell+1,Nx-ypml_cell)
| 1
Error: Expecting variable in READ statement at (1)
select case(u0_use_file)
case(.True.)
open(29,file="vy.dat")
do j=pml_cell+1,Ny-pml_cell
read(29,*) (u0y(i,j),i=ypml_cell+1,Nx-ypml_cell)
end do
close(29)
case(.False.)
u0x=u0x_const
u0y=u0y_const
end select
end if
select case(n0_use_file)
case(.True.)
open(30,file="density.dat")
do j=pml_cell+1,Ny-pml_cell
read(30,*) (n0(i,j),i=ypml_cell+1,Nx-ypml_cell)
end do
close(30)
case(.False.)
n0=n0_constant
end select
u0y 是否定义了?
另外
select case( .true. ) case( .false. )
这种写法很少见,也很奇怪。直接
if( n0_use_file ) then
else
end if
不是挺好嘛 kyra 发表于 2024-5-23 12:55
u0y 是否定义了?
另外
谢谢!找到问题了,u0y定义的那行被注释掉了:'(万万没想到是这个问题 强烈建议你写上 implicit none 并定义所有的变量。
页:
[1]