Sherman Crank Up The WayBack Machine

June 27th, 2008 by Mitch Frazier

Your rating: None

If you don't get the title, you're probably too young to get the rest of this. If you don't know who John Backus was or what his contribution to computer science was then you're also, probably, too young.

The first programming I ever did was in a language called DITRAN using punched cards. DITRAN was a Diagnostic version of FORTRAN. I found it about as interesting as watching the corn grow.

Some years later, sitting in front of a CRT, it was a completely different story, I was hooked. We were developing accounting applications in FORTRAN 66 (you read that right) on a Prime 300 mini-computer. Prime had a BASIC interpreter, but that was for wimps.

So, today I wondered if I could compile and run a FORTRAN program on Linux. First problem I had, was I couldn't remember enough FORTRAN to actually write a program, so I stole this from the Wikipedia FORTRAN page. Had to make a few slight modifications to get it to compile:

C AREA OF A TRIANGLE WITH A STANDARD SQUARE ROOT FUNCTION 
C INPUT - CARD READER UNIT 5, INTEGER INPUT
C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT
C INPUT ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING
      READ 501, IA, IB, IC
  501 FORMAT (3I5)
C IA, IB, AND IC MAY NOT BE NEGATIVE
C FURTHERMORE, THE SUM OF TWO SIDES OF A TRIANGLE
C IS GREATER THAN THE THIRD SIDE, SO WE CHECK FOR THAT, TOO
      IF (IA) 777, 777, 701
  701 IF (IB) 777, 777, 702
  702 IF (IC) 777, 777, 703
  703 IF (IA+IB-IC) 777,777,704
  704 IF (IA+IC-IB) 777,777,705
  705 IF (IB+IC-IA) 777,777,799
  777 STOP 1
C USING HERON'S FORMULA WE CALCULATE THE
C AREA OF THE TRIANGLE
  799 S = FLOAT (IA + IB + IC) / 2.0
      AREA = SQRT( S * (S - FLOAT(IA)) * (S - FLOAT(IB)) *
     +     (S - FLOAT(IC)))
      WRITE (0,601) IA, IB, IC, AREA
  601 FORMAT (4H A= ,I5,5H  B= ,I5,5H  C= ,I5,8H  AREA= ,F10.2, 
     +        13H SQUARE UNITS)
      STOP
      END
To compile it you'll need the gcc-fortran package for your distro. Assuming the source file is "test.f" compile it with the following command:
  $ gfortran test.f
Running it is simple, although it took me a while to remember that FORTRAN likes its input values separated by commas:
  $ ./a.out
  3,4,5
  A=     3  B=     4  C=     5  AREA=       6.00 SQUARE UNITS
Also took me a while to figure out some acceptable input values... can you say trigonometry?.

If none of this is new to you, if it seems quite old-hat, then maybe you're involved in some sort of HPC (High Performance Computing). If so, check this link and maybe you can pass along some of that knowledge to some of these youngsters.

__________________________

Mitch Frazier is an Associate Editor for Linux Journal and the Web Editor for linuxjournal.com.


Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer

Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
COVER THEM IN's picture

MSN VISTA

On November 5th, 2008 COVER THEM IN (not verified) says:

MSN VISTA

Donnie Berkholz's picture

Fortran aesthetics

On July 7th, 2008 Donnie Berkholz (not verified) says:

That's a semi-fancy Fortran code you found, it's even got indenting! The stuff floating around here is unindented and written in all caps, which contribute to making it nigh unreadable. I suspect the all caps frequency may be because they actually didn't have lowercase back then.

Nowadays, you can actually write quasi-readable Fortran in lowercase (which is provably more readable than all-uppercase) with indentation.

Anonymous's picture

FORTRAN acronym

On June 28th, 2008 Anonymous (not verified) says:

FORTRAN originally stood for FORmula TRANslation, according to my memory. This one of the first special purpose languages, along with COmmon Business Oriented Language (for business uses). FORTRAN was designed mainly for running scientific formula programs. The data would be on a (Hollerith) punch card(s) following the EOR card (End Of Record) and prior to the EOF (End Of File) card.

By the way, the EOR and EOF formats for data/program were also used for teletype transmittal.

P. Countryman's picture

Fortran 66

On June 27th, 2008 P. Countryman (not verified) says:

When I was learning it, it wasn't _called_ Fortran 66, it was Fortran IV. I think the name Fortran 66 was applied retrospectively when Fortran 77 came out. Oh, yeah, and it should really be spelled in caps: FORTRAN. Don't ask me why - ask Mr. Peabody!

Mitch Frazier's picture

No and Yes

On June 27th, 2008 Mitch Frazier says:

No, according to Wikipedia (the source of all knowledge), the official name was FORTRAN 66:

The FORTRAN defined by the first standard became known as FORTRAN 66 (although many continued to refer to it as FORTRAN IV, the language upon which the standard was largely based). FORTRAN 66 effectively became the first "industry-standard" version of FORTRAN.

And yes, it is supposed to be all uppercase and as far as I see that's what I put. According to Mr. Peabody the reason for this is that it predates the evolution of the science of Acronyms. Kind of a goofy explanation, but whaddya expect from a dog with glasses.

__________________________

Mitch Frazier is an Associate Editor for Linux Journal and the Web Editor for linuxjournal.com.

Post new comment

Please note that comments may not appear immediately, so there is no need to repost your comment.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

Newsletter

Each week Linux Journal editors will tell you what's hot in the world of Linux. You will receive late breaking news, technical tips and tricks, and links to in-depth stories featured on www.linuxjournal.com.
Sign up for our Email Newsletter

Tech Tip Videos

From the Magazine

December 2009, #188

If last month's Infrastrucuture issue was too "big" for you then try on this month's Embedded issue. Find out how to use Player for programming mobile robots, build a humidity controller for your root cellar, find out how to reduce the boot time of your embedded system, and if you're new to embedded systems find out the basics that go into one. You can also read about the Beagle Board, the Mesh Potato and a spate of other interestingly named items. And along with our regular columns don't miss our new monthly column: Economy Size Geek.







Read this issue