Information about running Fortran codes under Linux
I am interested in any information people have that could be useful here;
please send email to the address at the bottom of the page. As I am
no longer actively developing in Fortran, I mostly add info here
when someone else tells me it's missing. So please let me
know if you miss something here!
Recent (within past year) Additions
25 February 2015 -- Added "findent" (thanks Willem Vermin),
added a "historical" page which contains information about
Fortran is the language of the past, and one of the languages
of the present, as far as physics is concerned. Hence this page. This
page system was originally oriented towards the previous version
(F77) of Fortran, but it now contains (as far as I know) all information
on F90/F95 for Linux as well.
These pages are almost entirely specific to Linux, with the exception
of the paragraph you are reading right now. For general Fortran
information, The Fortran Library
and The Fortran Market
are good places to start. Check out one of the following links
if you need to learn
Arnaud deSitter maintains a page on
Fortran Compiler Tips and Tricks.
Finally, here are some tips on what constitutes
good Fortran coding style.
One more note: I run Linux on an x86 box, thus my experience comes
solely from experience with this platform. All comments below apply to
the x86 platforms unless specifically noted.
Fortran Compilers for Linux
There are several choices. Here is a list. Please contact me if you see
something inaccurate or know of something that is missing. Click on the
compiler name for more detailed information.
The information below is mostly about the compilers' capabilities.
Polyhedron Software has
posted a table making performance comparisons between many linux
compilers. Not all the ones listed below are covered on their
page, but they do have many different benchmarks and thus give
a better idea of speed differences in a wide range of applications.
The theory group at NIKHEF has
done some comparisons as well, you can see their results at their
fortran performace page.
GCC --- GCC is the GNU
The project unifies
the C, C++, and Fortran-77 compilers (gcc, g++, and g77), and
attempts to make the system close to the cutting edge in terms of
there is an
older page about Gnu Fortran 77
that has been recommended.
I have used G77 to compile
which is a simulation code containing tens of thousands of lines of source;
it compiled and ran correctly with no problems whatsoever.
- There is a
dedicated to specially-optimized versions of gnu compilers for
- Gnu and Fortran90/95: The situation here is quite confusing
and seems to change frequently. See the following for information:
- Gfortran. This is
the Fortran95 compiler that is part of the Gnu
Compiler Collection gcc.
- G95. A related Fortran95
project, but not the same project.
some information on the relationship between the two projects.
I should point out that this information seems to represent only
one of two points of view on the relationship. I know too little
about the projects to be able to judge if it's accurate.
OpenWatcom --- Sybase Inc.
has decided to make the Watcom compiler line (C/C++/Fortran) open
source. I am not sure at this point that the compilers actually
run under Linux, but the sources are all there, and the
announcement on comp.os.linux.announce stated that the project
team was able to port from Dec Alpha to NT on Alpha in about a
week, so Linux support should be coming very soon if it isn't
already there. Any new information is welcome.
--- This product was similar to f2c in that it
translated f90 code into f77 code, and used g77 to compile this translated
code into an executable image. It is no longer available. From their
"Veridian Personal Linux f90 Version
This product is no longer being offered.
For alternatives, see Absoft Fortran or the F compiler, and you might want
to keep an eye on the g95 project.
--- A "high performance fortran compilation system"
provided by the folks at GMD and SCAI in Germany. It appears
that this tool translates HPF
Fortran) code into either F77 or F90 code.
That code is linked in with a library that performs distributed
computation via PVM or MPI. I don't do HPF, but if anyone who
does wishes to provide a review of this tool I would be happy
to include it.
--- A special version of the g77 compiler which has been
optimized to produce code for Pentium machines.
f2c (+ gcc) --- This was previously the
"standard" Linux Fortran system. Not native - f2c translates to C, and
true compilation handled by gcc. Thus this "compiler" should run on any
of the various Linux hardware platforms. Very stable and well-debugged.
Handles almost no extensions to the ANSI F77 standard. Good performance,
slow compilation, excellent "paranoia" results (certain compiler options
are required ... see the link above for more info). Debugging using gdb
is difficult, but is supported through an add-on package
(see the f2c-stabs entry below.) Available free of charge by ftp.
Imagine1 F Compiler --- F is a language which is a subset
of Fortran 95, and the latest release contains some features anticipated
It is not Fortran 77 compatible, but Jos Bergervoet reports that
one may link in object files compiled with g77. So you can't compile
F77 code, but you can still use your old libraries. If you are beginning a
new project and thus do not have to be F77 or VAX compatible, and would
like to use both Fortran and modern language constructs, you may be interested
in this. I have no personal experience with it.
home page for Imagine, and
is the Linux binary package.
--- This is a front-end code for HPF 2.0 (which includes
all of Fortran-90). I don't think it actually makes executables.
I have contacted the authors for more information.
Any reviews or more information is welcome.
Comparisons between compilers, benchmarks
More information to come here when I find it. Contributions are welcome.
Performance comparison: Absoft/Intel/Lahey/Portland --
John Wolter from NASA sent a note about
Porting Experiences for Six Different Compilers ---
Barbara Robson has sent in
comments about linux fortran compilers
based on her project to port an F95 code.
Compilers covered are PGI, NAG, Absoft, Lahey,
Fujitsu, and NA Software.
Polyhedron Benchmarks ---
a very thorough table of benchmarks for various Fortran
compilers, interesting for anyone desiring the utmost in performance.
Phoenix vs. the Linux Compilers ---
has submitted a detailed comparison
of the performance of the Phoenix code when compiled by Absoft,
NAG, and PGI compilers on x86 Linux boxes. Phoenix is a VERY LARGE
stellar atmospherics code.
My personal silly benchmark
I have a very small code which computes bremsstrahlung energy-loss
distributions for high-energy electrons. Go
here to pick up a package containing this benchmark and some instructions.
The program almost certainly fits in cache. Go
here to see results of running this benchmark on my machine, and others,
using code from various compilers.
Tips and Tricks
Suggestions and info to help you get the most out of your Fortran+Linux
The Alignment Info Page talks about
the importance of data alignment in getting the maximum execution speed
out of your code. This is particularly important for Pentium and Pentium-Pro
machines, where you can slow down (or speed up) your code by something
like 50 percent by alignment effects.
Linux-Specific Fortran Tools
These packages help use Fortran on Linux systems more effectively and/or
Compiler driver scripts
These scripts allow you to run f2c and gcc together and with the correct
arguments, without having to issue two commands. You issue one command,
which looks like a typical Fortran compiler program. It manages the separate
phases of f2c and gcc compilation. Slackware comes standard with a script
called f77 (which I do not recommend), and RedHat comes standard
with fort77 (see below.)
fort77 and yaf77 can be found at any Sunsite mirror, directory
f77/reorder --- Wolfgang Wander at DESY has an alternate version
of the f77 script (the "standard" Linux f2c+gcc driver.) His version of
f77 fixes the bugs of the original (like not working correctly in Makefiles).
"reorder" prepares your code for f2c translation by fixing some common
standard-violating coding practices which f2c will not accept. "reorder"
has recently been upgraded so that the emitted debugger information is
in sync with the original source file. You can find this package at his
fort77 --- fort77 is another f77 replacement. It works very well
in Makefiles, and its compiler-option flags more closely resemble those
of typical Unix f77 compilers than do those of the Slackware f77
script. Thus, Makefiles from other Unix systems will probably work with
it (and possibly not with f77.) It also uses gcc flags which are different
(better?) than those of f77 when you turn on optimization.
yaf77 --- Yet Another f77. I don't have any information on this
script itself. Some libraries are included with this package that some
net people have found helpful in porting codes from other systems to
NAGWare F95 code can be directly debugged with gdb, and Absoft's compiler ships
with its own fully symbolic source-level debugger. Users of one of the
various f2c+gcc packages can use the f2c-stabs package, which is
an Emacs interface to gdb. It has its own Fortran parser, and knows how
to translate the names used in the Fortran source so that gdb can find
them. Look here for a package
description from the author (Harvey J. Stein, <email@example.com>).
Other Fortran Tools Available for Linux
Forcheck --- Forcheck is a Fortran 77 and Fortran 90 parser which
verifies the syntax of program units and the consistency of the entire
program. It has been developed by Leiden University in the Netherlands,
but it is a commercial product. The following information comes from the
Forcheck Group at Leiden:
"It warns for all kinds of anomalies such as unassigned or unreferenced
items. It produces listings and cross-references of all syntax items. For
the global program it provides a call-tree, a subprogram index, and cross-references
of procedures, i/o, include files, common blocks and even common-block
elements. Forcheck supports most Fortran language extensions of many compilers
and can be tuned easily by the user. It can be used as a software engineering
tool for small up to very large projects."
I have a copy and am generally quite pleased with it. I am especially
happy that it supports F90 and DEC-Fortran STRUCTUREs, so I can analyze
much more code than I could with FTNCHEK. There are still a couple of things
for which I like FTNCHEK better, for example FTNCHEK has more user-friendly
global analysis (it will tell you the line number and type of interface
mismatches which reside in different files, something FORCHECK cannot do).
Forcheck has a web page
Source Navigator --- a wonderful tool from Cygnus Solutions.
Contains an integrated editor, cross-reference tool, "class browser" (which
treats DEC-Fortran STRUCTUREs as "classes"), a graphical front-end to gprof,
and more. It is now open-source; check it out at
FTNCHEK --- FTNCHEK is a Fortran-77 parser which will make a
nice listing file, construct a subroutine call tree (a sort of flow diagram
for your program), and list all variables with their types. It also can
do extensive syntax checking, and detects many classes of errors in ANSI
fortran-77 code. Most F77 compilers will do none of this for you (except
for find the coding errors, if they are severe enough.) The FTNCHEK listing
file can be made to look very much like VAX Fortran's FOR/LIS output. Pick
it up here.
Findent --- findent
indents Fortran source, fixed and free
format, and converts Fortran fixed format to Fortran free format.
PlusFORT --- PlusFORT is a very sophisticated package which can
analyze, beautify, and improve your Fortran codes. The package is quite
a bit more difficult to use than is FTNCHEK (see above), but can do much
more. It claims to handle all VAX/VMS extensions. I found that it will
accept things such as STRUCTUREs, but does not do much with them other
than parse them (sometimes incorrectly computing the size.) A free subset
of the complete version is available for Linux platforms.
the PlusFORT Page for more information.
Understand --- Understand is a program-analysis tool for Fortran
codes. You run this program with your source files as input, and it constructs
a database which can be visually browsed. The tool appears to be best suited
for "understanding" your program; clicking on any entity (under X windows)
allows you to see a diagram of, for example, what routines call a particular
subroutine, and what subroutines are called by it; find all the places
a particular variable is used, where and how it is defined, etc. It also
creates tables of program statistics which can be browsed under a WWW browser.
A demo version can be downloaded from their
Interactive Software Services
Ltd distributes INTERACTER, a
"multi-platform Fortran user-interface and graphics library
for Unix, VMS, Windows, and DOS." They've had a Linux version available
since September 1995. It supports the Fujitsu compiler, f2c and g77;
the g77 support applies
to Intel, Alpha, and SPARC platforms (you apparently do not need to
purchase a separate license for each platform). The Linux version is priced
lower than the other Unix versions. This information comes directly from
ISS Ltd and I cannot confirm or deny it, as I have no direct experience
with the product.
Other Linux Fortran Sites
Look here for historical
information about products no longer available.
See either my local page for more Linux
Or, go to my home page for other non-linux
This page was accessed roughly 5700 times when it resided at MIT. It
was accessed about 160,000 times when it was located at UGA between
January 1997 and June 2001.
Jeff Templon - firstname.lastname@example.org