Scor­pio News

  

January–March 1987 – Volume 1. Issue 1.

Page 9 of 63

An Introduction to Fortran

by P.D. Coker

(In this article, F80 refers to Microsoft Fortran-80, ProFortran to the 8-bit Version of Fortran from Prospero Software. NFortran refers to Ellis Computing’s Nevada Fortran and Fortran refere to other versions such as Fortran IV oF Fortran 77.)

Why Use Fortran?

Fortran is, as computer languages go, very old, having first seen the light of day about 30 years ago as a scientific and technical high level language for early IBM mainframes – it’s older than ALGOL and BASIC (which owes a lot of its style to Fortran II) and, by comparison, Pascal and C are infants!

Most users are aware of the drawbacks of interpreted languages – particularly in terms of execution time. Fortran is a compiled language in which the source code is written using a text editor and then compiled into a run-time package which will execute much move rapidly than is the case with an interpreted language. There are two disadvantages to this, however. One is that any amendments which need to be made to the program involve editing and recompiling the source code which can be tedious. The other problem is one of cost. Virtually all compiled languages are expensive (£150 – 350), although HiSoft Pascal (a very satisfactory version) costs quite a lot less. There is a very good Fortran compiler, sold by Grey Matter of Ashburton, South Devon which is incredibly cheap. For £30 you get Nevada Fortran and a useful Guide – admittedly, the implementation of Fortran is not complete – but few will miss the bits the author has left out!

So, if you are fed-up with your BASIC and want to try a compiled language, then it really is worthwhile trying NFortran. True, Fortran is a little less flexible and efficient than Pascal but the conversion of programs from BASIC to Fortran is relatively simple and straightforward. I must admit to being professionally biased in favour of Fortran but some versions of Pascal are very finicky about syntax.

Program Structure

In BASIC, program entry is very straightforward with line numbers and statements typed in directly but in Fortran, the program statements must first be entered using a text editor such as WordStar (in non-document mode) or PEN before calling the compiler. All versions of Fortran use up to 80 columns per line of input, organised as follows:

Cols1 – 5Optional statement number (1 – 99999)
Col6‘Continuation’ character field (used only if the number of columns used by the statement exceeds 72)
Cols7 – 72Fortran statement
Cols73 – 80(can be used for identification, rude words or whatever)

Comments

In BASIC, REM statements (or comments preceded by single quote (') can be used to highlight information about programs. In Fortran, the use of a letter C in column 1 performs the same function; lines so marked are ignored by the compiler

Page 9 of 63