From patchwork Fri Aug 30 17:18:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 271383 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 5D7932C008E for ; Sat, 31 Aug 2013 03:18:42 +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:subject:content-type; q= dns; s=default; b=gTFprfyTeBxFc4ndGNwAptcFtWDhZJIe1wKUBKSvyYXeix oQYmoW8gdmotXXCKI9QBOzolCcSPVnMTpB9BzT/fMcSUOCuwEdvSJBS0Fsuw7ZUs LDpJAvwnKdT3rHG8/J9uDLxLTrO6ELfD3Zsy/aqTNh0o8asbMDjsA+5869qXE= 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:subject:content-type; s= default; bh=gcDU9etsJByUbBfipbJTdpG6oy8=; b=XK/Zl7Puqx2Ih5ovT419 98tHA4gWatDibuzsAWOR6TNC3E6xBtf6mKQcc5tVkYeiHCGUmsgTqfxNV8l81dUy NA7EByGIsCYgSsoh4hXV0PSe06KSmST/+T2BV3FiBDkYXVTpPxWuxgSOAbTBj+Fq X8BsnWy0Drvfs9CNgEbksEU= Received: (qmail 9006 invoked by alias); 30 Aug 2013 17:18:36 -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 8992 invoked by uid 89); 30 Aug 2013 17:18: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; Fri, 30 Aug 2013 17:18:35 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 1D25512410; Fri, 30 Aug 2013 19:18:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id 0DA6911DEC; Fri, 30 Aug 2013 19:18:31 +0200 (CEST) Received: from [78.35.140.85] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.0.0) (envelope-from ) id 5220d3e7-0b65-7f0000012729-7f0000019a0a-1 for ; Fri, 30 Aug 2013 19:18:31 +0200 Received: from [192.168.0.104] (xdsl-78-35-140-85.netcologne.de [78.35.140.85]) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA; Fri, 30 Aug 2013 19:18:29 +0200 (CEST) Message-ID: <5220D3E4.2010905@netcologne.de> Date: Fri, 30 Aug 2013 19:18:28 +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: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, fortran, docs] Unformatted sequential and special files Hello world, the attached patch documents the format for unformatted sequential files and what is, and is not, supported with special files. Tested with "make dvi" and "make info". OK for trunk? Thomas 2013-08-30 Thomas Koenig PR fortran/30162 * gfortran.texi: Document unformatted sequential file format and I/O with special files. 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,75 @@ 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 files +@cindex record marker +@cindex subrecord +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. + +The maximum number of bytes of user data in a record is 2147483639 for +a 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: + +@smallexample +program main + implicit none + integer :: 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 pipes +@cindex FIFO +@cindex terminal devices +@cindex BACKSPACE + +Special files such as pipes, FIFOs 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 + +Unformatted sequential file access is not supported for +special files. If necessary, it can be simulated using +unformatted stream, see @ref{Unformatted sequential file format}. + +@code{BACKSPACE} is not supported for special files. + @c --------------------------------------------------------------------- @c Extensions @c ---------------------------------------------------------------------