IBM 1130 User Manual page 568

Computing system
Hide thumbs Also See for 1130:
Table of Contents

Advertisement

Code Efficient I/O statements
The manner in which you code your I/O statements
can have a significant effect on the size of your
program. The FORTRAN compiler will generate a
certain fixed amount of coding for each READ or
WRITE:
READ
3 words
WRITE
4 words
plus a certain additional amount (average) for each
item in the I/O list:
variable -- e. g., AB or I
2 words
variable, constant subscript --
e. g. , X(3)
4 words
variable, variable subscript --
e. g., X(J)
5 words
array name
3 words
implied DO loop e. g., (X(N) , N=l, 6)
19 words
If you wish to WRITE a line containing eight real
variables, you may code
WRITE (3,XXX) A, B, C, D,E, F, G, H
and use 4 + (8 x 2)or 20 words. Or vou could
EQUIVALENCE each of the eight items to a variable
in the ANSWR array
EQUIVALENCE (A, ANSWR(l»
EQUIVALENCE (B,ANSWR(2»
etc.
and code
WRITE (3, XXX) ANSWR
which would require only 4
+
(1 x 3) or 7 words.
You would not want to use
WRITE (3,XXX) (ANSWR(K),K=l, 8)
since that would require 23 words, more than the
original. In fact, the implied DO loop I/O format
should be avoided wherever possible.
This can
usually be accomplished with the EQUIVALENCE
statement.
For example, if you want to WRITE
the first six items of the eight-item ANSWR array,
you would code
DIMENSION ANSWR(8), ANS6(6)
EQUIVALENCE (ANS6(1), ANSWR(l»
WRITE (3, XXX) ANS6
saving 23-7 or 16 words.
Section
Subsections
Page
70
50
I
10
Avoid Long Subroutine Argument Lists
The coding generated for CALLs to subroutines is
quite similar to that of READs and WRITEs -- an
initial CALL (two words) plus a certain number of
words for each argument:
03
Type of Argument
None
Approximate
Core Required
o
words
Constant -- e. g. ,6
Unsubscribed Variable -- e. g., X or I
Array Name, -- e. g., IARRY
Variable with Constant Subscript --
e. g. ,A(7)
Variable with Variable Subscript --
1 word
1 word
1 word
8 words
e. g. ,A(N)
13 words
You can see that there is quite a difference' between
a. CALL SUB
2 words
b. CALL SUB (X, Y,
Z)
5 words
c. CALL SUB (lARRY)
3 words
d.
CALL SUB (A(l), A(2), A(3»
26 words
e. CALL SUB (A(I),A(J),A(K»
41 words
There are many ways to avoid those types of CALLs
that consume core storage.
Item d, CALL SUB (A(l), A(2), A(3», could be
replaced by
and
EQUIVALENCE (A(1),X)
EQUIVALENCE (A(2), Y)
EQUIVALENCE (A(3),
Z)
CALL SUB (X, Y,
Z)
or by
and
DIMENSION XA(3)
EQUIVALENCE (XA(1), A(1»
CALL SUB (XA)
or by placing the A array in COMMON and using
CALL SUB
with no arguments.
Item e, CALL SUB (A(I) , A(J), A(K», could be
replaced by
CALL SUB (A, I, J, K)
which would require a revised subroutine but would
save 41 -6 or 35 words. Or it could be replaced by
CALL SUB (I, J, K)
with the A array placed in COMMON.

Advertisement

Table of Contents
loading

Table of Contents