From patchwork Tue Sep 3 12:04:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 272208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id ED1032C008C for ; Tue, 3 Sep 2013 22:04:48 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=ok5QR5RLfn99zyn6Z n6YSO8DPpW111N03+3yXyRu+IdFXIKyMxMnuEsSsCl5vi+77nnfJl5MaZU0KsFQL GJ5fk0olqHJT+B1AuPPo2yqdM+2svUjwC37d+PPlqIvU4HxtDN26oZuRFlYE0o3X HMXgefIu/x7EDbRoetzoypq8t4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=GbGGBl3DyGFS7EDHqXxk30B Z/Ag=; b=GS2zHluCOXHGpyjwOhLpP56M7L4RXgBGKjF+KhOYqmsrYE+XTMDgk9f XbwcHLEpeMaF03DW4V1+GQdhxBzLWd0iOGcp650g047j63irbf43I5UijoPhegt0 vFOF+RFNJA/YjZ98okoROMKS48ClOj4QXzkbNJh8n68qxRoIQHAo= Received: (qmail 26467 invoked by alias); 3 Sep 2013 12:04:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 26449 invoked by uid 89); 3 Sep 2013 12:04:35 -0000 Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 03 Sep 2013 12:04:35 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 151231222D; Tue, 3 Sep 2013 14:04:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id F3D9E11DEC; Tue, 3 Sep 2013 14:04:28 +0200 (CEST) Received: from [78.35.130.191] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.0.0) (envelope-from ) id 5225d04c-05d7-7f0000012729-7f000001ded6-1 for ; Tue, 03 Sep 2013 14:04:28 +0200 Received: from [192.168.0.104] (xdsl-78-35-130-191.netcologne.de [78.35.130.191]) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Tue, 3 Sep 2013 14:04:25 +0200 (CEST) Message-ID: <5225D048.8030902@netcologne.de> Date: Tue, 03 Sep 2013 14:04:24 +0200 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Tobias Burnus CC: Janne Blomqvist , "fortran@gcc.gnu.org" , gcc-patches Subject: Re: [patch, fortran, docs] Unformatted sequential and special files References: <5220D3E4.2010905@netcologne.de> <5223711B.1090000@netcologne.de> <5224EAED.2090000@net-b.de> In-Reply-To: <5224EAED.2090000@net-b.de> Hello world, here is a rewrite, which I hope make things more clear. Unformatted sequential files are now made up of subrecords, where a logical record may only have one. Regarding block devices: I don't know anybody who ever used them from gfortran, so I tried to be as vague as possible. Any more suggestions? OK for trunk otherwise? Thomas Index: gfortran.texi =================================================================== --- gfortran.texi (Revision 201996) +++ gfortran.texi (Arbeitskopie) @@ -1121,6 +1121,8 @@ * Internal representation of LOGICAL variables:: * Thread-safety of the runtime library:: * Data consistency and durability:: +* Unformatted sequential file format:: +* I/O with special files:: @end menu @@ -1291,7 +1293,109 @@ releasing @code{fcntl} file locks, if the server supports them, will also force cache validation and flushing dirty data and metadata. +@node Unformatted sequential file format +@section Unformatted sequential file format +@cindex unformatted sequential +@cindex sequential, unformatted +@cindex record marker +@cindex subrecord +Unformatted sequential files are stored as logical records using +record markers. Each logical record consists of one of more subrecords. + +Each subrecord 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 (which exists for backwards +compability reasons only) is in effect. + +The maximum number of bytes of user data in a subrecord is 2147483639 +(2 GiB - 9) for a four-byte record marker. If a logical record +contains more data, the data is distributed among several subrecords. + +The absolute of the number stored in the record markers is the number +of bytes of user data in the corresponding subrecord. If the leading +record marker of a subrecord contains a negative number, another +subrecord follows the current one. If the trailing record marker +contains a negative number, then there is a preceding subrecord. + +In the most simple case, with only one subrecord per logical record, +both record markers contain the number of bytes of user data in the +record, + +The format for unformatted sequential data can be duplicated using +unformatted stream, as shown in the example program for a single +subrecord only: + +@smallexample +program main + use iso_fortran_env, only: int32 + implicit none + integer(int32) :: i + real, dimension(10) :: a, b + call random_number(a) + open (10,file='test.dat',form='unformatted',access='stream') + inquire (iolength=i) a + write (10) i, a, i + close (10) + open (10,file='test.dat',form='unformatted') + read (10) b + if (all (a == b)) print *,'success!' +end program main +@end smallexample + +@node I/O with special files +@section I/O with special files +@cindex special files +@cindex character devices +@cindex devices, character +@cindex block devices +@cindex devices, block +@cindex sockets +@cindex special files, character +@cindex BACKSPACE +@cindex REWIND +@cindex ENDFILE +@cindex pipes +@cindex FIFO +@cindex terminal devices +@cindex unformatted sequential +@cindex sequential, unformatted +@cindex unformatted stream +@cindex stream, unformatted +@cindex formatted stream +@cindex stream, formatted +@cindex direct access + +Special character files such as pipes, FIFOs, sockets or terminal +devices are supported only for the following types of file access: + +@itemize + +@item Formatted sequential + +@item Formatted stream + +@item Unformatted stream + +@end itemize + +For special character files, the @code{POS=} specifier for stream I/O +can only be used in @code{INQUIRE} statements. + +@code{BACKSPACE}, @code{REWIND} and @code{ENDFILE} are not supported +for character special files. + +Unformatted sequential and direct file access are @emph{not} supported +for character special files. If necessary, unformatted sequential +access can be simulated using unformatted stream, see @ref{Unformatted +sequential file format}. + +Block devices have not been tested. It is likely that only +unformatted stream and direct access will work for those. Some +restrictions specific to the operating system regarding sizes and +alignment of data may apply. + @c --------------------------------------------------------------------- @c Extensions @c ---------------------------------------------------------------------