QQ截图20180104215011.png (103.91 KB, 下载次数: 521)
kyra 发表于 2018-1-5 07:56
read(7,*) a(i,:)
1.png (18.95 KB, 下载次数: 445)
2.png (4.01 KB, 下载次数: 446)
kyra 发表于 2018-1-5 09:30
照抄你都不会吗?
read(7,*) a(i,:)
kyra 发表于 2018-1-5 09:30
照抄你都不会吗?
read(7,*) a(i,:)
pasuka 发表于 2018-1-5 14:34
有open无close,自然会出错
向着光亮 发表于 2018-1-5 15:34
并不是这个问题,请您仔细看问题,OPEN和close并没有直接绝对关系
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的 ...
pasuka 发表于 2018-1-7 15:00
少年,有open无close这样的陋习,早晚会栽跟头!
Python有with关键字,光open就行,可惜fortran没有open的 ...
向着光亮 发表于 2018-1-7 19:57
而且我打开的是有文件名的文件,只是读取数据出错了
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
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |