Message from discussion record length in an unformatted (binary) file
Received: by 10.66.88.231 with SMTP id bj7mr4316371pab.45.1349721116008;
Mon, 08 Oct 2012 11:31:56 -0700 (PDT)
From: nos...@see.signature (Richard Maine)
Subject: Re: record length in an unformatted (binary) file
Date: Mon, 1 Oct 2012 19:23:00 -0700
X-Trace: individual.net Ip25x4DUQmqxwGusYagnoQ4zeuMYtMeTRY0//SdCS8Nq3sDElzhVmjtIvN/Tt6RVL7
User-Agent: MacSOUP/2.8.3 (Mac OS X version 10.6.8 (x86))
marcio.pmz <mtnobrega....@gmail.com> wrote:
> Is there somehow to know the lenght of records in an unformatted (binary)
Not anything portable or defined by the standard.
I might also note that "binary" is not a term defined by the Fortran
standard, and it is not well-defined what it means. The literal meaning
("base 2") is almost never what anyone means when talking about computer
files. Although different people use the term with different meanings
(which is why I avoid it), perhaps the most common meaning is to
describe an unformatted file that has no record structure. That takes a
pretty long stretch to connect to the word "binary", but still that's
the most common usage. If that happens to be what you mean, then such a
file doesn't *HAVE* an inherent record length to be known.
With most implementations, you can open such a file with any record
length as long as you are using direct access. "Records" are arbitrarily
defined to be chunks of data of whatever size you specify in the open,
but these records have no physical embodiment in the file. You usually
can't open such a file for sequential acess at all. Exceptions exist,
but that's the way most implementations work.
I might note that unformatted stream access, introduced in f2003, and
supported by most current compilers, is a more natural fit to such
> Would 'inquire' statement be an option?
> Of course I understand that with the record length I may use direct access
> at open statement. On the other hand, if I wish to use sequential
> access, how would I use the record length info?
For sequential access, the recl specifier in the open statement is not
actually the record length. It is the maximum record length. There is
usually little reason to specify it for sequential access. In the past,
some implementations have had fairly small default values for the
maximum record length. In that case, specifying a large value for recl
might tell the implementation to accomodate suffcient buffers or other
resources required to support that record length. However, to me
knowledge, most current implementations default to having the recl limit
as large as the implementation can support, which is often something
like 2GB (or sometimes more). If you are working with records long
enough that this is an issue, there are probably lots of other matters
that also need careful attention.
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain