7

Is it about performance, clean source code, compilers, ...? I know that many compilers allow longer single-line codes. But, if this extension is possible without any compromise, then why does Fortran standard strictly adhere to this rule?

I know that this is very general question (stackoverflow warns me that this question might be downvoted given its title), but I cannot find any resources that explain the logic behind a max length of 132 characters in modern Fortran standard.

Update Oct 22, 2019: See https://j3-fortran.org/doc/year/19/19-138r1.txt for a proposal accepted as a work item for the next 202X revision of the Fortran standard, which eliminates the maximum line length and continuation limits.

3
  • 2
    In line with mko and Holmz, "72", "132", etc, seem to be related to old hardware things (printers, terminals, punchcards, etc...) en.wikipedia.org/wiki/Characters_per_line but seem not much important any more...
    – roygvib
    Jul 9, 2017 at 9:12
  • 2
    132 is enough, even on modern large screens. Jul 9, 2017 at 17:13
  • 1
    The line length was previously 72, but with 6 characters on the left, used for labels and continuation lines. That leaves 66 for code, and 2 times 66 = 132. However, I don't have a reference to show that they "just" doubled the line length.
    – user13963867
    Feb 15, 2022 at 0:29

5 Answers 5

8

Take a look at specification:

ftp://ftp.nag.co.uk/sc22wg5/N001-N1100/N692.pdf

section: 3.3.1

It's just convention. Somebody decided that 132 will be ok. In 66 version it was 72.

Standards: https://gcc.gnu.org/wiki/GFortranStandards#Fortran_Standards_Documents

Usually, these limitations (like 80, 132 characters per line), were dictated by terminals.

Just to illustrate, in a "funny" way, how was it to code in 90's ;)

enter image description here

2
  • I am going to accept this as the answer. But I am still interested to know what went on in the mind of that someone who chose the 132 character limit.
    – Scientist
    Jun 15, 2020 at 23:13
  • 2
    @Scientist AFAIK the Sun Fortran Compiler uses internal arrays to represent the code, and these have a fixed size. Anything longer than 132 is simply cut off. Hard. So you would be left with half a variable name — and get the error message that myVariab is not defined (instead of myVariableName which you wrote in your too long line). Sep 8, 2022 at 16:10
4

The first programming language I learned back in the 1980s was Fortran (FORTRAN77 to be exact) Everybody was super excited because my group of students were the first ones allowed to use the brand new terminals that had just been set up in the room next to the computer. BTW: The computer was an IBM mainframe and it resided in a room the size of a small concert hall, about four times the size of the classroom with the 16 terminals. I remember having more than once spent hours and hours debugging my code only to find out that in one of my code lines I had again been using the full line width of 80 characters that the terminal provided instead of the 72 characters allowed by Fortan77. I used to call the language Fortran72 because of that restriction. When I asked my tutor for the reason he pointed me to the stack of cardboard boxes in the hallway. It was rather a wall of boxes, 8m long and almost 2m high. All these boxes were full of unused punch cards that they did not need anymore after the installation of the terminals. And yes the punchcards only used 72 characters per code line because the remaining 8 were required for the sequence number of the card. (Imagine dropping a stack of cards with no sequence numbers punched in.)

I am aware that I broke some rules and conventions here: I hope you still like that little piece of trivia and won't mind that my story does not exactly answer the original question. And yeah, it also repeats some information from previous answers.

1
  • 1
    It does repeat, but it repeats the stuff from answers that do not really answer the question. The question is why Fortran 90 free form has the 132 character limit, not why the old FORTRAN 66 fixed form has the 72 character limit. The connection of the old limit to punchards is well known to everyone, but the new limit is not obvious at all and is likely arbitrary to make compiler writing simpler. Jul 16, 2022 at 5:42
0

The old IBM line printers has 132 character width, so when IBM designed Fortran, that was the max line length

1
  • 4
    Do you have any source for this? I do not believe that is the case. When IBM designed Fortran I, the limit was much lower and was associated with punch cards. In 180s IBM was one of the forces blocking Fortran evolution, not designing it. Around 1990 when the limit was increased line printers were no longer a thing and line printer formatting in the first column was even removed from the Fortran standard. Oct 22, 2019 at 18:57
0

The reason was sequence numbers punched in columns 73-80 of the source code cards. When you dropped your program deck on the floor, they allowed you to bring the scrambled deck to a sorting machine (a large 5 foot long stand alone machine) and sort the deck back into order.

A sequencer program read the deck and could punch a new deck with updated sequence numbers, so the programmer did not get involved in the numbering. You punched a new deck after every few dozen changes. I did it many times 1970-1990.

2
  • 1
    Why would sequence numbers in columns 73-80 of a card influence the selection of a line limit of 132 columns? Jun 6, 2020 at 14:22
  • 1
    This answers a different question. You are writing about the obsolete fixed-form but the question is about the modern free form. Jun 6, 2020 at 15:15
-1

In the olden days the punchcards also were of finite length. I forget what was being used for terminals in the 90s other than they were long CRTs, but do not recall the resolution... But it was NOT 2k pixels wide.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.