jump to navigation

FORTRAN Not Dead Yet October 14, 2006

Posted by gordonwatts in computers, physics.

The title of a recent paper on hep-ph:

A FORTRAN code for $\gamma \gamma \to Z Z $ in SM and MSSM

I always chuckle when I see these things. All of our DZERO software and most of our ATLAS software is all C++. Top to bottom. Except one little tiny place: the interface to the Monte Carlo generators. The generators are usually written by the theorists and then plugged-in to the experimental software frameworks. Experimentalists write everything in C++ these days. But, for whatever reasons, theorists continue to write in FORTRAN (I can find 23 papers in hep-ph with the word FORTRAN in their title).

The other thing I like about this paper is, if you read it, there is barely a reference to the fact that the code is in FORTRAN. After all, it is calculating the production and decay of the two Z bosons: that is the science. Somehow FORTRAN made it into the title.😉

Now, lets see how many FORTRAN-is-better comments I’ll get.🙂 I’ll start us off: it isn’t.😉 On the other hand, it does get the job done.


1. Brian Broom - October 15, 2006

I work in a theory group (modeling and simulation) that is almost exclusively FORTRAN. I am most familliar with c type languages, and *really* don’t like FORTRAN. Luckily the post-doc I work with is a c++ guy🙂

The really telling part is if you look in the docs for packages that switched from FORTRAN to (usually) C++, there is a statement that the C++ version is only a 5-10% performance hit. Only a few packages claim the C++ version is as fast or faster.

2. andy.s - October 15, 2006

Me love FORTRAN. Me like use punch cards, line printer. Newest guy in cave, he use C++, he always talk polymorphism, encapsulation. Me take club, me smash new guy when he debug inheritance heirarchy.
Now everyone use FORTRAN.

3. Gordon Watts - October 15, 2006

Brian — yep. If you translate what you wrote from FORTRAN to C++, you ignore much of the extra power — and FORTRAN is way better at being FORTRAN than C++ is! C++ can help, however, with variable length arrays, grouping of information, and, in some cases, reducing the large IF statements you have to scatter everywhere in your program. So, if done right, the code may be easier to read and maintain. And C++ may allow you to change the way you approach the problem — and that is where you might get yourself to run faster.

Andy — Brilliant. I have to post that around our departement!

4. Wu-Ki - October 15, 2006

It seems, when you guys talk about “Fortran”, you have only in mind the archaic Fortran 77.

Fortran 90/95 has the best of both worlds (including all the features Gordon mentions above)! And most importantly, it is backward compatible with Fortran 77. New codes written in 90/95 work seemlessly with all the classical codes and libraries built over the years. The free g95 compiler proves to be quite robust.

I have been incrementally upgrading my extensive analysis codes to 90/95. I love it.

5. nt moore - October 16, 2006

Here’s another advantage to fortran – particularly when using g95. You can teach undergrads pidgin f95 in two weeks to get a computational physics class (full of newbies) up and running (see particularly, “Classical Fortran”, Kupferschmid, CRC press). I can’t imagine a similar course using C++ ever getting past the code and to the science.

Exposing my bias, I used C++ in my thesis research and hated it.

6. Gordon Watts - October 16, 2006

Holy cow! There is actually someone out there that uses F90!! I’ll be! Wu-Ki — you’ll have to show me some of your code when I see you around the department! Wow.🙂

NT — I’ve done it, and taught them ROOT to boot. It isn’t hard as long as you don’t get lost in the jargon or designing for the sake of designing. But I agree with your basic thesis: fortran, by its nature, is much simpler and so students can learn its full power more quickly.

7. 祼´ - October 18, 2006



8. Dave Bacon - October 18, 2006

Speaking as a physicist who has been transported to the land of computer science, there is nothing that perplexs CS people more than learning of physicists and astronomer’s strange love of FORTRAN. When you tell them this they just stare at you like you’re some kind of monster.

9. DarkNight - June 15, 2009

Hey Don;t forget us Engineers!! we Love FORTRAN too! perhaps even more so!🙂

10. Florian - April 19, 2011

I used Fortran 90 to write a Finite-Difference-Semiconductor simulation for my Master Thesis; and I encountered a whole buch of PROBLEMS with it:

– FORTRAN 90 is the ONLY sensible NEW STANDARD. Fortran 95 has (terribly useful) TR-Extensions that should actually constitute Fortran 96. Fortran 2003 isn’t fully implemented by any compiler. I want a defined standard not a programm that compiles with ifort 8.1+ or gfortran4.0+, because it uses the TR-Allocatable extenstion. And guess what Fortran 2008 is already on it’s way. Will it ever be implemented — I am no fortune teller.

– You need a COMMERCIAL Fortran Compiler, if you want a to use a working debugger — gdb doesn’t quite do the job. And no I don’t feel like cluttering my code with write-statements for debugging purposes.

– Fortran 90 (and I refuse to consider the other standards for reasons mentioned above) LACKS so many features for OBJECT ORIENTED programming, I doubt anybody actually writes object oriented Fortran 90 code.

I therefore switched to C++, which is mighty, ugly but well defined and in widespread use.

To get a class of newbies ready to write some code one could use Fortran 77 as well. This has at least some historic value. I personally would teach them Python. That’s something they can really use, not for real-world-numerics though.

Billy - October 17, 2012

There is a huge gap between Fortran and C++.
Just the fact that there is much more libraries such as STL and boost for C++ and that there is much a larger community developing new open source projects in C++ justifies the change. Fortran is bad because it is too easy to produce spaghetti type code. Of course you can also produce bad code C++ but you have many books on how to avoid that. I know that Fortran is fast, there are still many numerical codes, it is easy, etc. If you develop in Fortran there will be a time where you regret of doing so specially in large projects.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: