]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/about-gnu-fortran.rst
81852484c4eb0a52d14f218355245426dc4d57e0
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / about-gnu-fortran.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. _about-gnu-fortran:
7
8 About GNU Fortran
9 *****************
10
11 The GNU Fortran compiler is the successor to :command:`g77`, the
12 Fortran 77 front end included in GCC prior to version 4 (released in
13 2005). While it is backward-compatible with most :command:`g77`
14 extensions and command-line options, :command:`gfortran` is a completely new
15 implemention designed to support more modern dialects of Fortran.
16 GNU Fortran implements the Fortran 77, 90 and 95 standards
17 completely, most of the Fortran 2003 and 2008 standards, and some
18 features from the 2018 standard. It also implements several extensions
19 including OpenMP and OpenACC support for parallel programming.
20
21 The GNU Fortran compiler passes the
22 `NIST Fortran 77 Test Suite <http://www.fortran-2000.com/ArnaudRecipes/fcvs21_f95.html>`_, and produces acceptable results on the
23 `LAPACK Test Suite <https://www.netlib.org/lapack/faq.html>`_.
24 It also provides respectable performance on
25 the `Polyhedron Fortran compiler benchmarks <https://polyhedron.com/?page_id=175>`_ and the
26 `Livermore Fortran Kernels test <https://www.netlib.org/benchmark/livermore>`_. It has been used to compile a number of
27 large real-world programs, including
28 `the HARMONIE and HIRLAM weather forecasting code <http://hirlam.org/>`_ and
29 `the Tonto quantum chemistry package <https://github.com/dylan-jayatilaka/tonto>`_; see
30 https://gcc.gnu.org/wiki/GfortranApps for an extended list.
31
32 GNU Fortran provides the following functionality:
33
34 * Read a program, stored in a file and containing :dfn:`source code`
35 instructions written in Fortran 77.
36
37 * Translate the program into instructions a computer
38 can carry out more quickly than it takes to translate the
39 original Fortran instructions.
40 The result after compilation of a program is
41 :dfn:`machine code`,
42 which is efficiently translated and processed
43 by a machine such as your computer.
44 Humans usually are not as good writing machine code
45 as they are at writing Fortran (or C++, Ada, or Java),
46 because it is easy to make tiny mistakes writing machine code.
47
48 * Provide information about the reasons why
49 the compiler may be unable to create a binary from the source code,
50 for example if the source code is flawed.
51 The Fortran language standards require that the compiler can point out
52 mistakes in your code.
53 An incorrect usage of the language causes an :dfn:`error message`.
54
55 The compiler also attempts to diagnose cases where your
56 program contains a correct usage of the language,
57 but instructs the computer to do something questionable.
58 This kind of diagnostic message is called a :dfn:`warning message`.
59
60 * Provide optional information about the translation passes
61 from the source code to machine code.
62 This can help you to find the cause of
63 certain bugs which may not be obvious in the source code,
64 but may be more easily found at a lower level compiler output.
65 It also helps developers to find bugs in the compiler itself.
66
67 * Provide information in the generated machine code that can
68 make it easier to find bugs in the program (using a debugging tool,
69 called a :dfn:`debugger`, such as the GNU Debugger :command:`gdb`).
70
71 * Locate and gather machine code already generated to
72 perform actions requested by statements in the program.
73 This machine code is organized into :dfn:`modules` and is located
74 and :dfn:`linked` to the user program.
75
76 The GNU Fortran compiler consists of several components:
77
78 * A version of the :command:`gcc` command
79 (which also might be installed as the system's :command:`cc` command)
80 that also understands and accepts Fortran source code.
81 The :command:`gcc` command is the :dfn:`driver` program for
82 all the languages in the GNU Compiler Collection (GCC);
83 With :command:`gcc`,
84 you can compile the source code of any language for
85 which a front end is available in GCC.
86
87 * The :command:`gfortran` command itself,
88 which also might be installed as the
89 system's :command:`f95` command.
90 :command:`gfortran` is just another driver program,
91 but specifically for the Fortran compiler only.
92 The primary difference between the :command:`gcc` and :command:`gfortran`
93 commands is that the latter automatically links the correct libraries
94 to your program.
95
96 * A collection of run-time libraries.
97 These libraries contain the machine code needed to support
98 capabilities of the Fortran language that are not directly
99 provided by the machine code generated by the
100 :command:`gfortran` compilation phase,
101 such as intrinsic functions and subroutines,
102 and routines for interaction with files and the operating system.
103
104 .. and mechanisms to spawn,
105
106 .. unleash and pause threads in parallelized code.
107
108 * The Fortran compiler itself, (:command:`f951`).
109 This is the GNU Fortran parser and code generator,
110 linked to and interfaced with the GCC backend library.
111 :command:`f951` 'translates' the source code to
112 assembler code. You would typically not use this
113 program directly;
114 instead, the :command:`gcc` or :command:`gfortran` driver
115 programs call it for you.