Sherman Crank Up The WayBack Machine
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.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- Google's SwiftShader Released
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Managing Linux Using Puppet
- Non-Linux FOSS: Caffeine!
- Interview with Patrick Volkerding
- SuperTuxKart 0.9.2 Released
- Parsing an RSS News Feed with a Bash Script
- Doing for User Space What We Did for Kernel Space