@c %**start of header
@setfilename g77.info
-@set last-update 1999-05-06
-@set copyrights-g77 1995-1999
+@set last-update 2000-11-27
+@set copyrights-g77 1995,1996,1997,1998,1999,2000
@include root.texi
@smallexample
@var{one line to give the program's name and a brief idea of what it does.}
-Copyright (C) 19@var{yy} @var{name of author}
+Copyright (C) @var{year} @var{name of author}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
when it starts in an interactive mode:
@smallexample
-Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
+Gnomovision version 69, Copyright (C) @var{year} @var{name of author}
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
type `show w'.
This is free software, and you are welcome to redistribute it
experimental, options added by @code{g77} to the @code{gcc}
compiler and its back end.
-(These, in turn, have made their way into the @code{egcs}
+(These, in turn, had made their way into the @code{egcs}
version of the compiler, and do not exist in @code{gcc}
version 2.8 or versions of @code{g77} based on that version
of @code{gcc}.)
network connections, and so on, which are invaluable to volunteers.
(Similarly, hiring Cygnus Support can help a project like GNU
Fortran---Cygnus has been a long-time donor of equipment usage to the author
-of GNU Fortran, and this too has been invaluable---@xref{Contributors}.)
+of GNU Fortran, and this too has been invaluable---see @ref{Contributors}.)
Currently, the only way to directly fund the author of GNU Fortran
in his work on that project is to hire him for the work you want
-fdebug-kludge -femulate-complex
-falias-check -fargument-alias
-fargument-noalias -fno-argument-noalias-global
--fno-globals
--fsubscript-check -ff2c-subscript-check
+-fno-globals -fflatten-arrays
+-fbounds-check -ffortran-bounds-check
@end smallexample
@end table
@cindex options, -fset-g77-defaults
@item -fset-g77-defaults
@emph{Version info:}
-This option is obsolete in @code{egcs}
-as of version 1.1.
+This option was obsolete as of @code{egcs}
+version 1.1.
The effect is instead achieved
by the @code{lang_init_options} routine
-in @file{egcs/gcc/f/com.c}.
+in @file{gcc/gcc/f/com.c}.
@cindex consistency checks
@cindex internal consistency checks
@cindex common blocks
@cindex equivalence areas
@cindex missing debug features
-Support for this option in Fortran programs is incomplete.
+Support for this option in Fortran programs was incomplete up till
+version 0.5.26 of @code{g77}.
In particular, names of variables and arrays in common blocks
-or that are storage-associated via @code{EQUIVALENCE} are
+or that are storage-associated via @code{EQUIVALENCE} were
unavailable to the debugger.
However, version 0.5.19 of @code{g77} does provide this information
in a rudimentary way, as controlled by the
@samp{-fdebug-kludge} option.
+Because version 0.5.26 of @code{g77} enables full debug information
+of COMMON BLOCK and EQUIVALENCE items, this option has been disabled.
+
@xref{Code Gen Options,,Options for Code Generation Conventions},
for more information.
@end table
information is suggested.
Use @samp{set language c} and @samp{set language fortran} to accomplish this.
+As of version 0.5.26 of @code{g77} this option has been disabled, as the
+compiler is now able to emit correct and complete debug information
+for COMMON BLOCK and EQUIVALENCE items.
+
For example:
@smallexample
(and its negative form).
Current plans call for this to happen when published versions of @code{g77}
and @code{gdb} exist that provide proper access to debugging information on
-@code{COMMON} and @code{EQUIVALENCE} members.
+@code{COMMON} and @code{EQUIVALENCE} members. This is believed to have
+happened as of version 0.5.26 of @code{g77}, so that this option has been
+disabled starting with this release.
@cindex -femulate-complex option
@cindex options, -femulate-complex
likely to result in the compiler later crashing
or producing incorrect code.
-@cindex -fsubscript-check option
-@cindex -ff2c-subscript-check option
-@item -fsubscript-check
-@itemx -ff2c-subscript-check
+@cindex -fflatten-arrays option
+@item -fflatten-arrays
+@cindex array performance
+@cindex arrays, flattening
+Use back end's C-like constructs
+(pointer plus offset)
+instead of its @code{ARRAY_REF} construct
+to handle all array references.
+
+@emph{Note:} This option is not supported.
+It is intended for use only by @code{g77} developers,
+to evaluate code-generation issues.
+It might be removed at any time.
+
+@cindex -fbounds-check option
+@cindex -ffortran-bounds-check option
+@item -fbounds-check
+@itemx -ffortran-bounds-check
@cindex bounds checking
@cindex range checking
@cindex array bounds checking
@code{g77} also generates checks for @code{CHARACTER} substring references,
something @code{f2c} currently does not do.
-Since a future version of @code{g77} might use a different implementation,
-use the new @samp{-ff2c-subscript-check} option
-if your application requires use of @code{s_rnge} or a compile-time diagnostic.
+Use the new @samp{-ffortran-bounds-check} option
+to specify bounds-checking for only the Fortran code you are compiling,
+not necessarily for code written in other languages.
@emph{Note:} To provide more detailed information on the offending subscript,
-@code{g77} provides @code{s_rnge}
+@code{g77} provides the @code{libg2c} run-time library routine @code{s_rnge}
with somewhat differently-formatted information.
Here's a sample diagnostic:
A newline in the file is the character that represents the end of
a line of text to the underlying system.
For example, on ASCII-based systems, a newline is the @key{NL}
-character, which has ASCII value 12 (decimal).
+character, which has ASCII value 10 (decimal).
@item
Each newline in the file serves to end the line of text that precedes
@cindex #
@cindex preprocessor
-@code{cpp} output-style @code{#} directives @xref{C Preprocessor
-Output,,, cpp, The C Preprocessor}, are recognized by the compiler even
+@code{cpp} output-style @code{#} directives
+(@pxref{C Preprocessor Output,,, cpp, The C Preprocessor})
+are recognized by the compiler even
when the preprocessor isn't run on the input (as it is when compiling
@samp{.F} files). (Note the distinction between these @code{cpp}
@code{#} @emph{output} directives and @code{#line} @emph{input}
For convenience this section collects a list (probably incomplete) of
the Fortran 90 features supported by the GNU Fortran language, even if
they are documented elsewhere.
-@c makeinfo 1.68 objects to the nested parens
-@ifnotinfo
-@xref{Characters Lines Sequence,,{Characters, Lines, and Execution Sequence}},
-@end ifnotinfo
-@ifinfo
-@xref{Characters Lines Sequence},
-@end ifinfo
+@xref{Characters Lines Sequence,,@asis{Characters, Lines, and Execution Sequence}},
for information on additional fixed source form lexical issues.
@cindex @samp{-ffree-form}
Further, the free source form is supported through the
permitted. Character constants may be enclosed in double quotes
(@code{"}) as well as single quotes. @xref{Character Type}.
@item Construct names
-(Symbolic tags on blocks.) @xref{Construct Names }.
+(Symbolic tags on blocks.) @xref{Construct Names}.
@item @code{CYCLE} and @code{EXIT}
@xref{CYCLE and EXIT,,The @code{CYCLE} and @code{EXIT} Statements}.
@item @code{DOUBLE COMPLEX}
-@xref{DOUBLE COMPLEX,,@code{DOUBLE COMPLEX} Statement
-}.
+@xref{DOUBLE COMPLEX,,@code{DOUBLE COMPLEX} Statement}.
@item @code{DO WHILE}
@xref{DO WHILE}.
@item @code{END} decoration
@code{>=} may be used instead of @code{.LT.}, @code{.LE.}, @code{.EQ.},
@code{.NE.}, @code{.GT.} and @code{.GE.} respectively.
@item @code{SELECT CASE}
-Not fully implemented. @xref{SELECT CASE on CHARACTER Type,,
-@code{SELECT CASE} on @code{CHARACTER} Type}.
+Not fully implemented.
+@xref{SELECT CASE on CHARACTER Type,, @code{SELECT CASE} on @code{CHARACTER} Type}.
@item Specification statements
A limited subset of the Fortran 90 syntax and semantics for variable
declarations is supported, including @code{KIND}. @xref{Kind Notation}.
@code{f2c} program on your path.
Something else that might be useful is @samp{cfortran.h} from
-@uref{ftp://zebra/desy.de/cfortran}.
+@uref{ftp://zebra.desy.de/cfortran}.
This is a fairly general tool which
can be used to generate interfaces for calling in both directions
between Fortran and C@.
properly supports Fortran-language debugging, including access
to members of @code{COMMON} areas.)
+Version 0.5.26 of @code{g77} is believed to provide correct and
+complete debug information for COMMON BLOCK and EQUIVALENCE items -
+hence the @samp{-fdebug-kludge} option has been disabled.
+
@xref{Code Gen Options,,Options for Code Generation Conventions},
for information on the @samp{-fdebug-kludge} option.
were withdrawn as of @code{g77} version 0.5.23
due to their not being supported by @code{gcc} version 2.8.
-These options, which control the assumptions regarding aliasing
+These options control the assumptions regarding aliasing
(overlapping) of writes and reads to main memory (core) made
-by the @code{gcc} back end,
-might well be added back (in some form) in a future version
-of @code{gcc}.
-
-However, these options @emph{are} supported by @code{egcs}.
+by the @code{gcc} back end.
The information below still is useful, but applies to
only those versions of @code{g77} that support the
If your program depends on exact IEEE 754 floating-point handling it may
help on some systems---specifically x86 or m68k hardware---to use
the @samp{-ffloat-store} option or to reset the precision flag on the
-floating-point unit @xref{Optimize Options}.
+floating-point unit.
+@xref{Optimize Options}.
However, it might be better simply to put the FPU into double precision
mode and not take the performance hit of @samp{-ffloat-store}. On x86
and m68k GNU systems you can do this with a technique similar to that
-for turning on floating-point exceptions @xref{Floating-point Exception
-Handling}. The control word could be set to double precision by
-replacing the @code{__setfpucw} call with one like this:
+for turning on floating-point exceptions
+(@pxref{Floating-point Exception Handling}).
+The control word could be set to double precision by some code like this
+one:
@smallexample
- __setfpucw ((_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE);
+#include <fpu_control.h>
+@{
+ fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
+ _FPU_SETCW(cw);
+@}
@end smallexample
(It is not clear whether this has any effect on the operation of the GNU
maths library, but we have no evidence of it causing trouble.)
Some targets (such as the Alpha) may need special options for full IEEE
-conformance @xref{Submodel Options,,Hardware Models and
-Configurations,gcc,Using and Porting GNU CC}.
+conformance.
+@xref{Submodel Options,,Hardware Models and Configurations,gcc,Using and Porting GNU CC}.
@node Inconsistent Calling Sequences
@subsection Inconsistent Calling Sequences
@cindex ix86 FPU stack
@cindex x86 FPU stack
Code containing inconsistent calling sequences in the same file is
-normally rejected @xref{GLOBALS}. (Use, say, @code{ftnchek} to ensure
-consistency across source files
-@c makeinfo 1.68 objects to the nested parens
-@ifinfo
-@xref{f2c Skeletons and Prototypes}.)
-@end ifinfo
-@ifnotinfo
+normally rejected---see @ref{GLOBALS}.
+(Use, say, @code{ftnchek} to ensure
+consistency across source files.
@xref{f2c Skeletons and Prototypes,,
-{Generating Skeletons and Prototypes with @code{f2c}}}.)
-@end ifnotinfo
+Generating Skeletons and Prototypes with @code{f2c}}.)
Mysterious errors, which may appear to be code generation problems, can
appear specifically on the x86 architecture with some such
@node Use Submodel Options
@subsection Use Submodel Options
-@cindex Pentium optimizations
-@cindex optimization, for Pentium
-@cindex 586/686 CPUs
@cindex submodels
Using an appropriate @samp{-m} option to generate specific code for your
CPU may be worthwhile, though it may mean the executable won't run on
other versions of the CPU that don't support the same instruction set.
@xref{Submodel Options,,Hardware Models and Configurations,gcc,Using and
-Porting GNU CC}.
-
-For recent CPUs that don't have explicit support in
-the released version of @code{gcc}, it may still be possible to get
-improvements.
-For instance, the flags recommended for 586/686
-(Pentium(Pro)) chips for building the Linux kernel are:
+Porting GNU CC}. For instance on an x86 system the compiler might have
+been built---as shown by @samp{g77 -v}---for the target
+@samp{i386-pc-linux-gnu}, i.e.@: an @samp{i386} CPU@. In that case to
+generate code best optimized for a Pentium you could use the option
+@samp{-march=pentium}.
-@smallexample
--m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2
--fomit-frame-pointer
-@end smallexample
+For recent CPUs that don't have explicit support in the released version
+of @code{gcc}, it @emph{might} still be possible to get improvements
+with certain @samp{-m} options.
-@noindent @samp{-fomit-frame-pointer} will, however, inhibit debugging
-on x86 systems.
+@samp{-fomit-frame-pointer} can help performance on x86 systems and
+others. It will, however, inhibit debugging on the systems on which it
+is not turned on anyway by @samp{-O}.
@node Trouble
@chapter Known Causes of Trouble with GNU Fortran
directly from the @code{gcc} manual, with minor modifications
to tailor it to users of @code{g77}.
Anytime a bug seems to have more to do with the @code{gcc}
-portion of @code{g77},
-@xref{Trouble,,Known Causes of Trouble with GNU CC,
+portion of @code{g77}, see
+@ref{Trouble,,Known Causes of Trouble with GNU CC,
gcc,Using and Porting GNU CC}.)
@menu
of this manual.
However, users of Linux-based systems (such as GNU/Linux)
-should review @uref{http://www.bitwizard.nl/sig11}, a source
+should review @uref{http://www.bitwizard.nl/sig11/}, a source
of detailed information on diagnosing hardware problems,
by recognizing their common symptoms.
Overflowing the bounds of an array---usually by writing beyond
the end of it---is one of two kinds of bug that often occurs
in Fortran code.
-(Compile your code with the @samp{-fsubscript-check} option
+(Compile your code with the @samp{-fbounds-check} option
to catch many of these kinds of errors at program run time.)
The other kind of bug is a mismatch between the actual arguments
Floating-Point Arithmetic', Computing Surveys, 23, March 1991, pp.@:
5-48.
An online version is available at
-@uref{http://docs.sun.com},
+@uref{http://docs.sun.com/},
and there is a supplemented version, in PostScript form, at
@uref{http://www.validgh.com/goldberg/paper.ps}.
Information related to the IEEE 754
floating-point standard by a leading light can be found at
-@uref{http://http.cs.berkeley.edu/%7Ewkahan/ieee754status};
+@uref{http://http.cs.berkeley.edu/%7Ewkahan/ieee754status/};
see also slides from the short course referenced from
@uref{http://http.cs.berkeley.edu/%7Efateman/}.
@uref{http://www.linuxsupportline.com/%7Ebillm/} has a brief
* Better Source Model::
* Fortran 90 Support::
* Intrinsics in PARAMETER Statements::
+* Arbitrary Concatenation::
* SELECT CASE on CHARACTER Type::
* RECURSIVE Keyword::
* Popular Non-standard Types::
* Suppressing Space Padding::
* Fortran Preprocessor::
* Bit Operations on Floating-point Data::
+* Really Ugly Character Assignments::
New facilities:
* POSIX Standard::
* Large Automatic Arrays::
* Support for Threads::
* Increasing Precision/Range::
+* Enabling Debug Lines::
Better diagnostics:
+* Better Warnings::
* Gracefully Handle Sensible Bad Code::
* Non-standard Conversions::
* Non-standard Intrinsics::
Run-time facilities:
* Uninitialized Variables at Run Time::
* Portable Unformatted Files::
+* Better List-directed I/O::
+* Default to Console I/O::
Debugging:
* Labels Visible to Debugger::
such a facility, @code{g77} will likely use that facility
in implementing this feature soon afterwards.
+@node Arbitrary Concatenation
+@subsection Arbitrary Concatenation
+@cindex concatenation
+@cindex CHARACTER*(*)
+@cindex run-time, dynamic allocation
+
+@code{g77} doesn't support arbitrary operands for concatenation
+in contexts where run-time allocation is required.
+For example:
+
+@smallexample
+SUBROUTINE X(A)
+CHARACTER*(*) A
+CALL FOO(A // 'suffix')
+@end smallexample
+
@node SELECT CASE on CHARACTER Type
@subsection @code{SELECT CASE} on @code{CHARACTER} Type
END
@end smallexample
+@node Really Ugly Character Assignments
+@subsection Really Ugly Character Assignments
+
+An option such as @samp{-fugly-char} should be provided
+to allow
+
+@smallexample
+REAL*8 A1
+DATA A1 / '12345678' /
+@end smallexample
+
+and:
+
+@smallexample
+REAL*8 A1
+A1 = 'ABCDEFGH'
+@end smallexample
+
@node POSIX Standard
@subsection @code{POSIX} Standard
be invoked at startup using @code{gcc}'s @code{constructor} attribute.
For example, just compiling and linking the following C code with your
program will turn on exception trapping for the ``common'' exceptions
-on an x86-based GNU system:
+on a GNU system using glibc 2.2 or newer:
@smallexample
-#include <fpu_control.h>
+#define _GNU_SOURCE 1
+#include <fenv.h>
static void __attribute__ ((constructor))
trapfpe ()
@{
- __setfpucw (_FPU_DEFAULT &
- ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM));
+ /* Enable some exceptions. At startup all exceptions are masked. */
+
+ feenableexcept (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
@}
@end smallexample
processors).
A package such as PVM might help here.
+@node Enabling Debug Lines
+@subsection Enabling Debug Lines
+@cindex debug line
+@cindex comment line, debug
+
+An option such as @samp{-fdebug-lines} should be provided
+to turn fixed-form lines beginning with @samp{D}
+to be treated as if they began with a space,
+instead of as if they began with a @samp{C}
+(as comment lines).
+
+@node Better Warnings
+@subsection Better Warnings
+
+Because of how @code{g77} generates code via the back end,
+it doesn't always provide warnings the user wants.
+Consider:
+
+@smallexample
+PROGRAM X
+PRINT *, A
+END
+@end smallexample
+
+Currently, the above is not flagged as a case of
+using an uninitialized variable,
+because @code{g77} generates a run-time library call that looks,
+to the GBE, like it might actually @emph{modify} @samp{A} at run time.
+(And, in fact, depending on the previous run-time library call,
+it would!)
+
+Fixing this requires one of the following:
+
+@itemize @bullet
+@item
+Switch to new library, @code{libg77}, that provides
+a more ``clean'' interface,
+vis-a-vis input, output, and modified arguments,
+so the GBE can tell what's going on.
+
+This would provide a pretty big performance improvement,
+at least theoretically, and, ultimately, in practice,
+for some types of code.
+
+@item
+Have @code{g77} pass a pointer to a temporary
+containing a copy of @samp{A},
+instead of to @samp{A} itself.
+The GBE would then complain about the copy operation
+involving a potentially uninitialized variable.
+
+This might also provide a performance boost for some code,
+because @samp{A} might then end up living in a register,
+which could help with inner loops.
+
+@item
+Have @code{g77} use a GBE construct similar to @code{ADDR_EXPR}
+but with extra information on the fact that the
+item pointed to won't be modified
+(a la @code{const} in C).
+
+Probably the best solution for now, but not quite trivial
+to implement in the general case.
+Worth considering after @code{g77} 0.6 is considered
+pretty solid.
+@end itemize
+
@node Gracefully Handle Sensible Bad Code
@subsection Gracefully Handle Sensible Bad Code
format.) A future @code{g77} runtime library should use such
techniques.
+@node Better List-directed I/O
+@subsection Better List-directed I/O
+
+Values output using list-directed I/O
+(@samp{PRINT *, R, D})
+should be written with a field width, precision, and so on
+appropriate for the type (precision) of each value.
+
+(Currently, no distinction is made between single-precision
+and double-precision values
+by @code{libf2c}.)
+
+It is likely this item will require the @code{libg77} project
+to be undertaken.
+
+In the meantime, use of formatted I/O is recommended.
+While it might be of little consolation,
+@code{g77} does support @samp{FORMAT(F<WIDTH>.4)}, for example,
+as long as @samp{WIDTH} is defined as a named constant
+(via @code{PARAMETER}).
+That at least allows some compile-time specification
+of the precision of a data type,
+perhaps controlled by preprocessing directives.
+
+@node Default to Console I/O
+@subsection Default to Console I/O
+
+The default I/O units,
+specified by @samp{READ @var{fmt}},
+@samp{READ (UNIT=*)},
+@samp{WRITE (UNIT=*)}, and
+@samp{PRINT @var{fmt}},
+should not be units 5 (input) and 6 (output),
+but, rather, unit numbers not normally available
+for use in statements such as @code{OPEN} and @code{CLOSE}.
+
+Changing this would allow a program to connect units 5 and 6
+to files via @code{OPEN},
+but still use @samp{READ (UNIT=*)} and @samp{PRINT}
+to do I/O to the ``console''.
+
+This change probably requires the @code{libg77} project.
+
@node Labels Visible to Debugger
@subsection Labels Visible to Debugger
How to do this depends on the version of @code{g77}:
@table @code
-@item EGCS-1.0
-@itemx FSF
+@item G77 0.5.24 (EGCS 1.1)
+@itemx G77 0.5.25 (EGCS 1.2 - which became GCC 2.95)
+Change the @code{lang_init_options} routine in @file{gcc/gcc/f/com.c}.
+
+(Note that these versions of @code{g77}
+perform internal consistency checking automatically
+when the @samp{-fversion} option is specified.)
+
+@item G77 0.5.23
+@itemx G77 0.5.24 (EGCS 1.0)
Change the way @code{f771} handles the @samp{-fset-g77-defaults}
option, which is always provided as the first option when
called by @code{g77} or @code{gcc}.
even when the user has not explicitly specified them.
Other ``internal'' options such as @samp{-quiet} also
are passed via this mechanism.
-
-@item EGCS-1.1
-@itemx EGCS-1.2
-Change the @code{lang_init_options} routine in @file{egcs/gcc/f/com.c}.
-
-(Note that these versions of @code{g77}
-perform internal consistency checking automatically
-when the @samp{-fversion} option is specified.)
@end table
@node Projects
It is not worth repeating them here.
@item
-@cindex concatenation
-@cindex CHARACTER*(*)
-@cindex run-time, dynamic allocation
-Support arbitrary operands for concatenation, even in contexts where
-run-time allocation is required.
-For example:
-
-@smallexample
-SUBROUTINE X(A)
-CHARACTER*(*) A
-CALL FOO(A // 'suffix')
-@end smallexample
-
-@item
Consider adding a @code{NUMERIC} type to designate typeless numeric constants,
named and unnamed.
The idea is to provide a forward-looking, effective
Much of this should be done only after the redesign planned for
0.6 is complete.
+@xref{Front End}, which contains some information
+on @code{g77} internals.
+
@node Internals Improvements
@section Internals Improvements
this problem,
which occurs only in releases of @code{g77}
based on @code{gcc}.
-(It does not occur in @code{egcs}.)
+(It did not occur in @code{egcs}.)
On AIX 4.1, @code{g77} might not build with the native (non-GNU) tools
due to a linker bug in coping with the @samp{-bbigtoc} option which