On Mon, Feb 03, 2025 at 01:34:09PM -0500, Andi McClure wrote:
> 
> open(10,file=path,access='stream',form='unformatted',action='read',iostat=file_error)

You opened the file with form='unformatted'.

> READ (iu,"()", ADVANCE='NO', POS=file_pos) ! iu is file unit

You then try to use a format statement.

> At line 88 of file src/puzzle.f90 (unit = 10, file = 'data/sample-2.18.txt')
> Fortran runtime error: Format present for UNFORMATTED data transfer

You get the obvious error.

>    88 |     read(10, advance='no', pos=1)
>       |                     1
> Error: the ADVANCE= specifier at (1) must appear with an explicit format
> expression

(snip)

> > C1223 (R1213) An ADVANCE= specifier shall appear only in a
> > formatted sequential or stream data transfer statement with
> > explicit format specification (13.2) whose io-control-spec-list
> > does not contain an internal-file-variable as the io-unit.

I believe that you are misreading C1223.  The file is 
opened with form='unformatted'.  C1223 should be read as

C1223 An ADVANCE= specifier shall appear only in a 
formatted RED or BLUE data transfer statement ...

with RED and BLUE an obvious substitution for clarify the parsing.

Of course, I could be wrong.

PS: You're looking for the INQUIRE statement.

integer fd, n
character(len=:), allocatable :: string
inquire(file=..., size=n)
allocate(character(len=n) :: string)
open(fd,file=..., access='stream',status='old')
read(fd) string
close(fd)

-- 
Steve

Reply via email to