Sherman Crank Up The WayBack Machine
June 27th, 2008 by Mitch Frazier
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
$ gfortran test.fRunning 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 UNITSAlso 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.
Subscribe now!
The Latest
Newsletter
Tech Tip Videos
- Jul-01-09
- Jun-29-09
Recently Popular
From the Magazine
July 2009, #183
News Flash: Linux Kernel 3.0 to include an on-the-go Expresso machine interface! Ok, maybe not, but Linux is definitely going mobile, from phones to e-readers. Find out more inside about Android, the Kindle 2, the Western Digital MyBook II, The Bug, and Indamixx (a portable recording studio). And if you've gone mobile and you been wanting more Emacs in your life then check out Conkeror.
To compliment the mobile we've got the stationary: parsing command line options with getopt, checking your Ruby code with metric_fu, and building a secure Squid proxy. How is this stationary you ask? What can we say? It's not. We just wanted to see if anybody actually read this part of the page :) .
All this and more, and all you have to do is get your hot sweaty hands on the latest copy of Linux Journal.
Delicious
Digg
StumbleUpon
Reddit
Facebook








MSN VISTA
On November 5th, 2008 COVER THEM IN (not verified) says:
MSN VISTA
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.
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.
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!
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:
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