向着光亮 发表于 2018-1-5 15:34
并不是这个问题,请您仔细看问题,OPEN和close并没有直接绝对关系
少年,有open无close这样的陋习,早晚会栽跟头!
Python有with关键字,光open就行,可惜fortran没有open的说明文档
https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnaf/index.html
If you open a unit that is already open without specifying a file name (or with the previous file name), FORTRAN thinks you are reopening the file to change parameters. The file position is not changed. The only parameters you are allowed to change are BLANK (NULL or ZERO) and FORM (FORMATTED or PRINT). To change any other parameters, you must close, then reopen the file.怎么能说没有关系呢?
pasuka 发表于 2018-1-7 15:00
少年,有open无close这样的陋习,早晚会栽跟头!
Python有with关键字,光open就行,可惜fortran没有open的 ...
关键我加上close也没有用,还是从rean那里直接就end of file 了,这是怎么回事 pasuka 发表于 2018-1-7 15:00
少年,有open无close这样的陋习,早晚会栽跟头!
Python有with关键字,光open就行,可惜fortran没有open的 ...
而且我打开的是有文件名的文件,只是读取数据出错了 向着光亮 发表于 2018-1-7 19:57
而且我打开的是有文件名的文件,只是读取数据出错了
之前就有人指出了,数据量不够
截图一行只有12个数据,数据a有13数据
http://tpcg.io/1VGH45
program hello
implicit none
character(len=255):: src
real(kind=4):: a(13)
a=0.0E0
src = "20.332 12.1 0.063 429.0 "
!! Not enough data
!read(src, *)a
!! 4 float number in src
read(src, *)a(1:4)
write(*, *)"a = ", a
end program Hello
出错不给错误提示,都是耍流氓。 pasuka 发表于 2018-1-8 10:27
之前就有人指出了,数据量不够
截图一行只有12个数据,数据a有13数据
http://tpcg.io/1VGH45
已解决,thanks
页:
1
[2]