From 7d613e7c1b3585f36b98b0913520aeb131d97d11 Mon Sep 17 00:00:00 2001 From: burnus Date: Tue, 8 Dec 2009 08:52:28 +0000 Subject: [PATCH] 2009-12-08 Tobias Burnus PR fortran/40961 PR fortran/40377 * gfortran.texi (Non-Fortran Main Program): Add _gfortran_set_fpe documentation. (Interoperability with C): Mention array storage order. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155083 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 14 +++++++++++--- gcc/fortran/gfortran.texi | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 49f6b8f..24db229 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,8 +1,16 @@ +2009-12-08 Tobias Burnus + + PR fortran/40961 + PR fortran/40377 + * gfortran.texi (Non-Fortran Main Program): Add + _gfortran_set_fpe documentation. + (Interoperability with C): Mention array storage order. + 2009-12-07 Daniel Franke - PR fortran/41940 - * match.c (gfc_match_allocate): Improved error message for - allocatable scalars that are allocated with a shape. + PR fortran/41940 + * match.c (gfc_match_allocate): Improved error message for + allocatable scalars that are allocated with a shape. 2009-12-07 Kaveh R. Ghazi diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 1430c8a..e9adb3d 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -1911,6 +1911,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 orded 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 @@ -2191,6 +2197,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 @@ -2362,7 +2369,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}: @@ -2387,6 +2394,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 -- 2.7.4