In my Twitter feed today was this gem from user @science_dot:

There is very little proper Fortran 77 in the world. Legacy Fortran almost always uses extension from MIL-STD-1753 and we should call most legacy Fortran “Fortran 80” to reflect when those compiler features would have been broadly available.

I agree completely – nearly every bit of code I see someone call “FORTRAN 77” isn’t at all. Sure, there are the obvious things such as INTEGER*4 and STRUCTURE/RECORD that are extensions that never made it into any standard. But I’ll often see INCLUDE or END DO, which were also not part of FORTRAN 77; they were part of another standard, MIL-STD-1753.

This US Military specification was published in 1978 and listed common extensions to FORTRAN 77 that were required to be supported by vendors responding to defense contracts. Many compilers already supported most of these, but I remember when I was working on VAX FORTRAN that we had to fill in a few missing pieces.

Here’s what MIL-STD-1753 added:

  • END DO as the terminal statement of a DO loop. This didn’t add the unlabeled block DO..END DO Fortran 90 would have, but it works with that.
  • DO WHILE, which could be unlabeled.
  • INCLUDE – yes, really, INCLUDE was not part of FORTRAN 77!
  • Allowing READ past an endfile record – this needs some explanation. Back in the 1970s, magnetic tape was the most popular mass storage medium. If you have delved into the Fortran standard, you may have noticed that the language has the notion of an ENDFILE record that could be represented as some physical entity. Indeed, on “unlabeled magnetic tape” (as opposed to “ANSI labeled tape”), the end of a file was recorded as a special signal on the tape that, when read, was interpreted as end of file. But you could write past the endfile marker on a tape, and many programs did so, using the marker as a separator of file sections. The ENDFILE statement writes such a marker.

    But if you had a tape like this, how did you read it in Fortran? The answer lies in how the standard talks about file position relating to an ENDFILE record. You read until END= is triggered, at which point you are positioned just after the ENDFILE record. Then you keep reading! This is what MIL-STD-1753 wanted to allow.
  • Bitwise intrinsic functions IAND, IEOR, IOR and NOT that operate on integers. (See also Doctor Fortran in “To .EQV. or to .NEQV., that is the question”, or “It’s only LOGICAL”)
  • Bit manipulation intrinsic procedures ISHFT, ISHFTC, IBITS, and MVBITS
  • Bit testing intrinsic functions BTEST, IBSET, and IBCLR
  • Octal and hexadecimal constants in DATA statements of the form O’nnn’ and Z’nnn’. (B’nnn’ was not specified.)

All of these, with the exception of reading past an endfile record, were eventually included in Fortran 90.

There is, however, one additional class of so-called FORTRAN 77 code that isn’t. I often see people refer to any fixed-form source as FORTRAN 77, even if it includes modern language features. Fixed-form is still part of the standard, though deprecated. See my 2013 thoughts on that in Doctor Fortran in “Source Form Just Wants to be Free” .

Got a suggestion for a future Doctor Fortran column? Let me know in the comments!


Write Your Comments

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Doctor Fortran

Subscribe to Doctor Fortran