Fortran Compilers
There are several free compilers available or up-coming for Unix-like operating systems that support modern Fortran language standards:
- GNU Fortran (gfortran)
- Modern Fortran compiler, part of the GNU Compiler Collection and successor of g77.
- Flang
- Front-end for LLVM, with limited support of the Fortran 2003 and 2008 language standards. Based on source code of PGI.
- Flang/F18
- LLVM front-end for Fortran 2018 in development, contributed by NVIDIA.
- LFortran
- A Fortran 2018 REPL-like front-end for LLVM, in pre-alpha stage.
- FC
- Another Fortran 2018 front-end for LLVM 10 by CompilerTree, in development.
- Intel oneAPI Fortran
- Intel’s Fortran, C, C++, and Python compilers for Windows, Linux, and macOS (freeware).
- IBM XL Fortran
- Proprietary no-charge full-function Community Edition of IBM’s Fortran compiler for Linux.
GNU Fortran is a fork of G95, a discontinued Fortran 95 compiler that has been removed from the FreeBSD ports collection due to deprecated dependencies that are required for building. Flang in an older front-end for LLVM, missing most features of Fortran 2008 and 2018.
Fortran compilers are available for many platforms. Most of them target Microsoft Windows and/or Linux, but do not produce native binaries for FreeBSD and other Unix systems, like Intel Fortran, PGI Community Edition, or the abandoned Open64.
Some historic compilers for FORTRAN 77 are open-source as well:
- f2c, a FORTRAN 77 to C transcompiler (Linux, Unix, Windows, …),
- GNU Fortran 77 (g77), predecessor of gfortran (Linux, Unix, Windows, …),
- Open Watcom FORTRAN 77 (DOS, Linux, OS/2, Windows).
Proprietary compilers targeting CP/M, DOS (fig. 1), and Microsoft Windows can be downloaded from various web sites dedicated to historic software, like old-dos.ru or winworldpc.com.
- Fig. 1: Box of Microsoft FORTRAN Compiler for DOS
Online Compilers
There are services that provide online access to Fortran compilers, to build and run Fortran programs through the web browser, like:
- Rextester (GNU Fortran 5.4.0),
- OnlineGDB (GNU Fortran 5.4.0),
- Tutorials Point (GNU Fortran 7.1.1, only Fortran 95 standard).
You may want to try some of the examples in the next sections by using an online compiler.
Modern Fortran on FreeBSD
Using FreeBSD as a programming environment for modern Fortran currently limits the list of available compilers to GNU Fortran and Flang, as Flang/F18 is still in early stage. All three can be installed from ports or by using the FreeBSD package manager. The Intel Fortran compiler for FreeBSD was removed from the ports collection in 2010.
- Installing GNU Fortran:
# pkg install lang/gcc11 # gfortran11 --version GNU Fortran (FreeBSD Ports Collection) 10.2.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
- Installing Flang:
# pkg install devel/flang # flang --version clang version 7.0.1 Target: x86_64-portbld-freebsd12.0 Thread model: posix InstalledDir: /usr/local/bin
- Flang/F18 is included in port
devel/llvm-devel
(build optionFLANG
must be enabled):
At the current development stage, only FORTRAN 77 is covered.# pkg install devel/llvm-devel # flang-devel -v f18 compiler (under development), version 13.0.0
References
- Fortran Wiki: Compilers
- Fortran-Lang.org: Compilers
- Wikipedia: List of Fortran compilers
< Introduction | [Index] | Editors and IDEs > |