1.1 About GNU Fortran
The GNU Fortran compiler supports the Fortran 77, 90 and 95 standards completely, parts of the Fortran 2003, 2008 and 2018 standards, and several vendor extensions. The development goal is to provide the following features:
- Read a user’s program, stored in a file and containing instructions written in Fortran 77, Fortran 90, Fortran 95, Fortran 2003, Fortran 2008 or Fortran 2018. This file contains source code.
- 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. The result after compilation of a program is machine code, code designed to be efficiently translated and processed by a machine such as your computer. Humans usually are not as good writing machine code as they are at writing Fortran (or C++, Ada, or Java), because it is easy to make tiny mistakes writing machine code.
- Provide the user with information about the reasons why
the compiler is unable to create a binary from the source code.
Usually this will be the case if the source code is flawed.
The Fortran 90 standard requires that the compiler can point out
mistakes to the user.
An incorrect usage of the language causes an error message.
The compiler will also attempt to diagnose cases where the user’s program contains a correct usage of the language, but instructs the computer to do something questionable. This kind of diagnostics message is called a warning message.
- Provide optional information about the translation passes from the source code to machine code. This can help a user of the compiler to find the cause of certain bugs which may not be obvious in the source code, but may be more easily found at a lower level compiler output. It also helps developers to find bugs in the compiler itself.
- 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 the GNU Debugger
- Locate and gather machine code already generated to perform actions requested by statements in the user’s program. This machine code is organized into modules and is located and linked to the user program.
The GNU Fortran compiler consists of several components:
- A version of the
gcccommand (which also might be installed as the system’s
cccommand) that also understands and accepts Fortran source code. The
gcccommand is the driver program for all the languages in the GNU Compiler Collection (GCC); With
gcc, you can compile the source code of any language for which a front end is available in GCC.
gfortrancommand itself, which also might be installed as the system’s
gfortranis just another driver program, but specifically for the Fortran compiler only. The difference with
gfortranwill automatically link the correct libraries to your program.
- A collection of run-time libraries.
These libraries contain the machine code needed to support
capabilities of the Fortran language that are not directly
provided by the machine code generated by the
gfortrancompilation phase, such as intrinsic functions and subroutines, and routines for interaction with files and the operating system.
- The Fortran compiler itself, (
f951). This is the GNU Fortran parser and code generator, linked to and interfaced with the GCC backend library.
f951“translates” the source code to assembler code. You would typically not use this program directly; instead, the
gfortrandriver programs will call it for you.