Re: recl on g95 and gfortran



Arjen Markus wrote:
beliavsky@xxxxxxx schreef:

For the following program compiled and run on Windows XP

program xrecl

For both compilers, the first line in file xrecl.dat contains a space
followed by "24" (no quotes in file), followed by a newline.

Are both compilers conforming to the standard?

If I read this program correctly, then you are using RECL= on
a file that is not accessed as a direct-access file. I thought
that was only allowed for direct-access?

But if it is allowed, then there could be another explanation:
The unit of RECL is compiler (processor-) dependent. It could
be that g95 uses a single byte as the unit and gfortran uses
a word (4 bytes usually) as the unit. In the latter case, the
record would consist of 4 characters and that is within
the limits of the file you are reading.

Thanks for your reply.

Richard Maine wrote in a 2002 comp.lang.fortran thread
"OPEN(...,RECL=nnn,...) means DIRECT ACCESS, implicitly ?", that in
Fortran 77 it was "illegal to specify recl without also specifying
access="direct".'" but that

'In f90, you can use recl with sequential files, and it means that the
file must support
records at least that long. Note, while we are on the subject, that
specifying recl for a sequential file does *NOT* guarantee that you
won't write records longer than that (for example, it does not
necessarily have any effect on list-directed and namelist I/O, though
it is allowed to). It just means that the file must support records
at least that long. The exact wording of the standard says that
the file is created "with a set of allowed record lengths that
includes the specified value".'

This is consistent with what the Fortran 95 handbook says. So I think
recl is allowed on sequential files in F95.

.



Relevant Pages

  • Re: recl on g95 and gfortran
    ... For both compilers, the first line in file xrecl.dat contains a space ... a file that is not accessed as a direct-access file. ... The unit of RECL is compiler dependent. ...
    (comp.lang.fortran)
  • Re: recl on g95 and gfortran
    ... recl is allowed on sequential files in F95. ... It definitely does not specify that the records must ... many current compilers use 4-byte record length ...
    (comp.lang.fortran)
  • Re: Problem reading a binary file in fortran
    ... know which spellings all those compilers accept; ... You talked about values for recl, but I don't see them in the code. ... One thing that I didn't mention about the direct access record length. ... Or is there a type confusion here? ...
    (comp.lang.fortran)
  • Re: Input/Output Error 154: Wrong length record
    ... the OPEN statement is probably very relevant here. ... is that the recl in your OPEN statement needs to be multiplied by 4. ... The majority of current compilers use units ... Thus to specify the same ...
    (comp.lang.fortran)