fortran遇到了问题,求助大神。

毕设用了fortran,本人小白一个,程序出了问题,求大神指点。
C:\Users\t\Desktop\reflectnew\reflect3.f90(20) : Error: Constants and expressions are invalid in read-only I/O lists.
read(28,*)i*dx,j*dx,p(i,j),u(i,j),temp,under,seeds(i,j)
---------------------------^
C:\Users\t\Desktop\reflectnew\reflect3.f90(20) : Error: Constants and expressions are invalid in read-only I/O lists.
read(28,*)i*dx,j*dx,p(i,j),u(i,j),temp,under,seeds(i,j)
以下为原程序
implicit real*8(a-h,o-z) parameter (nmax=3510,nmay=453)
dimension p(0:nmax+1,0:nmay+1)
dimension u(0:nmax+1,0:nmay+1)
dimension pa(0:nmax+1,0:nmay+1)
dimension ua(0:nmax+1,0:nmay+1)
dimension seeds(0:nmax+1,0:nmay+1)
dimension seedsa(0:nmax+1,0:nmay+1)

open(28,file='movefile.dat') open(29,file='movefiletw.dat')
write(29,*)'VARIABLES = "x", "y", "phi", "U", "temp","DT","Seeds"'
n_maxx=3500
n_maxy=nmay
dx=0.8d0

write(29,*)'ZONE I=',(n_maxx+1)/4+1,',J=',(n_maxy+1)/4+1 do j=0,n_maxy/3+1,4
do i=0,n_maxx+1,4
read(28,*)i*dx,j*dx,p(i,j),u(i,j),temp,under,seeds(i,j)
enddo
enddo
do j=0,n_maxy/3+1,4
do i=0,n_maxx+1,4
pa(i,j)=p(i,j)
ua(i,j)=u(i,j)
seedsa(i,j)=seeds(i,j)
write(29,66)i*dx,j*dx,pa(i,j),ua(i,j),temp,under,seedsa(i,j)
enddo
enddo
do j=n_maxy/3,n_maxy*2/3+1,4
do i=0,n_maxx+1,4
pa(i,j)=p(i,302-j)
ua(i,j)=u(i,302-j)
seedsa(i,j)=seeds(i,302-j)
write(29,66)i*dx,j*dx,pa(i,j),ua(i,j),temp,under,seedsa(i,j)
enddo
enddo
do j=n_maxy*2/3,n_maxy+1,4
do i=0,n_maxx+1,4
pa(i,j)=p(i,j-302)
ua(i,j)=u(i,j-302)
seedsa(i,j)=seeds(i,j-302)
write(29,66)i*dx,j*dx,pa(i,j),ua(i,j),temp,under,seedsa(i,j)
enddo
enddo
66 format(f9.4,1x,f9.4,1x,f7.4,1x,f7.4,1x,f8.4,1x,f10.4,1x,f7.4)
end

read(28,*)i*dx,j*dx,p(i,j),u(i,j),temp,under,seeds(i,j)

这是没有道理的。

i*dx , j*dx 是一个运算式子。你不能读取它。逻辑上就说不过去。
比如 i = 5 , dx = 6
你读取 i*dx 什么意思呢?如果数据文件里是 31。你叫程序怎么办?
i*dx = 5*6 = 30,你又从文件里读一个 31,到底是改变 i 呢?还是改变 dx 呢?

是否应该是 i , dx , j , dx 而不是 i * dx , j * dx ??这句话你想实现什么目的?数据文件里第一个和第二个数据想赋值给谁?追问

我想读 i * dx , j * dx ,这是文件的第一和第二列
movefile这个文件是以 “write(28,66)i*dx,j*dx,p(i,j),u(i,j),temp,under,seeds(i,j)”的方式存储的,如果想读取该文件,该怎么设置呢?

追答

你不可能读取 i * dx , j * dx
逻辑上就说不通。文件里只有一个数,你怎么能让 i * dx 等于这个数呢?你让编译器怎么处理 i ,怎么处理 dx ?

读取出来的数据,只能存放在某个变量里,不能是一个表达式。

假如数据是 31,你让 31 = i * dx 这怎么操作呢?
你可以让 31 = i,也可以让 31 = dx,但不能让 31 = i * dx

再举例说,你可以让程序把 5*6 的结果写到黑板上,但不能让程序去黑板上读“ 5*6 ”

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网