public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <burnus@net-b.de>
To: Thomas Koenig <tkoenig@netcologne.de>
Cc: Janne Blomqvist <blomqvist.janne@gmail.com>,
	 "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch, fortran, docs] Unformatted sequential and special files
Date: Mon, 02 Sep 2013 19:45:00 -0000	[thread overview]
Message-ID: <5224EAED.2090000@net-b.de> (raw)
In-Reply-To: <5223711B.1090000@netcologne.de>

Thomas Koenig wrote:
> +Unformatted sequential files are stored using record markers. Each
> +full record consists of a leading record marker, the data written
> +by the user program, and a trailing record marker.  The record markers
> +are four-byte integers by default, and eight-byte integers if the
> +@option{-fmax-subrecord-length=8} option is in effect. Each record
> +marker contains the number of bytes of data in the record.

I wonder whether one should discourage the use of 
-fmax-subrecord-length=8 more explicitly here - when reading until here 
one might think that there is a 2GB limit for =4.

> +The maximum number of bytes of user data in a record is 2147483639 for
> +a four-byte record marker.

Why this number? I had expected it to be exactly  2 GiB (minus 1 Byte) = 
2**31-1 = 2147483647. Your number is one byte shorter. Why?

Actually, I had also mentioned GiB as those are simpler to remember, e.g.
"The maximal user data per record is 2 gigabytes (2147483647/2147483639 
bytes) for the four-byte record marker.

> If this is exceeded, a record is split into
> +subrecords. Each subrecord also has a leading and a trailing record
> +marker. If the leading record marker contains a negative number, the
> +number of user data bytes in the subrecord equals the absolute value
> +of this number, and another subrecord follows the current one.  If the
> +trailing record marker contains a negative number, then the number of
> +bytes of user data equals the absolute value of that number, and there
> +is a preceding subrecord.
> +
> +The format for unformatted sequential data can be duplicated using
> +unformatted stream, as shown in this example program:

(which assumes records shorter than 2 GiB)

> +
> +@smallexample
> +program main
> +  implicit none
> +  integer :: i

I wonder whether one should make this more explicit by using

use iso_fortran_env, only: int32
integer(int32) :: i

> +Unformatted sequential file access is @emph{not} supported for special
> +files.  If necessary, it can be simulated using unformatted stream,
> +see @ref{Unformatted sequential file format}.
> +
> +I/O to and from block devices are also not supported.
> +
> +@code{BACKSPACE}, @code{REWIND} and @code{ENDFILE} are not supported
> +for special files.

I think I understand what you mean but  "I/O to and from block devices 
are also not supported." sounds as if it also could apply to all I/O, 
including stream I/O.

How about adding "block devices" to the list of special files in the 
intro? You could also mention sockets, which behave similarly. The 
BACKSPACE/REWIND/ENDFILE could be moved directly after the itemize in 
the same paragraph as the POS=.

And instead of "unformatted sequential", you could write "unformatted 
sequential and directed access", which reminds me that we should also 
document that file format for the sake of completeness.

Tobias

  reply	other threads:[~2013-09-02 19:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30 17:31 Thomas Koenig
2013-08-31 20:48 ` Janne Blomqvist
2013-09-01 16:54   ` Thomas Koenig
2013-09-02 19:45     ` Tobias Burnus [this message]
2013-09-03 12:04       ` Thomas Koenig
2013-09-04 10:40         ` Janne Blomqvist
2013-11-25  9:45           ` Tobias Burnus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5224EAED.2090000@net-b.de \
    --to=burnus@net-b.de \
    --cc=blomqvist.janne@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tkoenig@netcologne.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).