Continuous reading in Fortran with a free format

I want to read a line in a file that includes three real numbers without moving the pointer. So I wrote: (TXT is a 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:

"error # 6568: this use of the ADVANCE, SIZE, or EOR specifier is not allowed."

So how should I write to make it right?

Thanks.

+6
source share
1 answer

You can use advance = 'no' only with explicit format. The reason is this: advance = 'no' just avoids going to the next record (note that the file pointer advances anyway immediately after the last read value); but with a directional list (format *), no one knows how many records are associated with your read statement (three numbers can be written, for example, on four lines).

+8
source

Source: https://habr.com/ru/post/971263/


All Articles