This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: OPEN statement binary equivalence with F2003
- From: Tobias Burnus <burnus at net-b dot de>
- To: Mike Toews <mwtoews at gmail dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 29 Apr 2013 15:03:31 +0200
- Subject: Re: OPEN statement binary equivalence with F2003
- References: <CAM2FmMp9cnN9NXv5WOfrAuKd3hBBvqGYACX3kAZgDXkCm7J2Kg at mail dot gmail dot com>
Mike Toews wrote:
First, I cannot seem to find any documentation on the OPEN statement
with the current version of the onlinedocs. Instead, I only see useful
fragments, e.g. [1]. Is the OPEN statement documented for gfortran
anywhere?
The online documentation tries to document the supported command line
arguments plus the most important compiler specific features (such as
extensions). The latter also includes the documentation of all intrinsic
procedures - both the compiler/vendor extensions and the ones of the
Fortran standard.
However, OPEN is a statement and currently statements are not
documented; this might change in the future but it is a lot of work. You
are essentially asking for a full language reference. But the best
definite source of the Fortran language is the Fortran standard. See
http://gcc.gnu.org/wiki/GFortranStandards - or in a more readable form,
in several Fortran text books.
The only exception are compiler-specific extensions, which are hopefully
mostly documented in gfortran's documentation.
A topic that needs some documentation is the vendor-dependant and
non-Standard FORM='BINARY',
Well, I do hope that those compilers have documented it. Admittedly, one
could also add it to "Extensions not implemented in GNU Fortran",
http://gcc.gnu.org/onlinedocs/gfortran/Extensions-not-implemented-in-GNU-Fortran.html
which I see in source code like MODFLOW,[2] which is developed by the USGS with Intel compilers with default FORM='BINARY' (although this is customisable with openspec.ini). Up until now, I had assumed that gfortran was unable to read/write a similar data structure to the programs produced by other compilers that supported FORM='BINARY', and I was silently awaiting this support with a future release.
I thought the only supported binary-like mode was OPEN(...,ACCESS='SEQUENTIAL',FORM='UNFORMATTED'),
First, sometimes it helps to ask - because then someone could have told
you to try "stream".
Secondly, besides sequential and Fortran 2003's stream there is also
"direct". "stream" mimics C's I/O while "sequential" writes some special
information to quickly jump forth to the next record or back to the
previous one.
Compilers added some vendor extensions to allow writing code in the C
way - and users used them because the Fortran standard only added it in
Fortran 2003. In general, vendor extensions should be avoided as they
are compiler-specific and not well defined.
On a related note, perhaps gfortran should support FORM='BINARY' by
resetting the OPEN statement parameters with the F2003 equivalent, and
possibly emitting a warning to the user.
Maybe. In any case, using vendor is discouraged and implementing new
features (and fixing bugs) cost time - and Fortran-standard features
have a higher precedence that adding vendor extensions, especially if a
Fortran-standard replacement exists.
In any case, contributions* to GCC/gfortran are welcome - especially as
the compiler is mostly developed by unpaid volunteers. (* documentation,
feature implementation, bug fixes but also bug reports.)
Tobias