© 2001 by CRC Press LLC
The above program shows that Subroutines are independent units all started with
a SUBROUTINE statement which includes a name followed by a pair of parentheses
enclosing a number of
arguments
. The Subroutines are called in the main program
by specifying which variables or constants should serve as arguments to connect to
the subroutines. Some arguments provide input to the subroutine while other argu-
ments transmit out the results determined by the subroutine. These are referred to
as
input arguments
and
output arguments
, respectively. In many instances, an argu-
ment may serve a dual role for both input and output purposes. To construct as an
independent unit, a subprogram which can be in the form of a SUBROUTINE, or
FUNCTION
(to be elaborated later) must have RETURN and END statements.
It should also be remarked that program
MatxAlgb
is arranged to handle any
matrix having an order of no higher than 25 by 25. For this restriction and for having
the flexibility of handling any matrices of lesser order, the Lmax, Mmax, and Nmax
arguments are added in all three subroutines in order not to cause any mismatch of
matrix sizes between the main program and the called subroutine when dealing with
any L, M, and N values which are interactively entered via keyboard.
Computed GOTO and arithmetic IF statements are also introduced in the pro-
gram
MatxAlgb
. GOTO (i,j,k,…) C will result in going to (execute) the statement
numbered i, j, k, and so on when C has a value equal to 1, 2, 3, and so on, respectively.
IF (Expression) a,b,c will result in going to the statement numbered a, b, or c if the
value calculated by the expression or a single variable is less than, equal to, or,
greater than zero, respectively.
It is important to point out that in describing any derived procedure of numerical
computation,
indicial notation
such as Equation 5 should always be preferred to
facilitate programming. In that notation, the indices are directly used, or, literally
translated into the index variables for the DO loops as can be seen in Subroutine
MatxMtpy which is developed according to Equation 5. Subroutine MatrixSD is
another example of literally translating Equations 1 and 2. For defining the values
of the element in the following
tri-diagonal band matrix: