Non-advancing read in Fortran with free format

2019-04-24 08:04发布

I want to read a line in a file, which includes three real numbers, without advancing the pointer. So I wrote: (TXT is the variable representing my file which has a value of 80)

read(TXT, *, ADVANCE='NO') (numbers(i),i=1,3)

However, I got an error message saying:

"error #6568: This use of the ADVANCE, SIZE, or EOR specifier is invalid."

So how should I write it to make it correct?

Thanks.

1条回答
一纸荒年 Trace。
2楼-- · 2019-04-24 09:00

You can use advance='no' only with an explicit format. The reason is the following : advance='no' just avoids to go to the next record (notice that the file pointer advances anyway, just after the last read value); but with a directed list (format *), one doesn't know how many record are involved by your read statement (the three numbers may be written on four lines for instance).

查看更多
登录 后发表回答