
|
FORTRAN FOR LINUX
|
|
|
|
Resources
- Michael Metcalf maintains the definitive "Fortran 90/95/HPF Information File".
- Less current is the Usenet-descended "Fortran FAQ".
- J3 is the US Fortran standards committee. It led formulation of the 66, 77, 90, and 95 definitions, and now "is the primary development body for Fortran 200x."
- The Fortran 77 Standard specifies what remains perhaps the most widely used Fortran base definition.
- The GNU Project documents its Fortran compiler in "Using and Porting GNU Fortran." Pay particular attention to the chapter on "Invoking G77." The wealth of command-line options detailed there make it practical to use G77 with an extremely wide range of Fortran coding standards.
- Already involved with Fortran? IBM's Common Optimization INterface (COIN) code base includes Derivative free optimization (DFO) -- a FORTRAN package for optimizing certain kinds of general nonlinear optimization problems.
- Although a physicist maintains The Linux Fortran Information Page, much of the information there applies in such far-flung domains as human resources and financial markets.
- The Intel Fortran Compiler 7.0 for Linux is widely recognized for the performance it achieves for executables compiled with it. It's not the only compiler for Linux; it might have the best reputation, though.
- If you think of Fortran only as "old," you're missing out on a language with plenty of advantages and life left in it, especially in the demanding scientific circles hungriest for the performance boosts Fortran provides. Learn how easy it is to start your own Fortran programming through any of several capable online tutorials.
- Linux4Chemistry is one of many science and engineering libraries based in large part on Fortran source code.
- The Royal Air Force uses Linux for its simulation and analysis of F3 Tornado aircraft.
- "VMS to Unix and Linux Migration Strategies" discusses, among other issues, the native formats for binary data under different operating systems.
- Did you know that IBM is the home of Fortran? It was the first language to allow engineers and scientists to write computer programs in more natural forms like C=A/B rather than as strings of 1s and 0s. Read more IBM history 1945-1996. The article History making components describes how Fortran and languages like it contributed to the evolution of object-oriented languages. For more on just the history of Fortran, see also A brief history of Fortran from the User Notes on Fortran Programming (UNFP) pages.
- It is a documented fact that Real Programmers use Fortran (although it is equally well known that the determined Real Programmer can write Fortran programs in any language.) As the saying goes, "If you can't do it in Fortran, do it in assembly language. If you can't do it in assembly language, it isn't worth doing." Read more in Real Programmers Don't Use PASCAL from 1983. Other worthy Fortran resources include the Fortran purity test and Fortran the song (to the tune of Billy Joel's Pressure.
Information about running Fortran codes under Linux
Recent (within past year) Additions
07 July 2004 -- More G95/Gnu Fortran info (thanks to Vivek Rao for this information).
13 April 2004 -- G95 info (thanks to Raymond S. Cheng for the pointer along with a couple other useful links).
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, Tomasz Plewa's page, The Fortran Library, and The Fortran Market are good places to start. Check out one of the following links (free book-size documents in postscript format) if you need to learn Fortran 77 or Fortran 90. 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.
Commercial Compilers
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.
Free Compilers
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
this page.
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 ---
Polyhedron maintains a very thorough table of benchmarks for various Fortran compilers, interesting for anyone desiring the utmost in performance.
Phoenix vs. the Linux Compilers ---
Peter Hauschildt 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 system.
- 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 more easily.
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.)
- 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 f77 Problem Page.
- 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 Linux.
fort77 and
yaf77 can be found at any Sunsite mirror, directory
devel/lang/fortran.
Debugger Support
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, <abel@netvision.net.il>).
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 (click here).
Foresys --- a very nice static analysis tool from Simulog in France. Does many of the same things that FORCHECK does. A nice plus is that code metrics are included; their value may be debated, but they are included if you want them. Also has a GUI; this is the only linux static analysis tool I have seen (for fortran that is) that has a GUI. Very nice, can easily take you with one click to the definition, or source code, for a variable or function on which you click in a source window. A trial version is available online.
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 RedHat. Also check out a support and extensions page as well as the FAQ.
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.
NAGWare Tools --- Software from NAG for transformation and analysis of Fortran-77 and Fortran-95 code. More information here.
The Fortran Programmer's Workshop This tool can be thought of as an interactive "make" facility. It has methods for organizing source code into libraries, building various programs from this code, running programs, and other code-maintenance facilities. There is a command-line version as well as a new graphical version which uses Tcl/Tk. You can visit the Fortran Programmer's Workshop Web Page for more information. I have no experience with this tool, as I am a diehard make fan.
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. Visit the PlusFORT Page for more information.
SNiFF+ --- A "source code engineering tool" which I know is in use at CERN, has now been released for Linux. Note that the version that you can download only works on glibc2.1 systems (like RedHat 6.0). I have not yet tried it, but here is what they sent me:
Description:
SNiFF+ is the premier Source Code Engineering tool. SNiFF+ provides an
integrated collection of source code analysis, browsing, navigation,
comprehension, editing, build, and configuration management tools for C,
C++, FORTRAN, Java, and CORBA IDL developers. With support for Windows and
all major UNIX platforms, SNiFF+ enables developers in cross-platform and
multi-language environments to utilize the same tool set and GUI.
Visit their web site to download an evaluation copy and find 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 web site, please click here to go to it.
asa --- This is an output filter for your Fortran output files. It looks at the Hollerith carriage-control strings in the first character position in each line (those pesky "0", "1", and "+" characters) and converts them into control codes understood by programs like "more" and by Unix printer software. This code should also work on other Unix systems.
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
See either
my local page for more Linux information.
Or, go to my
home page for other non-linux information.
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 - templon@nikhef.nl
http://www.nikhef.nl/~templon/fortran.html click this link for original page
Fortran Libraries
All of the following are free: