Pages

Friday, April 17, 2009

Room For Fortran?

As many of you know, I have real issues with FORTRAN. I tend to think progress in physics is held back by FORTRAN programmers for these reasons:
  1. Students taking CS classes to learn good programming practices cannot come back and apply them to their FORTRAN code. It's like we loose all that great knowledge by making students program in FORTRAN.
  2. Collaboration is minimized. Sure, high performance groups can collaborate since they know FORTRAN, but collaboration outside such niche groups is ruined. At least with C++ you can collaborate with the C/Java/C# programmers which is the overwhelming majority of programmers.
  3. Inability to reuse code as. Almost every FORTRAN programmer has to write code that has been written before by someone else. Some RK4 or Monte Carlo or etc.. routine. FORTRAN doesn't have the modern features like object oriented/generic programming so that code can be shared and reused more easily. Sure, some code is shared, but not at the same level as modern languages.
  4. Turns numerical programmers into people who can only write numerical programs? Seriously, other than numerical codes, what can you write in FORTRAN? To give physicists the ability to write more than just numerical codes will open the doors to greater progress.
Unfortunatly, here is the timeline of a FORTRAN programmer:
  1. Learns Java in his undergraduate CS class it was recommended he take.
  2. Starts doing research with some group where all the codes are in Fortran.
  3. Has to relearn a lot of programming and misses out being able to apply the good practices he could have taken from the CS department.
  4. Over time is convinced FORTRAN is great.
  5. Keeps a copy of Numerical Recipes close since he will have to write these routines that could easily be shared if he used another language.
  6. Pretty much can't do solid collaboration with people outside the high performance computing community, nor write anything other than numerical programs.
Now, I admit I am being extreme, but this is a big fear I have. I worry about scientific progress being held back.

At least, starting with FORTRAN 2003, object oriented and generic programming is merged into FORTRAN which will hopefully fix #3 above. I'm actually going to spend some free time looking into it. (Imagine that!) Also, at least FORTRAN has array checking.

Practical Realization:

I do realize that so much code is written in FORTRAN we can't just rewrite it all. But that doesn't mean I like the fact so much of the high-performance computing world is in this position.

3 comments:

  1. The trend that I am seeing is that all the old programmers who used to program in FORTRAN are switching over to C++. There is a grad student that I know whose thesis involves taking old FORTRAN code and converting it to C, and the professor who wrote the code in the first place is helping her. So all the old codes written in FORTRAN are steadily being replaced by C code. There are the die hard FORTRAN programmers but they will eventually retire and be replaced by C programmers. The impression I am getting is that the largest computing centers are no longer putting an emphasis on FORTRAN. Thus we will most likely be the first generation of professors that can deal with C and not FORTRAN.

    ReplyDelete
  2. We are one of those old-school research groups who use Fortran and I have to say that it does bite us in the rear occasionally. We use Fortran 95 which has a lot of the modern programing constructs, so we can write a modular, easy to understand code.

    However, since we are a rarity in the Fortran world, we do have some issues. For example, one of the best programs for profiling massively parallel codes is called TAU. TAU works with C, C++, and Fortran 77, but it does not support modules (which are somewhat like classes in C++). So while Fortran itself is keeping up with advances in computer science, the user community generally is not.

    ReplyDelete
  3. If you are going to use Fortran, thank heavens you use Fortran 95.

    I have used some Fortran 77 codes,(because I had to), and let' just say one code is even described by its author as spaghetti code.

    ReplyDelete

To add a link to text:
<a href="URL">Text</a>