summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-03 20:32:23 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-03 20:32:23 +0000
commit0c7efac1ed999e50f423f2e3e401b9d9cbf2df29 (patch)
tree7f5ea447e16137fa61a0a68979fd04ffdc8ec384 /gcc
parentcd819d2fba06ad666e2e6b80340bafcb6bc38a1b (diff)
downloadgcc-0c7efac1ed999e50f423f2e3e401b9d9cbf2df29.tar.gz
2009-06-03 Tobias Burnus <burnus@net-b.de>
* gfortran.texi: Add mixed-language programming, mention varying string lengths, some clean up of introduction parts. * intrinsic.texi (instrinsic modules): Create @menu for * subsections. (ISO_C_BINDING): Support ISOCBINDING_INT_FAST128_T. * libgfortran.h: Comment to rember to keep gfortran.texi in * sync. * iso-c-binding.def: Support ISOCBINDING_INT_FAST128_T. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148147 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog9
-rw-r--r--gcc/fortran/gfortran.texi556
-rw-r--r--gcc/fortran/intrinsic.texi34
-rw-r--r--gcc/fortran/iso-c-binding.def3
-rw-r--r--gcc/fortran/libgfortran.h4
5 files changed, 567 insertions, 39 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 9bed6a3180d..19c415a0744 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2009-06-03 Tobias Burnus <burnus@net-b.de>
+
+ * gfortran.texi: Add mixed-language programming, mention
+ varying string lengths, some clean up of introduction parts.
+ * intrinsic.texi (instrinsic modules): Create @menu for subsections.
+ (ISO_C_BINDING): Support ISOCBINDING_INT_FAST128_T.
+ * libgfortran.h: Comment to rember to keep gfortran.texi in sync.
+ * iso-c-binding.def: Support ISOCBINDING_INT_FAST128_T.
+
2009-06-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Tobias Burnus <burnus@net-b.de>
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index b7c8b82537c..ab69c0aa3a6 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -182,6 +182,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.
+* Mixed-Language Programming:: Interoperability with C
* Extensions:: Language extensions implemented by GNU Fortran.
* Intrinsic Procedures:: Intrinsic procedures supported by GNU Fortran.
* Intrinsic Modules:: Intrinsic modules supported by GNU Fortran.
@@ -240,12 +241,10 @@ or alternative to, the unix @command{f95} command;
@node About GNU Fortran
@section About GNU Fortran
-The GNU Fortran compiler is still in an early state of development.
-It can generate code for most constructs and expressions,
-but much work remains to be done.
-
-When the GNU Fortran compiler is finished,
-it will do everything you expect from any decent compiler:
+The GNU Fortran compiler supports the Fortran 77, 90 and 95 standards
+completely, parts of the Fortran 2003 and Fortran 2008 standards, and
+several vendor extensions. The development goal is to provide the
+following features:
@itemize @bullet
@item
@@ -504,7 +503,7 @@ The primary work remaining to be done on GNU Fortran falls into three
categories: bug fixing (primarily regarding the treatment of invalid code
and providing useful error messages), improving the compiler optimizations
and the performance of compiled code, and extending the compiler to support
-future standards---in particular, Fortran 2003.
+future standards---in particular, Fortran 2003 and Fortran 2008.
@c ---------------------------------------------------------------------
@@ -515,6 +514,10 @@ future standards---in particular, Fortran 2003.
@section Standards
@cindex Standards
+@menu
+* Varying Length Character Strings::
+@end menu
+
The GNU Fortran compiler implements
ISO/IEC 1539:1997 (Fortran 95). As such, it can also compile essentially all
standard-compliant Fortran 90 and Fortran 77 programs. It also supports
@@ -528,13 +531,30 @@ of that standard is already provided; the current status of Fortran 2003
support is reported in the @ref{Fortran 2003 status} section of the
documentation.
-The next version of the Fortran standard after Fortran 2003 is currently
+The next version of the Fortran standard (Fortran 2008) is currently
being developed and the GNU Fortran compiler supports some of its new
features. This support is based on the latest draft of the standard
(available from @url{http://www.nag.co.uk/sc22wg5/}) and no guarantee of
future compatibility is made, as the final standard might differ from the
draft. For more information, see the @ref{Fortran 2008 status} section.
+Additionally, the GNU Fortran compilers supports the OpenMP specification
+(version 3.0, @url{http://openmp.org/wp/openmp-specifications/}).
+
+@node Varying Length Character Strings
+@subsection Varying Length Character Strings
+@cindex Varying length character strings
+@cindex Varying length strings
+@cindex strings, varying length
+
+The Fortran 95 standard specifies in Part 2 (ISO/IEC 1539-2:2000)
+varying length character strings. While GNU Fortran currently does not
+support such strings directly, there exist two Fortran implementations
+for them, which work with GNU Fortran. They can be found at
+@uref{http://www.fortran.com/@/iso_varying_string.f95} and at
+@uref{ftp://ftp.nag.co.uk/@/sc22wg5/@/ISO_VARYING_STRING/}.
+
+
@c =====================================================================
@c PART I: INVOCATION REFERENCE
@@ -787,9 +807,8 @@ was used.
@node Fortran 2003 status
@section Fortran 2003 status
-Although GNU Fortran focuses on implementing the Fortran 95
-standard for the time being, a few Fortran 2003 features are currently
-available.
+GNU Fortran supports several Fortran 2003 features; an incomplete
+list can be found below.
@itemize
@item
@@ -1241,7 +1260,7 @@ the real part is initialized unless @code{CMPLX} is used. In all other
cases, the BOZ literal constant is converted to an @code{INTEGER} value with
the largest decimal representation. This value is then converted
numerically to the type and kind of the variable in question.
-(For instance @code{real :: r = b'0000001' + 1} initializes @code{r}
+(For instance, @code{real :: r = b'0000001' + 1} initializes @code{r}
with @code{2.0}.) As different compilers implement the extension
differently, one should be careful when doing bitwise initialization
of non-integer variables.
@@ -1529,8 +1548,8 @@ It consists of a set of compiler directives, library routines,
and environment variables that influence run-time behavior.
GNU Fortran strives to be compatible to the
-@uref{http://www.openmp.org/drupal/mp-documents/spec25.pdf,
-OpenMP Application Program Interface v2.5}.
+@uref{http://www.openmp.org/mp-documents/spec30.pdf,
+OpenMP Application Program Interface v3.0}.
To enable the processing of the OpenMP directive @code{!$omp} in
free-form source code; the @code{c$omp}, @code{*$omp} and @code{!$omp}
@@ -1568,7 +1587,7 @@ this may lead to surprising results, especially to segmentation faults
if the stacksize is limited.
@item
-On glibc-based systems, OpenMP enabled applications can not be statically
+On glibc-based systems, OpenMP enabled applications cannot be statically
linked due to limitations of the underlying pthreads-implementation. It
might be possible to get a working solution if
@command{-Wl,--whole-archive -lpthread -Wl,--no-whole-archive} is added
@@ -1597,7 +1616,7 @@ are rebuilt using a new compiler or version of a compiler.
@code{%VAL} passes a scalar argument by value, @code{%REF} passes it by
reference and @code{%LOC} passes its memory location. Since gfortran
already passes scalar arguments by reference, @code{%REF} is in effect
-a do-nothing. @code{%LOC} has the same effect as a fortran pointer.
+a do-nothing. @code{%LOC} has the same effect as a Fortran pointer.
An example of passing an argument by value to a C subroutine foo.:
@smallexample
@@ -1614,9 +1633,8 @@ C
For details refer to the g77 manual
@uref{http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/index.html#Top}.
-Also, the gfortran testsuite c_by_val.f and its partner c_by_val.c are
-worth a look.
-
+Also, @code{c_by_val.f} and its partner @code{c_by_val.c} of the
+GNU Fortran testsuite are worth a look.
@node Extensions not implemented in GNU Fortran
@@ -1634,7 +1652,7 @@ code that uses them running with the GNU Fortran compiler.
@c More can be found here:
@c -- http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Missing-Features.html
-@c -- the list of fortran and libgfortran bugs closed as WONTFIX:
+@c -- the list of Fortran and libgfortran bugs closed as WONTFIX:
@c http://tinyurl.com/2u4h5y
@menu
@@ -1822,9 +1840,503 @@ c
@end smallexample
+@c ---------------------------------------------------------------------
+@c Mixed-Language Programming
+@c ---------------------------------------------------------------------
+
+@node Mixed-Language Programming
+@chapter Mixed-Language Programming
+@cindex Interoperability
+@cindex Mixed-language programming
+
+@menu
+* Interoperability with C::
+* Non-Fortran Main Program::
+@end menu
+
+This chapter is about mixed-language interoperability, but also applies
+if one links Fortran code compiled by different compilers. In most cases,
+use of the C Binding features of the Fortran 2003 standard is sufficient,
+and their use is highly recommended.
+
+
+@node Interoperability with C
+@section Interoperability with C
+
+@menu
+* Intrinsic Types::
+* Further Interoperability of Fortran with C::
+* Derived Types and struct::
+* Interoperable Global Variables::
+* Interoperable Subroutines and Functions::
+@end menu
+
+Since Fortran 2003 (ISO/IEC 1539-1:2004(E)) there is a
+standardized way to generate procedure and derived-type
+declarations and global variables which are interoperable with C
+(ISO/IEC 9899:1999). The @code{bind(C)} attribute has been added
+to inform the compiler that a symbol shall be interoperable with C;
+also, some constraints are added. Note, however, that not
+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.
+
+
+@node Intrinsic Types
+@subsection Intrinsic Types
+
+In order to ensure that exactly the same variable type and kind is used
+in C and Fortran, the named constants shall be used which are defined in the
+@code{ISO_C_BINDING} intrinsic module. That module contains named constants
+for kind parameters and character named constants for the escape sequences
+in C. For a list of the constants, see @ref{ISO_C_BINDING}.
+
+@node Derived Types and struct
+@subsection Derived Types and struct
+
+For compatibility of derived types with @code{struct}, one needs to use
+the @code{BIND(C)} attribute in the type declaration. For instance, the
+following type declaration
+
+@smallexample
+ USE ISO_C_BINDING
+ TYPE, BIND(C) :: myType
+ INTEGER(C_INT) :: i1, i2
+ INTEGER(C_SIGNED_CHAR) :: i3
+ REAL(C_DOUBLE) :: d1
+ COMPLEX(C_FLOAT_COMPLEX) :: c1
+ CHARACTER(KIND=C_CHAR) :: str(5)
+ END TYPE
+@end smallexample
+
+matches the following @code{struct} declaration in C
+
+@smallexample
+ struct @{
+ int i1, i2;
+ /* Note: "char" might be signed or unsigned. */
+ signed char i3;
+ double d1;
+ float _Complex c1;
+ char str[5];
+ @} myType;
+@end smallexample
+
+Derived types with the C binding attribute shall not have the @code{sequence}
+attribute, type parameters, the @code{extends} attribute, nor type-bound
+procedures. Every component must be of interoperable type and kind and may not
+have the @code{pointer} or @code{allocatable} attribute. The names of the
+variables are irrelevant for interoperability.
+
+As there exist no direct Fortran equivalents, neither unions nor structs
+with bit field or variable-length array members are interoperable.
+
+@node Interoperable Global Variables
+@subsection Interoperable Global Variables
+
+Variables can be made accessible from C using the C binding attribute,
+optionally together with specifying a binding name. Those variables
+have to be declared in the declaration part of a @code{MODULE},
+be of interoperable type, and have neither the @code{pointer} nor
+the @code{allocatable} attribute.
+
+@smallexample
+ MODULE m
+ USE myType_module
+ USE ISO_C_BINDING
+ integer(C_INT), bind(C, name="_MyProject_flags") :: global_flag
+ type(myType), bind(C) :: tp
+ END MODULE
+@end smallexample
+
+Here, @code{_MyProject_flags} is the case-sensitive name of the variable
+as seen from C programs while @code{global_flag} is the case-insensitive
+name as seen from Fortran. If no binding name is specified, as for
+@var{tp}, the C binding name is the (lowercase) Fortran binding name.
+If a binding name is specified, only a single variable may be after the
+double colon. Note of warning: You cannot use a global variable to
+access @var{errno} of the C library as the C standard allows it to be
+a macro. Use the @code{IERRNO} intrinsic (GNU extension) instead.
+
+@node Interoperable Subroutines and Functions
+@subsection Interoperable Subroutines and Functions
+
+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.
+
+To pass a variable by value, use the @code{VALUE} attribute.
+Thus the following C prototype
+
+@smallexample
+@code{int func(int i, int *j)}
+@end smallexample
+
+matches the Fortran declaration
+
+@smallexample
+ integer(c_int) func(i,j)
+ integer, VALUE :: i
+ integer :: j
+@end smallexample
+
+Note that pointer arguments also frequently need the @code{VALUE} attribute.
+
+Strings are handled quite differently in C and Fortran. In C a string
+is a @code{NUL}-terminated array of characters while in Fortran each string
+has a length associated with it and is thus not terminated (by e.g.
+@code{NUL}). For example, if one wants to use the following C function,
+
+@smallexample
+ #include <stdio.h>
+ void print_C(char *string) /* equivalent: char string[] */
+ @{
+ printf("%s\n", string);
+ @}
+@end smallexample
+
+to print ``Hello World'' from Fortran, one can call it using
+
+@smallexample
+ use iso_c_binding, only: C_CHAR, C_NULL_CHAR
+ interface
+ subroutine print_c(string) bind(C, name="print_C")
+ use iso_c_binding, only: c_char
+ character(kind=c_char) :: string(*)
+ end subroutine print_c
+ end interface
+ call print_c(C_CHAR_"Hello World"//C_NULL_CHAR)
+@end smallexample
+
+As the example shows, one needs to ensure that the
+string is @code{NUL} terminated. Additionally, the dummy argument
+@var{string} of @code{print_C} is a length-one assumed-size
+array; using @code{character(len=*)} is not allowed. The example
+above uses @code{c_char_"Hello World"} to ensure the string
+literal has the right type; typically the default character
+kind and @code{c_char} are the same and thus @code{"Hello World"}
+is equivalent. However, the standard does not guarantee this.
+
+The use of pointers is now illustrated using the C library
+function @code{strncpy}, whose prototype is
+
+@smallexample
+ char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
+@end smallexample
+
+The function @code{strncpy} copies at most @var{n} characters from
+string @var{s2} to @var{s1} and returns @var{s1}. In the following
+example, we ignore the return value:
+
+@smallexample
+ use iso_c_binding
+ implicit none
+ character(len=30) :: str,str2
+ interface
+ ! Ignore the return value of strncpy -> subroutine
+ ! "restrict" is always assumed if we do not pass a pointer
+ subroutine strncpy(dest, src, n) bind(C)
+ import
+ character(kind=c_char), intent(out) :: dest(*)
+ character(kind=c_char), intent(in) :: src(*)
+ integer(c_size_t), value, intent(in) :: n
+ end subroutine strncpy
+ end interface
+ str = repeat('X',30) ! Initialize whole string with 'X'
+ call strncpy(str, c_char_"Hello World"//C_NULL_CHAR, &
+ len(c_char_"Hello World",kind=c_size_t))
+ print '(a)', str ! prints: "Hello WorldXXXXXXXXXXXXXXXXXXX"
+ end
+@end smallexample
+
+C pointers are represented in Fortran via the special derived type
+@code{type(c_ptr)}, with private components. Thus one needs to
+use intrinsic conversion procedures to convert from or to C pointers.
+For example,
+
+@smallexample
+ use iso_c_binding
+ type(c_ptr) :: cptr1, cptr2
+ integer, target :: array(7), scalar
+ integer, pointer :: pa(:), ps
+ cptr1 = c_loc(array(1)) ! The programmer needs to ensure that the
+ ! array is contiguous if required by the C
+ ! procedure
+ cptr2 = c_loc(scalar)
+ call c_f_pointer(cptr2, ps)
+ call c_f_pointer(cptr2, pa, shape=[7])
+@end smallexample
+
+When converting C to Fortran arrays, the one-dimensional @code{SHAPE} argument
+has to be passed. Note: A pointer argument @code{void *} matches
+@code{TYPE(C_PTR), VALUE} while @code{TYPE(C_PTR)} matches @code{void **}.
+
+Procedure pointers are handled analogously to pointers; the C type is
+@code{TYPE(C_FUNPTR)} and the intrinsic conversion procedures are
+@code{C_F_PROC_POINTER} and @code{C_FUNLOC}.
+
+The intrinsic procedures are described in @ref{Intrinsic Procedures}.
+
+@node Further Interoperability of Fortran with C
+@subsection Further Interoperability of Fortran with C
+
+Assumed-shape and allocatable arrays are passed using an array descriptor
+(dope vector). The internal structure of the array descriptor used
+by GNU Fortran is not yet documented and will change. There will also be
+a Technical Report (TR 29113) which standardizes an interoperable
+array descriptor. Until then, you can use the Chasm Language
+Interoperability Tools, @url{http://chasm-interop.sourceforge.net/},
+which provide an interface to GNU Fortran's array descriptor.
+
+The technical report 29113 will presumably also include support for
+C-interoperable @code{OPTIONAL} and for assumed-rank and assumed-type
+dummy arguments. However, the TR has neither been approved nor implemented
+in GNU Fortran; therefore, these features are not yet available.
+
+@node Non-Fortran Main Program
+@section Non-Fortran Main Program
+
+@menu
+* _gfortran_set_args:: Save command-line arguments
+* _gfortran_set_options:: Set library option flags
+* _gfortran_set_convert:: Set endian conversion
+* _gfortran_set_record_marker:: Set length of record markers
+* _gfortran_set_max_subrecord_length:: Set subrecord length
+@end menu
+
+Even if you are doing mixed-language programming, it is very
+likely that you do not need to know or use the information in this
+section. Since it is about the internal structure of GNU Fortran,
+it may also change in GCC minor releases.
+
+When you compile a @code{PROGRAM} with GNU Fortran, a function
+with the name @code{main} (in the symbol table of the object file)
+is generated, which initializes the libgfortran library and then
+calls the actual program which uses the name @code{MAIN__}, for
+historic reasons. If you link GNU Fortran compiled procedures
+to, e.g., a C or C++ program or to a Fortran program compiled by
+a different compiler, the libgfortran library is not initialized
+and thus a few intrinsic procedures do not work properly, e.g.
+those for obtaining the command-line arguments.
+
+Therefore, if your @code{PROGRAM} is not compiled with
+GNU Fortran and the GNU Fortran compiled procedures require
+intrinsics relying on the library initialization, you need to
+initialize the library yourself. Using the default options,
+gfortran calls @code{_gfortran_set_args} and
+@code{_gfortran_set_options}. The initialization of the former
+is needed if the called procedures access the command line
+(and for backtracing); the latter sets some flags based on the
+standard chosen or to enable backtracing. In typical programs,
+it is not necessary to call any initialization function.
+
+If your @code{PROGRAM} is compiled with GNU Fortran, you shall
+not call any of the following functions. The libgfortran
+initialization functions are shown in C syntax but using C
+bindings they are also accessible from Fortran.
+
+
+@node _gfortran_set_args
+@subsection @code{_gfortran_set_args} --- Save command-line arguments
+@fnindex _gfortran_set_args
+@cindex libgfortran initialization, set_args
+
+@table @asis
+@item @emph{Description}:
+@code{_gfortran_set_args} saves the command-line arguments; this
+initialization is required if any of the command-line intrinsics
+is called. Additionally, it shall be called if backtracing is
+enabled (see @code{_gfortran_set_options}).
+
+@item @emph{Syntax}:
+@code{void _gfortran_set_args (int argc, char *argv[])}
+
+@item @emph{Arguments}:
+@multitable @columnfractions .15 .70
+@item @var{argc} @tab number of command line argument strings
+@item @var{argv} @tab the command-line argument strings; argv[0]
+is the pathname of the executable itself.
+@end multitable
+
+@item @emph{Example}:
+@smallexample
+int main (int argc, char *argv[])
+@{
+ /* Initialize libgfortran. */
+ _gfortran_set_args (argc, argv);
+ return 0;
+@}
+@end smallexample
+@end table
+
+
+@node _gfortran_set_options
+@subsection @code{_gfortran_set_options} --- Set library option flags
+@fnindex _gfortran_set_options
+@cindex libgfortran initialization, set_options
+
+@table @asis
+@item @emph{Description}:
+@code{_gfortran_set_options} sets several flags related to the Fortran
+standard to be used, whether backtracing or core dumps should be enabled
+and whether range checks should be performed. The syntax allows for
+upward compatibility since the number of passed flags is specified; for
+non-passed flags, the default value is used. See also
+@pxref{Code Gen Options}. Please note that not all flags are actually
+used.
+
+@item @emph{Syntax}:
+@code{void _gfortran_set_options (int num, int options[])}
+
+@item @emph{Arguments}:
+@multitable @columnfractions .15 .70
+@item @var{num} @tab number of options passed
+@item @var{argv} @tab The list of flag values
+@end multitable
+
+@item @emph{option flag list}:
+@multitable @columnfractions .15 .70
+@item @var{option}[0] @tab Allowed standard; can give run-time errors
+if e.g. an input-output edit descriptor is invalid in a given standard.
+Possible values are (bitwise or-ed) @code{GFC_STD_F77} (1),
+@code{GFC_STD_F95_OBS} (2), @code{GFC_STD_F95_DEL} (4), @code{GFC_STD_F95}
+(8), @code{GFC_STD_F2003} (16), @code{GFC_STD_GNU} (32),
+@code{GFC_STD_LEGACY} (64), and @code{GFC_STD_F2008} (128).
+Default: @code{GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_F2003
+| GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_GNU | GFC_STD_LEGACY}.
+@item @var{option}[1] @tab Standard-warning flag; prints a warning to
+standard error. Default: @code{GFC_STD_F95_DEL | GFC_STD_LEGACY}.
+@item @var{option}[2] @tab If non zero, enable pedantic checking.
+Default: off.
+@item @var{option}[3] @tab If non zero, enable core dumps on run-time
+errors. Default: off.
+@item @var{option}[4] @tab If non zero, enable backtracing on run-time
+errors. Default: off.
+Note: Installs a signal handler and requires command-line
+initialization using @code{_gfortran_set_args}.
+@item @var{option}[5] @tab If non zero, supports signed zeros.
+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).
+Default: disabled.
+@item @var{option}[7] @tab If non zero, range checking is enabled.
+Default: enabled. See -frange-check (@pxref{Code Gen Options}).
+@end multitable
+
+@item @emph{Example}:
+@smallexample
+ /* Use gfortran 4.5 default options. */
+ static int options[] = @{68, 255, 0, 0, 0, 1, 0, 1@};
+ _gfortran_set_options (8, &options);
+@end smallexample
+@end table
+
+
+@node _gfortran_set_convert
+@subsection @code{_gfortran_set_convert} --- Set endian conversion
+@fnindex _gfortran_set_convert
+@cindex libgfortran initialization, set_convert
+
+@table @asis
+@item @emph{Description}:
+@code{_gfortran_set_convert} set the representation of data for
+unformatted files.
+
+@item @emph{Syntax}:
+@code{void _gfortran_set_convert (int conv)}
+
+@item @emph{Arguments}:
+@multitable @columnfractions .15 .70
+@item @var{conv} @tab Endian conversion, possible values:
+GFC_CONVERT_NATIVE (0, default), GFC_CONVERT_SWAP (1),
+GFC_CONVERT_BIG (2), GFC_CONVERT_LITTLE (3).
+@end multitable
+
+@item @emph{Example}:
+@smallexample
+int main (int argc, char *argv[])
+@{
+ /* Initialize libgfortran. */
+ _gfortran_set_args (argc, argv);
+ _gfortran_set_convert (1);
+ return 0;
+@}
+@end smallexample
+@end table
+
+
+@node _gfortran_set_record_marker
+@subsection @code{_gfortran_set_record_marker} --- Set length of record markers
+@fnindex _gfortran_set_record_marker
+@cindex libgfortran initialization, set_record_marker
+
+@table @asis
+@item @emph{Description}:
+@code{_gfortran_set_record_marker} set the length of record markers
+for unformatted files.
+
+@item @emph{Syntax}:
+@code{void _gfortran_set_record_marker (int val)}
+
+@item @emph{Arguments}:
+@multitable @columnfractions .15 .70
+@item @var{val} @tab Length of the record marker; valid values
+are 4 and 8. Default is 4.
+@end multitable
+
+@item @emph{Example}:
+@smallexample
+int main (int argc, char *argv[])
+@{
+ /* Initialize libgfortran. */
+ _gfortran_set_args (argc, argv);
+ _gfortran_set_record_marker (8);
+ 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
+@cindex libgfortran initialization, set_max_subrecord_length
+
+@table @asis
+@item @emph{Description}:
+@code{_gfortran_set_max_subrecord_length} set the maximum length
+for a subrecord. This option only makes sense for testing and
+debugging of unformatted I/O.
+
+@item @emph{Syntax}:
+@code{void _gfortran_set_max_subrecord_length (int val)}
+
+@item @emph{Arguments}:
+@multitable @columnfractions .15 .70
+@item @var{val} @tab the maximum length for a subrecord;
+the maximum permitted value is 2147483639, which is also
+the default.
+@end multitable
+
+@item @emph{Example}:
+@smallexample
+int main (int argc, char *argv[])
+@{
+ /* Initialize libgfortran. */
+ _gfortran_set_args (argc, argv);
+ _gfortran_set_max_subrecord_length (8);
+ return 0;
+@}
+@end smallexample
+@end table
+
-@c ---------------------------------------------------------------------
@c Intrinsic Procedures
@c ---------------------------------------------------------------------
@@ -1913,6 +2425,7 @@ ideas and significant help to the GNU Fortran project
@item Andy Vaught
@item Feng Wang
@item Janus Weil
+@item Daniel Kraft
@end itemize
The following people have contributed bug reports,
@@ -1925,6 +2438,7 @@ GNU Fortran project:
@item Dominique d'Humi@`eres
@item Kate Hedstrom
@item Erik Schnetter
+@item Joost VandeVondele
@end itemize
Many other individuals have helped debug,
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index d560af78b37..0a8bba01cd9 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -11211,7 +11211,13 @@ Fortran 95 elemental function: @ref{IEOR}
@chapter Intrinsic Modules
@cindex intrinsic Modules
-@c @node ISO_FORTRAN_ENV
+@menu
+* ISO_FORTRAN_ENV::
+* ISO_C_BINDING::
+* OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
+@end menu
+
+@node ISO_FORTRAN_ENV
@section @code{ISO_FORTRAN_ENV}
@table @asis
@item @emph{Standard}:
@@ -11251,7 +11257,7 @@ Identifies the preconnected unit identified by the asterisk
(@code{*}) in @code{WRITE} statement.
@end table
-@c @node ISO_C_BINDING
+@node ISO_C_BINDING
@section @code{ISO_C_BINDING}
@table @asis
@item @emph{Standard}:
@@ -11272,12 +11278,8 @@ manual.
@c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
@c don't really know why.
-The @code{ISO_C_BINDING} module provides the following named constants of the
-type integer, which can be used as KIND type parameter. Note that GNU
-Fortran currently does not support the @code{C_INT_FAST...} KIND type
-parameters (marked by an asterisk (@code{*}) in the list below).
-The @code{C_INT_FAST...} parameters have therefore the value @math{-2}
-and cannot be used as KIND type parameter of the @code{INTEGER} type.
+The @code{ISO_C_BINDING} module provides the following named constants of
+type default integer, which can be used as KIND type parameters.
In addition to the integer named constants required by the Fortran 2003
standard, GNU Fortran provides as an extension named constants for the
@@ -11296,17 +11298,17 @@ C_INT_LEAST128_T, C_INT_FAST128_T}.
@item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t}
@item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t}
@item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t}
-@item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
+@item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
@item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t}
@item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
@item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
@item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
-@item @code{INTEGER}@tab @code{C_INT_LEAST128_T} @tab @code{int_least128_t} @tab Ext.
-@item @code{INTEGER}@tab @code{C_INT_FAST8_T}* @tab @code{int_fast8_t}
-@item @code{INTEGER}@tab @code{C_INT_FAST16_T}* @tab @code{int_fast16_t}
-@item @code{INTEGER}@tab @code{C_INT_FAST32_T}* @tab @code{int_fast32_t}
-@item @code{INTEGER}@tab @code{C_INT_FAST64_T}* @tab @code{int_fast64_t}
-@item @code{INTEGER}@tab @code{C_INT_FAST128_T}* @tab @code{int_fast128_t} @tab Ext.
+@item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext.
+@item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t}
+@item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t}
+@item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t}
+@item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t}
+@item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext.
@item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t}
@item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t}
@item @code{REAL} @tab @code{C_FLOAT} @tab @code{float}
@@ -11334,7 +11336,7 @@ defined.
@item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'}
@end multitable
-@c @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
+@node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
@section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
@table @asis
@item @emph{Standard}:
diff --git a/gcc/fortran/iso-c-binding.def b/gcc/fortran/iso-c-binding.def
index 2879776798a..aeeb41de298 100644
--- a/gcc/fortran/iso-c-binding.def
+++ b/gcc/fortran/iso-c-binding.def
@@ -95,7 +95,8 @@ NAMED_INTCST (ISOCBINDING_INT_FAST32_T, "c_int_fast32_t", \
NAMED_INTCST (ISOCBINDING_INT_FAST64_T, "c_int_fast64_t", \
get_int_kind_from_name (INT_FAST64_TYPE), GFC_STD_F2003)
/* GNU Extension. */
-NAMED_INTCST (ISOCBINDING_INT_FAST128_T, "c_int_fast128_t", -2, GFC_STD_GNU)
+NAMED_INTCST (ISOCBINDING_INT_FAST128_T, "c_int_fast128_t",
+ get_int_kind_from_width (128), GFC_STD_GNU)
NAMED_REALCST (ISOCBINDING_FLOAT, "c_float", \
get_real_kind_from_node (float_type_node))
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h
index d7e254f3635..839279e413e 100644
--- a/gcc/fortran/libgfortran.h
+++ b/gcc/fortran/libgfortran.h
@@ -19,7 +19,9 @@ along with GCC; see the file COPYING3. If not see
/* Flags to specify which standard/extension contains a feature.
- Note that no features were obsoleted nor deleted in F2003. */
+ Note that no features were obsoleted nor deleted in F2003.
+ Please remember to keep those definitions in sync with
+ gfortran.texi. */
#define GFC_STD_F2008 (1<<7) /* New in F2008. */
#define GFC_STD_LEGACY (1<<6) /* Backward compatibility. */
#define GFC_STD_GNU (1<<5) /* GNU Fortran extension. */