Rules for Fixed Format Fortran: A Comprehensive Guide

  • Context: Fortran 
  • Thread starter Thread starter swartzism
  • Start date Start date
  • Tags Tags
    Format Fortran Rules
Click For Summary
SUMMARY

This discussion focuses on the rules governing fixed format Fortran, specifically for file extensions .f77, .f, and .for. It confirms that there is a single fixed format used since Fortran 66, which includes specific column designations for comments, statement labels, and code statements, all adhering to an 80-column width limit due to historical punch card constraints. The conversation clarifies that while .f90 and .f95 indicate free-form formats, the fixed format remains consistent across .f77, .f, and .for extensions.

PREREQUISITES
  • Understanding of Fortran programming language
  • Familiarity with file extensions .f77, .f, and .for
  • Knowledge of historical computing concepts, particularly punch card systems
  • Basic grasp of programming syntax and structure
NEXT STEPS
  • Research the differences between fixed format and free format in Fortran, focusing on .f90 and .f95
  • Explore the historical context of Fortran's development and its evolution from punch cards
  • Study best practices for writing clean and maintainable Fortran code
  • Investigate modern tools and compilers that support Fortran, such as GNU Fortran (gfortran)
USEFUL FOR

This discussion is beneficial for Fortran developers, computer scientists, and educators teaching programming principles, particularly those focusing on legacy systems and fixed format coding standards.

swartzism
Messages
103
Reaction score
0
Are there any rule guides on fixed format Fortran such as in .f77, .f, .for files? For example, http://www.physics.nau.edu/~bowman/PHY520/F77tutor/03_basics.html has a few snippets of rules for Fortran 77 such as

Col. 1 : Blank, or a "c" or "*" for comments
Col. 1-5 : Statement label (optional)
Col. 6 : Continuation of previous line (optional; see below)
Col. 7-72 : Statements
Col. 73-80: Sequence number (optional, rarely used today)​

I'm wondering if there are any style guides floating around out there governing all of these sorts of rules for fixed (and even free) format Fortran. Thanks in advance!
 
Technology news on Phys.org
I don't understand why you are calling that "a few snippets." This is a complete description of fixed-form Fortran.
 
Yes, but isn't that just for .f77? Do .f and .for have different rules?
 
swartzism said:
Yes, but isn't that just for .f77? Do .f and .for have different rules?
No. There is a single fixed format, which is a leftover from the punch card era.

The only time the extension is important is when it is something like .f90 or .f95, where free-form is assumed.
 
swartzism said:
Yes, but isn't that just for .f77? Do .f and .for have different rules?
The statement format in the OP has been used since at least Fortran 66. The 80 column width limit is predicated on what could be fit onto old-style punch cards, which were used at one time to store and then feed a Fortran source program into a computer.

A punch card:

ibm-80-column-punched-card1.jpg

A Fortran coding form:

FortranCodingForm.png


Ahhh... the good old days!
 
That's progress for you ! Much better than that damn flimsy old paper tape ... :rolleyes:
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
Replies
2
Views
760