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.
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
@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
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 ---------------------------------------------------------------------
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
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.
* _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
@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}:
@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