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
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.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

MSN VISTA

COVER THEM IN's picture

MSN VISTA

Fortran aesthetics

Donnie Berkholz's picture

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

Anonymous's picture

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

P. Countryman's picture

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

Mitch Frazier's picture

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.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix