Scor­pio News

  

January–March 1987 – Volume 1. Issue 1.

Page 10 of 63

Statement Numbers

In most BASICs, it in necessary to give each line of the program an identifying line number in ascending sequence since lines are interpreted on an incremental basis. Fortran differs since only certain statements are required to have numbers and program execution does not depend upon a numerical sequence but on the way in which statements are arranged – it starts at the first line and finishes at the last! Statement numbers are usually only required. during loop operations, data I/O of where control has to be passed to another part of the propram.

Continuation Lines

There are occasions when text headings or complicated expressions or layouts are used in a program where the space available for the statement (cols 7-72) is insufficient. A continuation line (or lines) needs to be used to accommodate the additional material; in such case, a character must be typed in column 6 and columns 1 – 5 left blank. Usually the first continuation line is labelled With an ‘A’ the second with a ‘B” and so on; the figures 0 – 9 could also be used if there are a lot of continuation Lines and F90 and ProFortran place no restriction, unlike some Mainframes where a limit of 10 – 20 is quite common. It is allowable, but not good practice to use the same symbol for succeeding lines. The normal use of only 72 columns is a hangover from the days of teletypes and was maintained when the majority of input was in the form of punched cards.

Program Entry

It is perfectly possible to write small Fortran programs on the back of an envelope before typing then into your micro – but a great deal easier if you use a proper coding form for the purpose in which the various columns and fields are shown; a typical example is shown in fig 1. A flow chart is useful when constructing a new program, note that control characters which the text editor may insect must be removed – the compiler tends to get uppity if it receives ^U or ^G. The program must not be formatted in any way and I would not recommend the use of DR’s ED which is only for the masochists – PEN, WordStar or HiSoft’s ED are such better

The statement must start in or after column 7 of each Line, with a statement label if needed in columns 1 – 5; the ‘tab’ facility could be used if one has a dislike of using the space bar although this will usually start the statement in column 9. If a continuation line is required, column 6 must be used as noted earlier; program statements must finish in or before column 72 unless a continuation line is to be used.

Data Names And Types

Fortran defines data specifically by name and, unlike most forms of BASIC, by type.

There are four names for data; constants (such as an explicitly stated numbers or pieces of data); variables – which are symbolically identified pieces of data; arrays which are ordered sets of data in 1,2 or 3 dimensions and array elements which refer to one member of the set of data in an array.

Date types may be Integer, Real, Double Precision, Logical or Hollerith.

Integer types are precise representations of whole numbers, positive, negative or zero in the range −32768 to +32767 and have a precision of 5 digits.

REAL types are approximations of real numbers, to 7+ significant digits which may have a magnitude lying between 10^-38 and 10^38 (or 2^-127 and 2^127).

Page 10 of 63