Control Statell1Ents - IBM 1620 Manual

Hide thumbs Also See for 1620:
Table of Contents

Advertisement

Control Statements
22
Instead of writing the same statements many times, the
FORTRAN
program
allows you to take the square root of a number by merely inserting the expression
"SQRT
(x)" into an arithmetic statement wherever it is required. The mathematical
operations which are required to take the square root of a number are "prewritten"
into the
FORTRAN
program as a subroutine. (A subroutine is a program which per-
forms certain operations and may be included in another program to cause those
operations to be carried out each time the subroutine is used.)
The following functions can be used in
FORTRAN:
Mathematical Function
Square Root
Exponential
Sine of an angle in radians
Cosine of an angle in radians
Arctangent, angle given in radians
N aturallogarithm
FORTRAN Name~
SQRTF
EXPF
SINF
COSF
ATANF
LOGF
~The
name can be written with or without the terminal F.
For each of the functions shown above, there exists a subroutine within the
FORTRAN
system which computes the function of the argument enclosed in the
parentheses. These subroutines will be compiled into the object program auto-
matically when called for by a statement containing the name of one of these
functions. (These subroutines are sometimes called "relocatable subroutines").
To take the square root of a quantity with the variable name
DELTA,
you
could write the statement
D
=
SQRT (DELTA)
The argument enclosed in the parentheses must follow the name of the function.
The argument can be a variable or an expression and the variable can be sub-
scripted. The argument must always be in floating point mode. For example:
A
=
COS (B7)
A
=
SQRT (BETA)
A
=
LOG
(A)
Y
=
A - SIN (B
*
SQRT (A) )
FORTRAN
statements are executed in the object program in the same sequence as
they are written on the coding sheet, unless you specify a different sequence.
Control statements provide flexibility in program development. If statements
could only be followed sequentially in a fixed pattern,. a program would follow a
single path of operation without any possibility of dealing with predefined ex-
ceptions to the procedure, and without any ability to choose alternatives based
upon conditions encountered during the processing of the program.
As an example of the program control that can be exercised, assume that you
have written a
FORTRAN
program consisting of fifteen statements. These statements
perform a number of operations upon a series of variable quantities. Now, if the
first ten statements develop meaningless results when processed with variable
quantities of zero, the processing time of the object program would be reduced
if the first ten statements could be bypassed when the quantity to be processed is
zero. A single
FORTRAN
control statement permits you to evaluate a quantity, and
depending upon the value, permits you to direct the program to some other
statement rather than have the program continue in the sequence of the state-
ments.

Advertisement

Table of Contents
loading

Table of Contents