OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / fortran / gfortran.texi
index f847df3..b1790c6 100644 (file)
@@ -1,7 +1,7 @@
 \input texinfo  @c -*-texinfo-*-
 @c %**start of header
 @setfilename gfortran.info
-@set copyrights-gfortran 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+@set copyrights-gfortran 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
 
 @include gcc-common.texi
 
@@ -222,7 +222,7 @@ compiler.
 The GNU Fortran compiler front end was
 designed initially as a free replacement for,
 or alternative to, the unix @command{f95} command;
-@command{gfortran} is the command you'll use to invoke the compiler.
+@command{gfortran} is the command you will use to invoke the compiler.
 
 @menu
 * About GNU Fortran::    What you should know about the GNU Fortran compiler.
@@ -261,7 +261,7 @@ place.  The result after compilation of a program is
 @dfn{machine code},
 code designed to be efficiently translated and processed
 by a machine such as your computer.
-Humans usually aren't as good writing machine code
+Humans usually are not as good writing machine code
 as they are at writing Fortran (or C++, Ada, or Java),
 because it is easy to make tiny mistakes writing machine code.
 
@@ -580,8 +580,8 @@ Malformed environment variables are silently ignored.
 * GFORTRAN_STDOUT_UNIT:: Unit number for standard output
 * GFORTRAN_STDERR_UNIT:: Unit number for standard error
 * GFORTRAN_TMPDIR:: Directory for scratch files
-* GFORTRAN_UNBUFFERED_ALL:: Don't buffer I/O for all units.
-* GFORTRAN_UNBUFFERED_PRECONNECTED:: Don't buffer I/O for preconnected units.
+* GFORTRAN_UNBUFFERED_ALL:: Do not buffer I/O for all units.
+* GFORTRAN_UNBUFFERED_PRECONNECTED:: Do not buffer I/O for preconnected units.
 * GFORTRAN_SHOW_LOCUS::  Show location for runtime errors
 * GFORTRAN_OPTIONAL_PLUS:: Print leading + where permitted
 * GFORTRAN_DEFAULT_RECL:: Default record length for new files
@@ -620,7 +620,7 @@ GNU Fortran searches for the environment variable @env{TMP}, then @env{TEMP}.
 If these are missing, the default is @file{/tmp}.
 
 @node GFORTRAN_UNBUFFERED_ALL
-@section @env{GFORTRAN_UNBUFFERED_ALL}---Don't buffer I/O on all units
+@section @env{GFORTRAN_UNBUFFERED_ALL}---Do not buffer I/O on all units
 
 This environment variable controls whether all I/O is unbuffered.  If
 the first letter is @samp{y}, @samp{Y} or @samp{1}, all I/O is
@@ -629,7 +629,7 @@ the first letter is @samp{n}, @samp{N} or @samp{0}, I/O is buffered.
 This is the default.
 
 @node GFORTRAN_UNBUFFERED_PRECONNECTED
-@section @env{GFORTRAN_UNBUFFERED_PRECONNECTED}---Don't buffer I/O on preconnected units
+@section @env{GFORTRAN_UNBUFFERED_PRECONNECTED}---Do not buffer I/O on preconnected units
 
 The environment variable named @env{GFORTRAN_UNBUFFERED_PRECONNECTED} controls
 whether I/O on a preconnected unit (i.e.@: STDOUT or STDERR) is unbuffered.  If 
@@ -642,7 +642,7 @@ is @samp{n}, @samp{N} or @samp{0}, I/O is buffered.  This is the default.
 
 If the first letter is @samp{y}, @samp{Y} or @samp{1}, filename and
 line numbers for runtime errors are printed.  If the first letter is
-@samp{n}, @samp{N} or @samp{0}, don't print filename and line numbers
+@samp{n}, @samp{N} or @samp{0}, do not print filename and line numbers
 for runtime errors.  The default is to print the location.
 
 @node GFORTRAN_OPTIONAL_PLUS
@@ -795,8 +795,13 @@ override type-bound procedures or to have deferred binding.
 
 @item Polymorphic entities (``@code{CLASS}'') for derived types -- including
 @code{SAME_TYPE_AS}, @code{EXTENDS_TYPE_OF} and @code{SELECT TYPE}.
-Note that the support for array-valued polymorphic entities is incomplete
-and unlimited polymophism is currently not supported.
+Note that unlimited polymorphism is currently not supported.
+
+@item Generic interface names, which have the same name as derived types,
+are now supported. This allows one to write constructor functions.  Note
+that Fortran does not support static constructor functions.  For static
+variables, only default initialization or structure-constructor
+initialization are available.
 
 @item The @code{ASSOCIATE} construct.
 
@@ -830,7 +835,7 @@ association status not the value of the pointer target.
 @item Intrinsics @code{command_argument_count}, @code{get_command},
 @code{get_command_argument}, and @code{get_environment_variable}.
 
-@item Support for unicode characters (ISO 10646) and UTF-8, including
+@item Support for Unicode characters (ISO 10646) and UTF-8, including
 the @code{SELECTED_CHAR_KIND} and @code{NEW_LINE} intrinsic functions.
 
 @item Support for binary, octal and hexadecimal (BOZ) constants in the
@@ -1090,6 +1095,7 @@ might in some way or another become visible to the programmer.
 * KIND Type Parameters::
 * Internal representation of LOGICAL variables::
 * Thread-safety of the runtime library::
+* Data consistency and durability::
 @end menu
 
 
@@ -1194,6 +1200,81 @@ Finally, for platforms not supporting thread-safe POSIX functions,
 further functionality might not be thread-safe.  For details, please
 consult the documentation for your operating system.
 
+
+@node Data consistency and durability
+@section Data consistency and durability
+@cindex consistency, durability
+
+This section contains a brief overview of data and metadata
+consistency and durability issues when doing I/O.
+
+With respect to durability, GNU Fortran makes no effort to ensure that
+data is committed to stable storage. If this is required, the GNU
+Fortran programmer can use the intrinsic @code{FNUM} to retrieve the
+low level file descriptor corresponding to an open Fortran unit. Then,
+using e.g. the @code{ISO_C_BINDING} feature, one can call the
+underlying system call to flush dirty data to stable storage, such as
+@code{fsync} on POSIX, @code{_commit} on MingW, or @code{fcntl(fd,
+F_FULLSYNC, 0)} on Mac OS X. The following example shows how to call
+fsync:
+
+@smallexample
+  ! Declare the interface for POSIX fsync function
+  interface
+    function fsync (fd) bind(c,name="fsync")
+    use iso_c_binding, only: c_int
+      integer(c_int), value :: fd
+      integer(c_int) :: fsync
+    end function fsync
+  end interface
+
+  ! Variable declaration
+  integer :: ret
+
+  ! Opening unit 10
+  open (10,file="foo")
+
+  ! ...
+  ! Perform I/O on unit 10
+  ! ...
+
+  ! Flush and sync
+  flush(10)
+  ret = fsync(fnum(10))
+
+  ! Handle possible error
+  if (ret /= 0) stop "Error calling FSYNC"
+@end smallexample
+
+With respect to consistency, for regular files GNU Fortran uses
+buffered I/O in order to improve performance. This buffer is flushed
+automatically when full and in some other situations, e.g. when
+closing a unit. It can also be explicitly flushed with the
+@code{FLUSH} statement. Also, the buffering can be turned off with the
+@code{GFORTRAN_UNBUFFERED_ALL} and
+@code{GFORTRAN_UNBUFFERED_PRECONNECTED} environment variables. Special
+files, such as terminals and pipes, are always unbuffered. Sometimes,
+however, further things may need to be done in order to allow other
+processes to see data that GNU Fortran has written, as follows.
+
+The Windows platform supports a relaxed metadata consistency model,
+where file metadata is written to the directory lazily. This means
+that, for instance, the @code{dir} command can show a stale size for a
+file. One can force a directory metadata update by closing the unit,
+or by calling @code{_commit} on the file descriptor. Note, though,
+that @code{_commit} will force all dirty data to stable storage, which
+is often a very slow operation.
+
+The Network File System (NFS) implements a relaxed consistency model
+called open-to-close consistency. Closing a file forces dirty data and
+metadata to be flushed to the server, and opening a file forces the
+client to contact the server in order to revalidate cached
+data. @code{fsync} will also force a flush of dirty data and metadata
+to the server. Similar to @code{open} and @code{close}, acquiring and
+releasing @code{fcntl} file locks, if the server supports them, will
+also force cache validation and flushing dirty data and metadata.
+
+
 @c ---------------------------------------------------------------------
 @c Extensions
 @c ---------------------------------------------------------------------
@@ -1440,7 +1521,7 @@ of the @code{READ} statement, and the output item lists of the
 
 GNU Fortran accepts real literal constants with an exponent-letter
 of @code{Q}, for example, @code{1.23Q45}.  The constant is interpreted
-as a @code{REAL(16)} entity on targets that suppports this type.  If
+as a @code{REAL(16)} entity on targets that support this type.  If
 the target does not support @code{REAL(16)} but has a @code{REAL(10)}
 type, then the real-literal-constant will be interpreted as a
 @code{REAL(10)} entity.  In the absence of @code{REAL(16)} and
@@ -1953,7 +2034,7 @@ store_catalog(7)%id = 7831
 store_catalog(7)%description = "milk bottle"
 store_catalog(7)%price = 1.2
 
-! Assignments of a whole variable don't change
+! Assignments of a whole variable do not change
 store_catalog(12) = pear
 print *, store_catalog(12)
 @end example
@@ -1974,7 +2055,7 @@ print *, store_catalog(12)
 @cindex @code{ENCODE}
 @cindex @code{DECODE}
 
-GNU Fortran doesn't support the @code{ENCODE} and @code{DECODE}
+GNU Fortran does not support the @code{ENCODE} and @code{DECODE}
 statements.  These statements are best replaced by @code{READ} and
 @code{WRITE} statements involving internal files (@code{CHARACTER}
 variables and arrays), which have been part of the Fortran standard since
@@ -2334,10 +2415,10 @@ Procedure pointers are handled analogously to pointers; the C type is
 @code{TYPE(C_FUNPTR)} and the intrinsic conversion procedures are
 @code{C_F_PROCPOINTER} and @code{C_FUNLOC}.
 
-Let's consider two examples of actually passing a procedure pointer from
+Let us consider two examples of actually passing a procedure pointer from
 C to Fortran and vice versa.  Note that these examples are also very
-similar to passing ordinary pointers between both languages.
-First, consider this code in C:
+similar to passing ordinary pointers between both languages. First,
+consider this code in C:
 
 @smallexample
 /* Procedure implemented in Fortran.  */
@@ -2827,7 +2908,7 @@ some are completely orthogonal to the rest of what is
 happening on GNU Fortran,
 but others are ``mainstream'' projects in need of enthusiastic hackers.
 All of these projects are important!
-We'll eventually get around to the things here,
+We will eventually get around to the things here,
 but they are also things doable by someone who is willing and able.
 
 @menu