Go to the first, previous, next, last section, table of contents. ---------------------------------------------------------------------------- What is GNU Fortran? GNU Fortran, or g77, is designed initially as a free replacement for, or alternative to, the UNIX f77 command. (Similarly, gcc is designed as a replacement for the UNIX cc command.) g77 also is designed to fit in well with the other fine GNU compilers and tools. Sometimes these design goals conflict--in such cases, resolution often is made in favor of fitting in well with Project GNU. These cases are usually identified in the appropriate sections of this manual. As compilers, g77, gcc, and f77 share the following characteristics: * They read a user's program, stored in a file and containing instructions written in the appropriate language (Fortran, C, and so on). This file contains source code. * They translate the user's program into instructions a computer can carry out more quickly than it takes to translate the instructions in the first place. These instructions are called machine code---code designed to be efficiently translated and processed by a machine such as a computer. Humans usually aren't as good writing machine code as they are at writing Fortran or C, because it is easy to make tiny mistakes writing machine code. When writing Fortran or C, it is easy to make big mistakes. * They provide information in the generated machine code that can make it easier to find bugs in the program (using a debugging tool, called a debugger, such as gdb). * They locate and gather machine code already generated to perform actions requested by statements in the user's program. This machine code is organized into libraries and is located and gathered during the link phase of the compilation process. (Linking often is thought of as a separate step, because it can be directly invoked via the ld command. However, the g77 and gcc commands, as with most compiler commands, automatically perform the linking step by calling on ld directly, unless asked to not do so by the user.) * They attempt to diagnose cases where the user's program contains incorrect usages of the language. The diagnostics produced by the compiler indicate the problem and the location in the user's source file where the problem was first noticed. The user can use this information to locate and fix the problem. (Sometimes an incorrect usage of the language leads to a situation where the compiler can no longer make any sense of what follows--while a human might be able to--and thus ends up complaining about many "problems" it encounters that, in fact, stem from just one problem, usually the first one reported.) * They attempt to diagnose cases where the user's program contains a correct usage of the language, but instructs the computer to do something questionable. These diagnostics often are in the form of warnings, instead of the errors that indicate incorrect usage of the language. How these actions are performed is generally under the control of the user. Using command-line options, the user can specify how persnickety the compiler is to be regarding the program (whether to diagnose questionable usage of the language), how much time to spend making the generated machine code run faster, and so on. g77 consists of several components: * A modified version of the gcc command, which also might be installed as the system's cc command. (In many cases, cc refers to the system's "native" C compiler, which might be a non-GNU compiler, or an older version of gcc considered more stable or that is used to build the operating system kernel.) * The g77 command itself, which also might be installed as the system's f77 command. * The libf2c run-time library. This library contains the machine code needed to support capabilities of the Fortran language that are not directly provided by the machine code generated by the g77 compilation phase. * The compiler itself, internally named f771. Note that f771 does not generate machine code directly--it generates assembly code that is a more readable form of machine code, leaving the conversion to actual machine code to an assembler, usually named as. gcc is often thought of as "the C compiler" only, but it does more than that. Based on command-line options and the names given for files on the command line, gcc determines which actions to perform, including preprocessing, compiling (in a variety of possible languages), assembling, and linking. For example, the command `gcc foo.c' drives the file `foo.c' through the preprocessor cpp, then the C compiler (internally named cc1), then the assembler (usually as), then the linker (ld), producing an executable program named `a.out' (on UNIX systems). As another example, the command `gcc foo.cc' would do much the same as `gcc foo.c', but instead of using the C compiler named cc1, gcc would use the C++ compiler (named cc1plus). In a GNU Fortran installation, gcc recognizes Fortran source files by name just like it does C and C++ source files. It knows to use the Fortran compiler named f771, instead of cc1 or cc1plus, to compile Fortran files. Non-Fortran-related operation of gcc is generally unaffected by installing the GNU Fortran version of gcc. However, without the installed version of gcc being the GNU Fortran version, gcc will not be able to compile and link Fortran programs--and since g77 uses gcc to do most of the actual work, neither will g77! The g77 command is essentially just a front-end for the gcc command. Fortran users will normally use g77 instead of gcc, because g77 knows how to specify the libraries needed to link with Fortran programs (libf2c and lm). g77 can still compile and link programs and source files written in other languages, just like gcc. The command `g77 -v' is a quick way to display lots of version information for the various programs used to compile a typical preprocessed Fortran source file--this produces much more output than `gcc -v' currently does. (If it produces an error message near the end of the output--diagnostics from the linker, usually ld---you might have an out-of-date libf2c that improperly handles complex arithmetic.) In the output of this command, the line beginning `GNU Fortran Front End' identifies the version number of GNU Fortran; immediately preceding that line is a line identifying the version of gcc with which that version of g77 was built. The libf2c library is distributed with GNU Fortran for the convenience of its users, but is not part of GNU Fortran. It contains the procedures needed by Fortran programs while they are running. For example, while code generated by g77 is likely to do additions, subtractions, and multiplications in line---in the actual compiled code--it is not likely to do trigonometric functions this way. Instead, operations like trigonometric functions are compiled by the f771 compiler (invoked by g77 when compiling Fortran code) into machine code that, when run, calls on functions in libf2c, so libf2c must be linked with almost every useful program having any component compiled by GNU Fortran. (As mentioned above, the g77 command takes care of all this for you.) The f771 program represents most of what is unique to GNU Fortran. While the libf2c component is really part of f2c, a free Fortran-to-C converter distributed by Bellcore (AT&T), and the g77 command is just a small front-end to gcc, f771 is a combination of two rather large chunks of code. One chunk is the so-called GNU Back End, or GBE, which knows how to generate fast code for a wide variety of processors. The same GBE is used by the C, C++, and Fortran compiler programs cc1, cc1plus, and f771, plus others. Often the GBE is referred to as the "gcc back end" or even just "gcc"---in this manual, the term GBE is used whenever the distinction is important. The other chunk of f771 is the majority of what is unique about GNU Fortran--the code that knows how to interpret Fortran programs to determine what they are intending to do, and then communicate that knowledge to the GBE for actual compilation of those programs. This chunk is called the Fortran Front End (FFE). The cc1 and cc1plus programs have their own front ends, for the C and C++ languages, respectively. These fronts ends are responsible for diagnosing incorrect usage of their respective languages by the programs the process, and are responsible for most of the warnings about questionable constructs as well. (The GBE handles producing some warnings, like those concerning possible references to undefined variables.) Because so much is shared among the compilers for various languages, much of the behavior and many of the user-selectable options for these compilers are similar. For example, diagnostics (error messages and warnings) are similar in appearance; command-line options like `-Wall' have generally similar effects; and the quality of generated code (in terms of speed and size) is roughly similar (since that work is done by the shared GBE). ---------------------------------------------------------------------------- Go to the first, previous, next, last section, table of contents.
alvin888