OSDN Git Service

gcc/fortran/:
[pf3gnuchains/gcc-fork.git] / gcc / fortran / gfortran.texi
index f0b1c67..989a926 100644 (file)
@@ -1,7 +1,7 @@
 \input texinfo  @c -*-texinfo-*-
 @c %**start of header
 @setfilename gfortran.info
-@set copyrights-gfortran 1999-2008
+@set copyrights-gfortran 1999-2010
 
 @include gcc-common.texi
 
@@ -181,7 +181,7 @@ Part I: Invoking GNU Fortran
 
 Part II: Language Reference
 * Fortran 2003 and 2008 status::  Fortran 2003 and 2008 features supported by GNU Fortran.
-* Compiler Characteristics::      KIND type parameters supported.
+* Compiler Characteristics::      User-visible implementation details.
 * Mixed-Language Programming::    Interoperability with C
 * Extensions::           Language extensions implemented by GNU Fortran.
 * Intrinsic Procedures:: Intrinsic procedures supported by GNU Fortran.
@@ -635,8 +635,8 @@ error is used. If the first letter is @samp{n}, @samp{N} or
 
 This environment variable controls where scratch files are
 created.  If this environment variable is missing,
-GNU Fortran searches for the environment variable @env{TMP}.  If
-this is also missing, the default is @file{/tmp}.
+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
@@ -808,7 +808,8 @@ was used.
 @section Fortran 2003 status
 
 GNU Fortran supports several Fortran 2003 features; an incomplete
-list can be found below.
+list can be found below.  See also the
+@uref{http://gcc.gnu.org/wiki/Fortran2003, wiki page} about Fortran 2003.
 
 @itemize
 @item 
@@ -820,7 +821,8 @@ Intrinsics @code{command_argument_count}, @code{get_command},
 @cindex array, constructors
 @cindex @code{[...]}
 Array constructors using square brackets. That is, @code{[...]} rather
-than @code{(/.../)}.
+than @code{(/.../)}.  Type-specification for array constructors like
+@code{(/ some-type :: ... /)}.
 
 @item
 @cindex @code{FLUSH} statement
@@ -858,6 +860,14 @@ TR 15581:
 @end itemize
 
 @item
+@cindex @code{ALLOCATE}
+The @code{ERRMSG=} tag is now supported in @code{ALLOCATE} and
+@code{DEALLOCATE} statements.  The @code{SOURCE=} tag is supported
+in an @code{ALLOCATE} statement.  An @emph{intrinsic-type-spec}
+can be used as the @emph{type-spec} in an @code{ALLOCATE} statement;
+while the use of a @emph{derived-type-name} is currently unsupported.
+
+@item
 @cindex @code{STREAM} I/O
 @cindex @code{ACCESS='STREAM'} I/O
 The @code{OPEN} statement supports the @code{ACCESS='STREAM'} specifier,
@@ -904,7 +914,23 @@ Renaming of operators in the @code{USE} statement.
 Interoperability with C (ISO C Bindings)
 
 @item
-BOZ as argument of INT, REAL, DBLE and CMPLX.
+BOZ as argument of @code{INT}, @code{REAL}, @code{DBLE} and @code{CMPLX}.
+
+@item
+@cindex type-bound procedure
+@cindex type-bound operator
+Type-bound procedures with @code{PROCEDURE} or @code{GENERIC}, and operators
+bound to a derived-type.
+
+@item
+@cindex @code{EXTENDS}
+@cindex derived-type extension
+Extension of derived-types (the @code{EXTENDS(...)} syntax).
+
+@item
+@cindex @code{ABSTRACT} type
+@cindex @code{DEFERRED} procedure binding
+@code{ABSTRACT} derived-types and declaring procedure bindings @code{DEFERRED}.
 
 @end itemize
 
@@ -916,7 +942,7 @@ The next version of the Fortran standard after Fortran 2003 is currently
 being worked on by the Working Group 5 of Sub-Committee 22 of the Joint
 Technical Committee 1 of the International Organization for
 Standardization (ISO) and the International Electrotechnical Commission
-(IEC). This group is known at @uref{http://www.nag.co.uk/sc22wg5/, WG5}.
+(IEC). This group is known as @uref{http://www.nag.co.uk/sc22wg5/, WG5}.
 The next revision of the Fortran standard is informally referred to as
 Fortran 2008, reflecting its planned release year. The GNU Fortran
 compiler has support for some of the new features in Fortran 2008. This
@@ -925,6 +951,9 @@ support is based on the latest draft, available from
 differ from the drafts, no guarantee of backward compatibility can be
 made and you should only use it for experimental purposes.
 
+The @uref{http://gcc.gnu.org/wiki/Fortran2008Status, wiki} has some information
+about the current Fortran 2008 implementation status.
+
 
 @c ---------------------------------------------------------------------
 @c Compiler Characteristics
@@ -933,14 +962,13 @@ made and you should only use it for experimental purposes.
 @node Compiler Characteristics
 @chapter Compiler Characteristics
 
-@c TODO: Formulate this introduction a little more generally once
-@c there is more here than KIND type parameters.
-
-This chapter describes certain characteristics of the GNU Fortran compiler,
-namely the KIND type parameter values supported.
+This chapter describes certain characteristics of the GNU Fortran
+compiler, that are not specified by the Fortran standard, but which
+might in some way or another become visible to the programmer.
 
 @menu
 * KIND Type Parameters::
+* Internal representation of LOGICAL variables::
 @end menu
 
 
@@ -984,6 +1012,32 @@ imaginary part are a real value of the given size).  It is recommended to use
 the @code{SELECT_*_KIND} intrinsics instead of the concrete values.
 
 
+@node Internal representation of LOGICAL variables
+@section Internal representation of LOGICAL variables
+@cindex logical, variable representation
+
+The Fortran standard does not specify how variables of @code{LOGICAL}
+type are represented, beyond requiring that @code{LOGICAL} variables
+of default kind have the same storage size as default @code{INTEGER}
+and @code{REAL} variables.  The GNU Fortran internal representation is
+as follows.
+
+A @code{LOGICAL(KIND=N)} variable is represented as an
+@code{INTEGER(KIND=N)} variable, however, with only two permissible
+values: @code{1} for @code{.TRUE.} and @code{0} for
+@code{.FALSE.}. Any other integer value results in undefined behavior.
+
+Note that for mixed-language programming using the
+@code{ISO_C_BINDING} feature, there is a @code{C_BOOL} kind that can
+be used to create @code{LOGICAL(KIND=C_BOOL)} variables which are
+interoperable with the C99 _Bool type.  The C99 _Bool type has an
+internal representation described in the C99 standard, which is
+identical to the above description, i.e. with 1 for true and 0 for
+false being the only permissible values.  Thus the internal
+representation of @code{LOGICAL} variables in GNU Fortran is identical
+to C99 _Bool, except for a possible difference in storage size
+depending on the kind.
+
 @c ---------------------------------------------------------------------
 @c Extensions
 @c ---------------------------------------------------------------------
@@ -1789,7 +1843,7 @@ c     ... Code that sets A, B and C
 with the following:
 
 @smallexample
-      INTEGER*1 LINE(80)
+      CHARACTER(LEN=80) LINE
       REAL A, B, C
 c     ... Code that sets A, B and C
       WRITE (UNIT=LINE, FMT=9000) A, B, C
@@ -1882,6 +1936,12 @@ all C features have a Fortran equivalent or vice versa. For instance,
 neither C's unsigned integers nor C's functions with variable number
 of arguments have an equivalent in Fortran.
 
+Note that array dimensions are reversely ordered in C and that arrays in
+C always start with index 0 while in Fortran they start by default with
+1. Thus, an array declaration @code{A(n,m)} in Fortran matches
+@code{A[m][n]} in C and accessing the element @code{A(i,j)} matches
+@code{A[j-1][i-1]}. The element following @code{A(i,j)} (C: @code{A[j-1][i-1]};
+assuming @math{i < n}) in memory is @code{A(i+1,j)} (C: @code{A[j-1][i]}).
 
 @node Intrinsic Types
 @subsection Intrinsic Types
@@ -1965,10 +2025,10 @@ a macro. Use the @code{IERRNO} intrinsic (GNU extension) instead.
 Subroutines and functions have to have the @code{BIND(C)} attribute to
 be compatible with C. The dummy argument declaration is relatively
 straightforward. However, one needs to be careful because C uses
-call-by-value by default while GNU Fortran uses call-by-reference.
-Furthermore, strings and pointers are handled differently. Note that
-only explicit size and assumed-size arrays are supported but not
-assumed-shape or allocatable arrays.
+call-by-value by default while Fortran behaves usually similar to
+call-by-reference. Furthermore, strings and pointers are handled
+differently. Note that only explicit size and assumed-size arrays are
+supported but not assumed-shape or allocatable arrays.
 
 To pass a variable by value, use the @code{VALUE} attribute.
 Thus the following C prototype
@@ -1980,9 +2040,10 @@ Thus the following C prototype
 matches the Fortran declaration
 
 @smallexample
-  integer(c_int) func(i,j)
-    integer, VALUE :: i
-    integer :: j
+  integer(c_int) function func(i,j)
+    use iso_c_binding, only: c_int
+    integer(c_int), VALUE :: i
+    integer(c_int) :: j
 @end smallexample
 
 Note that pointer arguments also frequently need the @code{VALUE} attribute.
@@ -2161,6 +2222,7 @@ the same declaration part as the variable or procedure pointer.
 * _gfortran_set_convert:: Set endian conversion
 * _gfortran_set_record_marker:: Set length of record markers
 * _gfortran_set_max_subrecord_length:: Set subrecord length
+* _gfortran_set_fpe:: Set when a Floating Point Exception should be raised
 @end menu
 
 Even if you are doing mixed-language programming, it is very
@@ -2277,7 +2339,7 @@ initialization using @code{_gfortran_set_args}.
 Default: enabled.
 @item @var{option}[6] @tab Enables run-time checking. Possible values
 are (bitwise or-ed): GFC_RTCHECK_BOUNDS (1), GFC_RTCHECK_ARRAY_TEMPS (2),
-GFC_RTCHECK_RECURSION (4), GFC_RTCHECK_DO (16).
+GFC_RTCHECK_RECURSION (4), GFC_RTCHECK_DO (16), GFC_RTCHECK_POINTER (32).
 Default: disabled.
 @item @var{option}[7] @tab If non zero, range checking is enabled.
 Default: enabled. See -frange-check (@pxref{Code Gen Options}).
@@ -2332,7 +2394,7 @@ int main (int argc, char *argv[])
 
 @table @asis
 @item @emph{Description}:
-@code{_gfortran_set_record_marker} set the length of record markers
+@code{_gfortran_set_record_marker} sets the length of record markers
 for unformatted files.
 
 @item @emph{Syntax}:
@@ -2357,6 +2419,44 @@ int main (int argc, char *argv[])
 @end table
 
 
+@node _gfortran_set_fpe
+@subsection @code{_gfortran_set_fpe} --- Set when a Floating Point Exception should be raised
+@fnindex _gfortran_set_fpe
+@cindex libgfortran initialization, set_fpe
+
+@table @asis
+@item @emph{Description}:
+@code{_gfortran_set_fpe} sets the IEEE exceptions for which a
+Floating Point Exception (FPE) should be raised. On most systems,
+this will result in a SIGFPE signal being sent and the program
+being interrupted.
+
+@item @emph{Syntax}:
+@code{void _gfortran_set_fpe (int val)}
+
+@item @emph{Arguments}:
+@multitable @columnfractions .15 .70
+@item @var{option}[0] @tab IEEE exceptions. Possible values are
+(bitwise or-ed) zero (0, default) no trapping,
+@code{GFC_FPE_INVALID} (1), @code{GFC_FPE_DENORMAL} (2),
+@code{GFC_FPE_ZERO} (4), @code{GFC_FPE_OVERFLOW} (8),
+@code{GFC_FPE_UNDERFLOW} (16), and @code{GFC_FPE_PRECISION} (32).
+@end multitable
+
+@item @emph{Example}:
+@smallexample
+int main (int argc, char *argv[])
+@{
+  /* Initialize libgfortran.  */
+  _gfortran_set_args (argc, argv);
+  /* FPE for invalid operations such as SQRT(-1.0).  */
+  _gfortran_set_fpe (1);
+  return 0;
+@}
+@end smallexample
+@end table
+
+
 @node _gfortran_set_max_subrecord_length
 @subsection @code{_gfortran_set_max_subrecord_length} --- Set subrecord length
 @fnindex _gfortran_set_max_subrecord_length