Fortran 77′s Line Length Limit…

4 Comments

At work I have to modified a huge Fortran 77 program which simulates some geo-chemical stuff in order to make it run on a cluster to accommodate our large model. I have never dealt with Fortran before, only heard of it. It’s kind of old, I mean, 77, doesn’t that suppose to mean it came out in the year of 77?

I heard of some good things about Fortran in the old days: lots of programs in engineering fields, more efficient than C, wide spread, etc. But that’s not the case anymore. Things have changed greatly after, er, 1/3 of a century.

Although there is a lot to complains against Fortran 77, what I hate the most is the line length limit and the fields in a line. Let me explain what it means:

  • A line in Fortran 77 has fixed length of 80 characters, anything over that the compiler will report error
  • Column 1-5 is for descriptor number, yep, that’s for “GOTO” statements…
  • Column 6 is for continuation character, that’s to indicate this line is continued from last line
  • Column 7-72 is for actual coding
  • Column 73-80 is for whatever that will be ignored by the compiler

FortranCardPROJ039.agr

That’s where the idea came from, yes, PUNCH CARD! Now you know why some older Fortran 77 programs’ variable always have horribly short names.

This limit really gave me a lot of problems while I was writing the program. Especially I can only write my code from column 7 to 72. Sometimes I get weird bugs because of this. I guess this will train my attention to detail, heh!

9780133630039
Here is a book I bought that helped me quite a bit. I’m not sure if it’s DI best Fortran 77 book, but I think it’s at least one of the best for those who are relatively new to the language. If you already have programming background in other language, you can pick Fortran up really quick just by speed reading this book. Get a used one for a reasonable price on Amazon

RSSSubscribe to the RSS feed to receive more useful tips. Filed under: Software

4 Responses to “Fortran 77′s Line Length Limit…”

  1. Helge Grimm
    March 22nd, 2008 at 5:00 AM

    Fortran is STILL faster than C in most cases.
    The next time you have to modify a Fortran 77 program, convert the program to Fortran 90 free form first with one of the many free programs that will do just that. You certainly aren’t using a F77 compiler, you are using a F90/F95/F2003 compiler that does still understand the fixed source form, but will happily compile free form as well.

  2. rolandli
    March 24th, 2008 at 8:51 PM

    I think nowadays speed is not really an issue. After all, they all get compiled into the same machine code. So what really matters is the compiler.

    Actually I have been using PGI compiler, to be more specific, PGF77 for Fortran code. But you are right, I can convert them to newer free form. On the other hand, I guess I am pretty used to the line-length limit =) It’s good to know some “ancient art”.

  3. Yarko
    September 24th, 2008 at 11:03 AM

    Can somebody please please point to a single damn benchmark for Fortran vs C large number crunchers? I understand *some* optimized routines are more available for Fortran (i.e. matrix operations with BLASS etc.), and also there are awesome Fortran compilers for some supercomputers/clusters available, but what’s the actual gain? I mean is this a factor of 10 or more like 10% ?

  4. rolandli
    September 24th, 2008 at 11:47 AM

    Personally, I think there is no benchmark like that because it’s just too difficult to compare. However, here is an interesting read: http://ubiety.uwaterloo.ca/~tveldhui/papers/iscope97/index.html

Leave a comment