Skip to main content

Full text of "ibm :: 1130 :: lang :: GC26-3715-8 1130 1800 Basic FORTRAN IV Language Jan73"

See other formats




Systems Reference Library 



File No. 1130/1800-25 
Order No. GC26-37 15-8 



IBM 1130/1800 Basic FORTRAN IV Language 



Page of GC26-3715-8 
Revised February 1974 
ByTNLGN34-0181 



PREFACE 



This publication provides the programmer of an 1130 
or 1800 system with the specifications required to 
write programs in the basic FORTRAN IV language. 
The basic FORTRAN IV language can be used with 
the minimum machine configurations of the following 
systems, with the one noted exception: 

• IBM 1130 Disk Monitor System, Version 2 (DM2) 

• IBM 1130 Disk Monitor System, Version 1 (DM1) 

• IBM 1130 Card/Paper Tape (C/PT) Programming 
System 

• IBM 1800 Multiprogramming Executive (MPX) 
Operating System 

• IBM 1800 Time- Sharing Executive (TSX) Operating 
System 

• IBM 1800 Card/Paper Tape (C/PT) Programming 
System with an IBM 1053 Printer, an IBM 1443 
Printer, or an IBM 1816 Printer-Keyboard 

Each of these programming systems includes a 
FORTRAN Compiler that converts a source program 
written in the 1130/1800 basic FORTRAN IV language 
into an object program for use by that system. 

This" publication is a reference source (not a self- 
study text) and describes the coding form, compilation 
messages, error codes, and the use of constants, vari- 
ables, arithmetic operators, FORTRAN statements, 
and statement numbers used in writing an 1130/1800 
basic FORTRAN IV program. 



Suggested Reading 

IBM 1130 publications: 

Subroutine Library, GC26-5929 
| Disk Monitor System, Version 2, Programmer's 

and Operator's Guide, GC26-3717 
Disk Monitor System (Version 1), Reference Manual, 

GC26-3750 
Card/Paper Tape Programming System 

Operator's Guide, GC26-3629 

IBM 1800 Multiprogramming Executive Operating 
System publications: 

Subroutine Library, GC26-3724 
Operating Procedures, GC26-3725 
Programmer's Guide, GC26-3720 

IBM 1800 Time-Sharing Executive Operating 
System publications: 

Subroutine Library, GC26-3723 
Operating Procedures, GC26-3754 
Concepts and Techniques, GC26-3703 

IBM 1800 Card/Paper Tape Programming System 
publications: 

Subroutine Library, GC26-5880 
Operator's Guide, GC26-3751 



Ninth Edition (January 1973) 



This is a reprint of GC26-3715-7 incorporating changes released in the following Technical Newsletters: 
GN34-0085 (dated May 1972) and GN34-0111 (dated October 1972). 

| This edition applies to Version 1, Modification 8, and to Version 2, Modification 12, of IBM 1130 
Disk Monitor System; to 1130 Card/Paper Tape System containing either Version 1, Modification 2, of 
1130-FO-001, or Version 1, Modification 3, of 1130-FO-002; to 1800 Card/Paper Tape System 
containing Version 1, Modification 3, of 1800-FO-007/008; to IBM 1800 Time-Sharing Executive 
Operating System containing Version 3, Modification 9, of 1800-OS-001 ; to IBM 1 800 Multiprogram- 

| ming Executive Operating System containing Version 3, Modification 4, of 1800-OS-010; and to all 
subsequent modifications of the above systems until otherwise indicated in new editions or Technical 
Newsletters. Changes are occasionally made to the specifications herein; before using this publication 
in connection with the operation of IBM systems, consult the latest SRL Newsletter, Order No. 
GN26-1130 or GN26-1800, for the editions that are applicable and current. 

Requests for copies of IBM publications should be made to your IBM representative or to the IBM 
branch office serving your locality. 

A form is provided at the back of this publication for readers' comments. If the form has been 
removed, coments may be addressed to IBM Corporation, Systems Publications, Department 27T, 
P. O. Box 1328, Boca Raton, Florida 33432. Comments become the property of IBM. 



©International Business Machines Corporation 1967, 1968, 1969, 1970, 1971 



CONTENTS 



INTRODUCTION 1 

CODING FORM 2 

How the Columns Are Used 2 

FORTRAN Statements 2 

Statement Numbers 2 

Program Identification, Sequencing 2 

Comments 2 

Blank Records 2 

Blank Columns 2 

CONSTANTS, VARIABLES, AND ARRAYS 3 

Constants 3 

Integer Constants • 3 

Real Constants 3 

Variables 4 

Variable Names 4 

Variable Types 4 

Subscripted Variables 5 

Arrays and Subscripts 5 

Arrangement of Arrays in Storage 5 

Subscript Forms ' 6 

ARITHMETIC EXPRESSIONS 7 

Definition 7 

The Arithmetic Operation Symbols 7 

Computational Modes, Integer and Real 7 

The Mode of an Expression 7 

Integer and Real Mode Expressions 7 

Mixed Expressions 7 

Arithmetic Operation Symbols 8 

Use of Parentheses 8 

Order of Operations 8 

STATEMENTS 9 

Arithmetic Statements 9 

j Control Statements 9 

Unconditional GO TO Statement 10 

Computed GO TO Statement 10 

IF Statement 10 

DO Statement 10 

CONTINUE Statement 12 

PAUSE Statement • • 13 

STOP Statement 13 

END Statement 13 

CALL Statement 13 

Special CALL Statements • • • 14 

Machine and Program Indicator Tests ' • 15 

Input/Output Statements 16 

Non-disk I/O Statements 17 

Disk I/O Statements 18 



Unformatted I/O Statements 20 

Indexing I/O Lists 20 

Manipulative I/O Statements 21 

Logical Unit Numbers r 22 

FORMAT Statement 22 

Specification Statements 29 

Type Statements (REAL, INTEGER) 29 

EXTERNAL Statement 30 

DIMENSION Statement 30 

COMMON Statement 30 

EQUIVALENCE Statement 32 

DATA Statement 33 

DEFINE FILE Statement 34 

Subprogram Statements 35 

Subprogram Names 36 

Functions 35 

SUBROUTINE Subprogram 39 

END and RETURN Statements in Subprograms 40 

Subprograms Written in Assembler Language 40 

COMPILATION MESSAGES 42 

APPENDIX A. SYSTEM/STATEMENT CROSS- 
REFERENCE TABLE 45 

APPENDIX B. COMPARISON OF USA STANDARD 

FORTRAN AND IBM 1130/1800 FORTRAN 
LANGUAGES 45 

APPENDIX C. 1130/1800 FORTRAN SOURCE 

PROGRAM CHARACTER CODES 49 

APPENDIX D. IMPLEMENTATION RESTRICTIONS 50 

APPENDIX E. SOURCE PROGRAM STATEMENTS 

AND SEQUENCING 51 

APPENDIX F. ERROR CODES 52 

INDEX 55 



INTRODUCTION 



FORTRAN (FORmula TRANslation) is a language that 
closely resembles the language of mathematics: It 
is designed primarily for scientific and engineering 
computations. Since the language is problem- 
oriented rather than machine- oriented, it provides 
scientists and engineers with a method of communi- 
cation with a computer that is more familiar, easier 
to learn, and easier to use than the system pro- 
gramming (Assembler) language. 



able for execution under each respective program- 
ming system. The translated program is known as 
the object program. 

The FORTRAN Compiler detects certain errors in 
the source program and writes appropriate messages 
on the typewriter or printer. At the user's option, 
the compiler also produces a listing of the source 
program and storage allocations. 



The elements of the FORTRAN Language are con- 
stants, variables, arrays, arithmetic operators, 
FORTRAN Statements and statement numbers. 
The elementary rules of expression of these 
elements in a FORTRAN program of 1130/1800 
systems are given in the chapters that follow. 

The IBM 1130 and 1800 Programming Systems 
provide a FORTRAN Compiler, a program that 
translates a FORTRAN program into a form suit- 



Exact results of the calculations should not always 
be expected because some computations are subject 
to "round- off" errors. 



The 1130/1800 FORTRAN language contains all 
of the features defined in American Standard Basic 
FORTRAN, X3. 10-1966, with significant extensions 
beyond this standard. These extensions are listed 
in Appendix B. 



Introduction 1 



Page of GC26-37 15-7 
Revised May 1972 
By TNL GN34-0085 



CODING FORM 



The statements of a FORTRAN source program 
are normally written on a standard FORTRAN cod- 
ing sheet (Form No. X28-7327). See Figure 1. 

HOW THE COLUMNS ARE USED 

The 80 columns of the FORTRAN Coding Sheet 
are used as follows: 

FORTRAN STATEMENTS 

FORTRAN statements are written one to a line in 
columns 7-72. If a st atement is too long for on e 
line, it m ay be continued on a maximum of five 
successive lines by placing any character other tha n 
a blank or a zero in column 6 of each continuati on 
line. In the first line of a statement, column 6 
must be either blank or zero. 

STATEMENT NUMBERS 

Some FORTRAN statements are identified with 
statement numbers in columns 1-5 inclusive. 
A statement number must be one of the digits in 

the range 1 to 99999 inclusive. It must be placed 
in the statement number field, but may be placed 
anywhere in that field; leading blanks or zeros, 
and trailing blanks are ignored by the compiler. 
Note: Superfluous statement numbers may de- 
crease efficiency during compilation and should, 



therefore, be avoided. Statement numbers on specifica- 
tion statements and continuation lines are ignored. 
PROGRAM IDENTIFICATION, SEQUENCING 

Columns 73-80 are not used by the FORTRAN 
Compiler and may, therefore, be used for program 
identification, sequencing, or any other purpose. 

COMMENTS 

Comments to explain the program may be written 
in columns 2-72 if the character C is placed in 
column 1. Comment lines may appear anywhere 
except before a continuation line or after an END 
statement. Comments are not processed by the 
FORTRAN Compiler. 

BLANK RECORDS 

Blank records in a source program are ignored 
by the Compiler. 

BLANK COLUMNS 

Blanks may be used freely to improve the read- 
ability of a FORTRAN program listing. For 
example, the following statements have a valid 
format: 

GObTO(l, 2, 3, 4), I 

GObTObb(l,2, 3,4),bbl 

where b represents a blank. 



IBM 


































































FORTRAN Codi 


"« 


r.™ 




























































"""""' 


~OUA» 


:r.Sn> 


gum: 














|«o. o- 


noctAMMi* 1 o*ii 


riNcn 














l CA "°' l ' c, "° """"'■ 


"CX" 


I 


FORTRAN STATEMENT 


"*S£T 


































































































































' 












































































































~ 


















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































' 


























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1 f 1 4 > 


# 


i • « io ii u ii u is 


. 17 II I. » 11 11 11 It M 


1* 17 n 19 10 11 11 11 14 11 M 11 !■ i» 40 41 « 41 44 *s » w « « so si 11 11 14 IS 14 1' 18 


nuiniuMouvN.niin 


n m n i. ii ii i. » 



Figure 1. FORTRAN Coding Sheet 



CONSTANTS, VARIABLES AND ARRAYS 



CONSTANTS 



REAL CONSTANTS 



In FORTRAN, any number which is not a state- 
ment number, appearing in a source statement, 
is called a constant. For example, in the state- 
ment J= 3 + K, the 3 is a constant. 
There are both integer and real constants in 
FORTRAN. 



INTEGER CONSTANTS 

Any constant which does not contain a decimal 
point is called an integer constant. 
The allowed range for integer constants is from 
-32768 or -(2^) to +32767 or +(2 15 -1). 

Explanatory Note; Only the (positive) magnitudes 
of integer constants are stored during compilation. 
The generation of negative integer constants 
occurs during execution of the program, as an 
arithmetic operation. Thus, the sign bits (16th 
bits) of the words in core are not available for 
integer constants; the maximum size of integer 
constants, both positive and negative, is given 
by fifteen bits being on. That number is 32767. 
All arithmetic operations in integer mode are 
modular 32767; that is, if the result of an arithmetic 
operation falls outside the allowed range, the sign 
is reversed. Sign changes during execution time 
are not displayed. 

Commas are not permitted within any FORTRAN 
constants. A preceding plus sign is optional for 
positive numbers. Any unsigned constant is assumed 
to be positive. 

The following examples are valid integer constants: 



91 

-173 

+327 

The following are not valid integer constants: 

3. 2 (contains a decimal point) 

27. (contains a decimal point) 

31459036 (exceeds the magnitude permitted 

by the compiler) 
5,496 (contains a comma) 



Any constant which contains a decimal point is 
called a real constant. Real constants may contain 
up to six or up to nine significant digits depending 
on the precision specified to the Compiler. 

Standard precision provides up to 23 significant 
bits of precision (6 plus significant digits) stored in 
core storage as shown below: 



1st Word 



2nd Word 



15 most significant bits of Mantissa 



15 



8 least significant bits 
of Mantissa 



Characteristic 



7 8 



15 



Extended precision provides up to 31 significant 
bits of precision (9 plus significant digits) stored in 
core storage as shown below: 



2nd Word 



3rd Word 



Reserved 


Characteristic 





7 8 15 


S 


Mantissa 





1 15 


Mantissa 



15 



Note: Normalization can in some cases cause the 
loss of one bit of significance. 

(The precision is specified to the compiler by 
optional use of an *EXTENDED PRECISION control 
record. See the section describing FORTRAN con- 
trol records in the appropriate corequisite pub- 
lication, as listed. in the Preface .) 

The magnitude of a real constant must not be 
greater than 2* 2 ^ or less than 2~ 12 ° (approximately 
10 38 and 10~ 39 ). It may be zero. 

A real constant may be followed by a decimal 
exponent written as the letter E followed by a one- 
or two-digit integer constant (signed or unsigned) 
indicating the power of 10. 



Constants, Variables and Arrays 3 



Page of GC26-3715-8 
Revised February 1974 
ByTNLGN34-0181 

The following examples are valid real constants: 



105. 




3.14159 




5.E3 


(5. x 10 3 ) 


5.0E3 


(5. Ox 103) 


■5. 0E03 


(-5. Ox 103) 


5.0E-3 


(5. x 10-3) 


5.0E1 


(5. x 10) 



The following are not valid real constants: 



325 

5.0E 

5.0E003 

5E02 



VARIABLES 



(no decimal point; however, this is 

a valid integer constant) 

(no exponent) 

(exponent contains three digits) 

(no decimal point) 



A FORTRAN variable is a symbolic representation of 
a quantity that may assume different values. The 
value of a variable may change either for different 
executions of a program or at different stages within 
the program. For example, in the statement 

A = 5.0 + B 

both A and B are variables. The value of B is 
determined by some previous statement and may 
change from time to time. The value of A varies 
whenever this computation is performed with a new 
value for B. 



VARIABLE NAMES 

A variable name consists of 1-5 alphameric charac- 
ters, excluding special characters, the first of which 
must be alphabetic. Blanks in a variable name will 
be ignored by the compiler. (See Appendix C. ) 



Examples: 

M 

DEV86 

12 

The rules for naming variables allow for extensive 
selectivity. In general, it is easier to follow the 



flow of a program if meaningful symbols are used 
wherever possible. For example, to compute 
distance it would be possible to use the statement: 

X = Y*Z (Asterisk denotes multiplication) 

but it would be more meaningful to write: 



or: 



D = R*T 



DIST = RATE*TIME 



Similarly, if the computation were to be performed 
using integers, it would be possible to write: 

1 = J*K 
but it would be more meaningful to write: 



ID = IR*IT 



ort 



IDIST = IRATE *ITIME 
In other words, variables can often be written in a 
meaningful manner by using an initial character to 
indicate whether the variable represents an integer 
or real value and by using succeeding characters as 
an aid to the user's memory. 

Note: .The names of FORTRAN-supplied FUNCTION 
subprograms, or such names preceded by F or E, 
for example, SIN, FCOS, ESQRT, must not be used 
as variable names. 

VARIABLE TYPES 

The type of variable corresponds to the type of data 
the variable represents (i.e. , integer or real). 
Variable type can be specified in two ways: 
implicitly or explicitly. 

Implicit Specification 

Implicit specification of a variable is made as 
follows: 

1. If the first character of the variable name is 

I, J, K, L, M, or N, the variable is an integer 
variable. 

2. If the first character of the variable name is not 
I, J, K, L, M, or N, the variable is a real 
variable. 

Explicit Specification 

Explicit specification of a variable type 
is made by using the Type statement 



Page of GC26-37 15-7 
Revised May 1972 
By TNL GN34-0085 



(see Type Statements) . The explicit specification 
overrides the implicit specification. For example, 
if a variable name is ITEM and a Type specification 
statement indicates that this variable is real, the 
variable is handled as a real variable, even though 
its initial letter is I. 

The allowed range for integer variables is from 
-32768 to 32767 inclusive. 

SUBSCRIPTED VARIABLES 

A subscripted variable consists of a variable name 
followed by a pair of parentheses enclosing one, two, 
or three subscripts separated by commas. 

Examples: 

A(I) 

K(3) 

ALPHA(I,J+2) 

BETA(5*J-2, K-2, L+3) 



ARRAYS AND SUBSCRIPTS 

An array is an ordered set of data that is referred 
to by a single name. Each individual element in the 
array is referred to by subscripting the name of the 
array, the subscript denoting the position of the ele- 
ment in the array. For example, assume that the 
following is an array named NEXT: 

15 
12 
18 
42 
19 

To refer to the second element in the group in ordi- 
nary mathematical notation, the form NEXT 2 might 
be used. In FORTRAN the form must be NEXT(2). 
Thus, NEXT(2) has the value 12 and NEXT(4) has the 
value 42. 

Similarly, an ordinary mathematical notation 
might use NEXT^ to represent any element of the 
array NEXT. In FORTRAN, this is written as 
NEXT(I) where I equals 1, 2, 3, 4, or 5. 

The array could be two-dimensional; for example, 
the array LIST: 



To refer to the number in row 2, column 3 
LIST 2 3 might be used in ordinary mathematical 
notation. In FORTRAN, the form LIST(2,3) would 
be used where 2 and 3 are the subscripts. Thus, 
LIST (2,3) has the value 14 and LIST (4,1) has the 
value 24. 

Ordinary mathematical notation uses LIST^ j to 
represent any element of the two-dimensional array 
LIST. In FORTRAN, this is written as LIST(I, J) 
where I equals 1, 2, 3, 4, or 5 and J equals 1, 2, or 
3. 

FORTRAN allows up to three subscripts (i. e. , 
three-dimensional arrays). For example, a three- 
dimensional array might be used to store statistical 
data on the urban and rural population of each state 
for a period of 10 decades. 

The use of an array in the source program must 
be preceded by either a DIMENSION statement, a 
COMMON statement, or a Type statement in order to 
specify the size of the array. The first reference to 
the array in one of these statements must specify its 
size (see Specification Statements) . 

NOTE FOR DM2 USERS: Be cautious when including 
arrays in DO loops. No error message is generated 
if the index of a DO loop uses the same variable as the 
subscript of an array in the DO loop and the value of the 
index exceeds the dimension of the subscript. 

ARRANGEMENT OF ARRAYS IN STORAGE 

Arrays are stored by column in descending storage 
addresses, with the value of the first of their 
subscripts increasing most rapidly and the value 
of the last increasing least rapidly. In other words, 
arrays are stored with element (1,1,1) in a higher 
core location than element (2,3,4). In scanning the 
array from element (1,1,1), the left indices are 
advanced more rapidly than those on the right. A 
one-dimensional array, J(5), in address 0508 
appears in storage as follows: 



Address 


Element 


0500 


J(5). 


0502 


J(4) 


0504 


J(3) 


0506 


J(2) 


0508 


J(l) 





COLUMN1 


COLUMN2 


COLUMN3 


ROW1 


82 


4 


7 


ROW2 


12 


13 


14 


ROW3 


91 


1 


31 


ROW4 


24 


16 


10 


ROW5 


2 


8 


2 



A two-dimensional array, K(5,3), appears in storage 
in single-array form in ascending storage addresses 
in the following order reading from left to right: 
K(5,3) K(4,3) K(3,3) K(2,3) K(l,3) 
K(5,2) K(4,2) K(3,2) K(2, 2) K(l,2) 
K(5,l) K(4,l) K(3,l) K(2,l) K(l,l) 
If K(5,3) is in core address 0200, K(l,l) will be in 
core address 0228 (assuming each element occupies 
two words). 



Constants, Variables and Arrays 5 



The following list is the order of a three- 
dimensional array, A(3,3,3): 

A(3,3,3) A(2,3,3) A(l,3,3) A(3,2,3) A(2,2,3) 
A(l,2,3) A(3,l,3) A(2,l,3) A(l,l,3) A(3,3,2) 
A(2,3,2) A(l,3,2) A(3,2,2) A(2,2,2) A(l,2,2) 
A(3,l,2) A(2,l,2) A(l,l,2) A(3,3,l) A(2,3,l) 
A(l, 3, 1) A(3, 2, 1) A(2, 2, 1) A(l, 2, 1) A(3, 1, 1) 
A(2,1,1)A(1,1,1) 



SUBSCRIPT FORMS 

Subscripts may take the following forms: 

v 

c 

v+c 

v-c 

c*v 

c*v+c' 

c*v-c' 

where: 

v represents an unsigned, nonsubscripted, 

integer variable. 

c and c' represent unsigned integer constants. 

The value of a subscript (including the added or 
subtracted constant, if any) must be greater than 



zero and not greater than the corresponding array 
dimension. Each subscripted variable must have the 
size of its array (i.e. , the maximum values that 
its subscripts can attain) specified in a DIMENSION, 
COMMON, or Type Statement. 

Examples; 

The following are valid subscripts: 

IMAX 

19 

JOB+2 

NEXT -3 

8*IQUAN 

5*L+7 

4*M-3 



The following are not valid subscripts: 



-I 

A+2 

1+2. 
-2* J 
1(3) 
K*2 



2+JOB 



(the variable may not be signed) 

(A is not an integer variable unless 

defined as such by a Type statement) 

(2. is not an integer constant) 

(the constant must be unsigned) 

(a subscript may not be subscripted) 

(for multiplication, the constant must 

precede the variable; thus, 2*K is 

correct) 

(for addition, the variable must precede 

the constant; thus, JOB+2 is correct) 



Page of GC26-37 15-8 
Revised February 1974 
ByTNLGN34-0181 



ARITHMETIC EXPRESSIONS 



Arithmetic Expressions appear on the right- 
hand side of Arithmetic Statements and in 
certain Control Statements. They are used to 
specify arithmetic computation. 

DEFINITION 

An Arithmetic Expression is a sequence of con- 
stants, variables, function names (see Sub- 
program Statements), and arithmetic operation 
symbols which obeys the rules set out below. 

COMPUTATIONAL MODES, INTEGER AND REAL 

Arithmetic computations are done in either of two 
modes, integer or real, depending on the type of the 
quantities, integer or real, involved in the compu- 
tation. All constants, variables, and functions that 
form an arithmetic expression need not be of the 
same type. 

THE MODE OF AN EXPRESSION 

The mode of an expression is integer, real, or 
mixed depending on whether its constants are of 
type integer, real, or are .mixed. 

INTEGER AND REAL MODE EXPRESSIONS 



Examples: 




Mode of 


Expression 


Type of Data 


Expression 


3 


Integer Constant 


Integer 


I+J 


Integer Variables 


Integer 


3.0 


Real Constant 


Real 


A 


Real Variable 


Real 


BILL+3. 6 
A(I) . 


Real Variable, 
Real Constant 
Real Variable 


Real 
Real 



In the last example, note that the subscript, which 
is always an integer quantity, does not affect the 
mode of the expression. The mode of the subscripted 
expression is determined solely by the mode of the 
variable. 



MIXED EXPRESSIONS 

In a mixed expression, the parts of the expression 
involving purely integer operations are computed 
in the integer mode. Then these integer results are 
converted to real values and the entire expression is 
computed in the real mode. Note that arithmetic 
operations involving variables that contain alphameric 
characters should be performed in the integer mode. 

For example, in the expression: 

A + (I* J) + (A / J) + 1**2 
I*J and 1**2 are computed in the integer mode and 
these results are then.converted to real values. 
However, the J in A/J will be converted to real 
before A/J is computed. 

Examples : The following are valid expressions. 



Expression 



Mode 



F 


Real 


5*JOB+ITEM/(2*ITAX) 


Integer 


5.*AJOB+BITEM/(2. *TAX 


Real 


J+l 


Integer 


A**I+B(J)+C(K) 


Real 


A**B 


Real 


I**J+K(L) 


Integer 


A+B(I)/ITEM 


Mixed 


Expression 


Mode 


DEV+I 


Mixed 


ITA**2. 5 


Mixed 


Rule: If a variable contains 


alphameric 



arithmetic operations involving the variable must be 
done in integer mode. 

Note: The computed value of an integer expression, 
or the integer part of a mixed expression, cannot 
lie outside the range -32768 through 32767. 
Overflow occurs if the value would otherwise 
exceed this range, that is, if the mathematical 
value of the expression exceeds the stated range. 



Expressions 7' 



Page of GC26-3715-8 
Revised February 1974 
ByTNLGN34-0181 



ARITHMETIC OPERATION SYMBOLS 



FORTRAN 



Symbol 



Means 



Example 



ORDER OF OPERATIONS 

Code a FORTRAN arithmetic expression so that if 
you evaluate it in the following order of operations, 
you get the desired result. 



+ 


plus 


A+B 


- 


minus, unary minus 


A-B, -A 


* 


multiplication 


A*B 


/ 


division 


A/B 


** 


exponentiation 


A**B 


Rules : 







1. Operators must not be adjacent to each other. 
They must be separated by quantities or paren- 
theses in the expression. For example, A+ -B 
is invalid, while -B +A or A +(-B) are valid. 

2. No operation symbol is assumed. For example, 
3 A will not be taken to mean 3*A. 

3. No quanitity is assumed. For example, an isolate 
minus sign (-) is never taken to mean minus one. 

4. The expression A**B**C is permitted and 
evaluated as A**(B**C). If exponentiation to a 
real power involves a negative base, the absolute 
value of the base will be used when performing 
the computation, and the result will be left in the 
absolute form. To preserve the base sign, an 
integer exponent must be used. 

USE OF PARENTHESES 

Parentheses may be used in arithmetic ex- 
pressions, as in algebra, to specify the order in 
which various arithmetic operations are to be per- 
formed. Expressions enclosed in parentheses 
are effectively isolated from other parts (if any) 
of the containing expression until their values are 
computed. Then they enter the larger computation 
with the status of a variable or constant. 

Redundant parentheses are allowed. Thus, A, (A), 
((A)) are all valid expressions. 
The mode of an expression's not changed by the 
use of parentheses. Within parentheses, or where 
parentheses are omitted, the order of operations 
is as follows: 

Note ; Parentheses may not be used to imply 
multiplication; the asterisk .arithmetic operator 
must always be used for this purpose. Therefore, 
the algebraic expression: 

(AxB) (-C D ) 

must be written as: 



1130 Order of Operations. Perform all operations 
on level 1, then go to level 2, etc. 

1. Evaluation of expressions enclosed in 
parentheses 

2. Evaluation of functions 

3. Exponentiation (right to left) 

4. Multiplication and division 

5. Addition, subtraction, and unary minus 



1800 Order of Operations. Perform all operations 
on level 1, then go to level 2, etc. 

1. Evaluation of expressions enclosed in 
parentheses 

2. Evaluation of functions 

3. Exponentiation (right to left) 

4. Unary minus 

5. Multiplication and division 

6. Addition and subtraction 



Coding Examples: 

3A 2 + 4 e C 
27 C 

(3*A**2 + 4*EXP (C))/(27*C) 
-4C 



; 



B 2 + C2 



(-4*C)/SQRT((B**2 + C**2)/2) 



+ A2 



(A - B)C 
B/((A-B)*C)+A**2 



Note : Coding redundant parentheses often helps to 
clarify your thinking and reduce errors. 



(A*B)*(-C**D) 



There are five classes of FORTRAN statements: 

1. Arithmetic Statements 

2. Control Statements 

3. Input/Output Statements 

4. Specification Statements 

5. Subprogram Statements 

Arithmetic Statements cause the values of Arithme- 
tic Expressions to be assigned to program variables 
during program execution. The major arithmetic 
calculations to be done by a program must be written 
as a series of Arithmetic Statements. 

Control Statements allow programmed control of the 
sequence of execution of program statements. The 
IF, DO, and Computed GO TO statements direct the 
sequence of execution of program statements accord- 
ing to current values of specified expressions. 

Input/ Output Statements are used to transmit infor- 
mation between the computer and input or output 
units. 

Specification Statements provide the Compiler with 
information about program variables, some storage 
requirements, and the names of sub-programs used 
by the program. 



Subprogram Statements 
subprograms. 



define linkage to and from 



STATEMENTS 



Examples: 

K = X + 2.5 

ROOT = (-B+(B**2-4. *A*C)**. 5)/(2. *A) 

ANS (I) = A(J) + B(K) 

In each of the above Arithmetic statements, the 
arithmetic expression to the right of the equal sign 
is evaluated, converted to the mode of the variable 
to the left of the equal sign (if there is a difference), 
and this converted value is stored in the storage 
location associated with the variable name to the left 
of the equal sign. 

In the first example, K=X+2. 5, assume that the 
current value of X is 232. 18. Upon execution of this 
statement, 2. 5 is added to 232. 18, giving 234. 68. 
This value is then truncated (because K is an integer 
variable) to 234, and this value replaces the value of 
K. If K were defined as a real variable by a Type 
statement, truncation would not occur and the value 
of K would be 234. 68. 



Examples: 

A = I 

A = B 

A = 3. *B 

I = B 



Convert I to real value and 

store it in A. 

Store the value of B in A. 

Multiply 3 by B and store the 

result in A. 

Truncate B to an integer and 

store it in I. 



ARITHMETIC STATEMENTS 



Arithmetic Statements have the following form: 

A = B where A is a variable and B 
is an Arithmetic Expression. 

The variable A may be either subscripted (e. g. A(I) , 
I an index variable) or single -valued. Arithmetic 
Statements are substitution statements , they cause 
a new value to be assigned to a variable during exe- 
cution. 

The above statement would cause the value of the 
expression B to be computed and assigned to the 
variable A. 

We may have the statement 1=1+1. This statement 
would cause the value of the variable I to be incre- 
mented by 1. 



CONTROL STATEMENTS 

The second class of FORTRAN statements is com- 
posed of control statements that enable the program- 
mer to control the course of the program. Normally, 
statements are executed sequentially; that is, after 
one statement has been executed, the statement 
immediately following it is executed. However, it 
is often undesirable to proceed in this manner. The 
following statements may be used to alter the 
sequence of a program. 



Statements 9 



UNCONDITIONAL GO TO STATEMENT 



Example: 



This statement interrupts the sequential execution of 
statements, and specifies the number of the next 
statement to be performed. 

General Form: 

GO TOn 

where 



GO TO (10, 20, 30, 40), ITEM 

In this example, if the value of ITEM is 3 at the 
time of execution, a transfer occurs to the statement 
whose number is third in the series (30). If the 
value of ITEM is 4, a transfer occurs to the statement 
whose number is fourth in the series (40), etc. 



n is a statement number. 

Examples: 

GO TO 25 
GO TO 63468 

The first example causes control to be transferred 
to the statement numbered 25; the second example 
causes control to be transferred to the statement 
numbered 63468. 



COMPUTED GO TO STATEMENT 

This statement also indicates the statement that is 
to be executed next. However, the statement number 
that the program is transferred to can be altered 
during execution of the program. 

General Form: 



GO TO (n 1 , n 2 , ..., n m ), i 
where: 



n , n , . . . ,n are statement numbers and 
i is a non-subscripted integer variable whose 
value is greater than or equal to 1 and less than 
or equal to the number of statement numbers 
within the parentheses. 

This statement causes control to be transferred 
to statement nj, n2, . . . ,n m , depending on whether 
the current value of i is 1, 2, . . . , or m, respectively. 

NOTE: If i>m or i<l, the results are unpredictable. 
Under the 1800 TSX and MPX Systems an execution 
error results and the program is aborted. 



IF STATEMENT 

This statement permits the programmer to change the 
sequence of statement execution, depending upon the 
value of an arithmetic expression. 

General Form: 

IF (a) n r n 2 , n g 

where: 

a is an expression and n^, n 2 , and n3 are state- 
ment numbers. The expression, a, must be 
enclosed in parentheses; the statement numbers 
must be separated from one another by commas. 

Control is transferred to statement ni, n2, or n3 
depending on whether the value of a is less than, 
equal to, or greater than zero, respectively. 



Example: 



10 
12 
72 



IF ((B+C)/(D**E)-F) 12, 72, 10 



which means: if the result of the expression is less 
than zero, transfer to the statement numbered 12; 
if the result is zero, transfer to 72; otherwise, 
transfer to the statement numbered 10. 

DO STATEMENT 

The ability of a computer to repeat the same opera- 
tions using different data is a powerful tool that 
greatly reduces programming effort. There are 
several ways to accomplish this when using the 



10 



Page of GC26-37 15-8 
Revised February 1974 
ByTNLGN34-0181 



FORTRAN language. For example, assume that a 
manufacturer carries 1,000 different parts in 
inventory. Periodically, it is necessary to compute 
the stock on hand of each item (STOCK) by sub- 
tracting stock withdrawals of that item (OUT) from 
the previous stock on hand. These results could be 
achieved by the following statements: 



5 

10 

25 

15 

30 



1=0 

1=1 + 1 

STOCK (I) = STOCK (I) - OUT (I) 

IF (1-1000) 10, 30, 30 



The three statements (5, 10, 15) required to 
control this loop could be replaced by a single DO 
statement. 



25 
General Form: 



DO 25 1 = 1, 1000, 1 
STOCK(I) = STOCK(I) - OUT(I) 



DO n i = m , m 

J. di 



or 



DO n i = m^ m 2> m g 
where: 

n is a statement number. 

i is a nonsubscripted integer variable. 

m^, m2, m3 are unsigned integer constants or 
nonsubscripted integer variables. If 1113 is 
not stated (it is optional), its value is assumed 
to be 1. In this case, the preceding comma 
must also be omitted. 

Examples : 

DO 50 1 = 1, 1000 
DO 10 I = J, K, L 
DO 11 I = 1, K, 2 

The DO statement is a command to repeatedly 
execute the statements that follow, up to and including 
the statement n. The first time the statements are 
executed, i has the value mi, and each succeeding 



time, i is increased by the value of 1113. After the 
statements have been executed with i equal to the 
highest value that does not exceed m2, control passes 
to the statement following statement number n. This 
is called a normal exit from the DO statement. 

The range limit (n) defines the range of the DO. 
The range is the series of statements to be executed 
repeatedly. It consists of all statements following 
the DO, up to and including statement n. The range 
can consist of any number of statements. 

The index (i) is an integer variable that is incre- 
mented for each execution of the range of statements. 
Throughout the range of the DO, the index is available 
for use either as a subscript or as an ordinary integer 
variable. When transferring out of the range of the 
DO, the value of the index is equal to the last value 
it attained. 

The initial value (m^) is the value of the index 
for the first execution of the range. The initial 
value cannot be equal to zero or negative when 
specified as an integer constant. 

The test value (m2) is the value against which 
the index is tested. The index is incremented and 
compared with the test value at the end of the range; 
therefore, a DO loop will always be executed at 
least once. If the index is less than or equal to the 
test value,' the loop will be executed again. If the 
index exceeds the test value, the next sequential 
instruction following the DO loop will be executed. 

The increment (1113) is the amount by which the 
value of the index will be increased after each 
execution of the range. The increment may be omit- 
ted, in which case it is assumed to be 1. 

Example: 





DO 25 1=1, 10 


5 


. 


10 


. 


15 


. 


20 


. 


25 


A=B+C 


26 


9 



This example shows a DO statement that will 
execute statements 5, 10, 15, 20, and 25 ten times. 
Upon each execution, the value of I will be increment- 
ed by 1 (1 is assumed when no increment is specified). 
After completion of the DO, statement 26 is executed. 

On exit from the DO loop, the value of the index 
variable I exceeds the test value (In the above 
example it then has the value 11). 

Variable I may be used elsewhere in the program. 
However, if variable I has been used as both the 



Statements 1 1 



Page of GC26-37 15-8 
Revised February 1974 
ByTNLGN34-0181 

index of the DO loop and as an array subscript 
within the DO loop, and if the DO loop ends with a 
CONTINUE statement, the value of I as a subscript 
to an array outside the loop will equal the last 
value it reached within the loop before the index 
exceeded the test value. On the other hand, if the 
DO loop does not end with a CONTINUE statement, 
the value of I as an array subscript outside the loop 
will be unpredictable. 

In some cases, the DO is completed before the 
test value is reached. Consider the following: 

D0 5K=1,9,3 

In this example, the range is executed three times 
(i. e. , K equal to 1, 4, and 7). The next value of K 
would be 10. Since this exceeds the test value, the 
DO is completed after three iterations. 

Restrictions. The restrictions on statements in the 

range of a DO are: 

1. Within the range of a DO may be other DOs. 
When this is so, all statements in the range of 
the inner DO must be in the range of the outer 
DO. A set of DOs satisfying this rule is called 
a nest of DOs. The maximum depth of a single 
nest of DOs is 25. For example, the following 
configuration is permitted (brackets are used to 
indicate the range of the DOs) : 



DO 
DO 
DO 



but, the following configuration is not permitted: 



DO 
DO 



2. 



3. 



A transfer out of the range of any DO loop is 
permissible at any time. A transfer into a DO 
range is permissible only as described in item 3. 
When a transfer is made out of the range of the 
innermost DO loop, a transfer back into the 
range of that loop is allowed if, and only if, 
neither the index nor any of the indexing param- 
eters (i.e. , m 1? m2, ni3) are changed outside 
the range of the DO loop. This transfer back 
into a DO loop is permitted only to the innermost 
DO loop. A transfer back into the range of any 
other DO in the nest of DOs is not permitted. 
The following illustrations show those transfers 
that are valid and those that are invalid. 





VALID 




INVALID 




► 




^ 











■*-> 


£-^C 






- - - -"i ) 












i— — _-j 



*Return (opposite of arrow direction) is also permitted 
if no indexing parameters are changed. 



4. The last statement in the range of a DO loop 
must not be a GO TO, IF, STOP, PAUSE, 
FORMAT, RETURN, or another DO statement. 

5. Any statement that redefines the value of the 
index or any of the indexing parameters (i. e: , 
mj, m2, n^) is liable to alter the logic of the 
execution of the DO loop. This logic is 
governed by the index and parameters. These 
variables are used throughout the execution of 
the DO loop to control the number of times the 
loop is executed. 



CONTINUE STATEMENT 



The CONTINUE statement is a dummy statement that 
does not produce any executable instructions. It can 
be inserted anywhere into a program; it simply in- 
dicates that the normal execution sequence continues 
with the statement following. 

General Form: 

CONTINUE 

The CONTINUE statement is principally used as 
the range limit of DO loops in which the last state- 
ment would otherwise be a GO TO, IF, PAUSE, 
STOP, or RETURN statement. It also serves as a 
transfer point for IF and GO TO statements within 
the DO loop that are intended to begin another 
repetition of the loop. An example of these two 
functions follows: 

DO 30 I = 1,20 
D =D + 5.0 
7 IF (A - B) 10,30,30 

10 A=A+1.0 

B = B - 2.0 
GO TO 7 
30 CONTINUE 

40 C =A +B 



A CONTINUE statement used as the range limit 
of any number of DO loops is compiled as an exe- 
cutable instruction, as in the example that follows: 



12 



30 



DO 30 I = 1,10 
DO 30 J = 2,19 
DO 30 K = 1,10,3 

CONTINUE 



The above statements will be replaced by object 
code equivalent to: 



XI 



X2 



X3 



30 



X4 



X5 



X6 



1 = 1 



J = 2 



K = 1 



K =K +3 

IF (K - 10) X3, X3, X4 

J = J +1 

IF (J - 19) X2, X2, X5 

1 = 1+1 

IF (I - 10) XI, XI, X6 



If a CONTINUE statement serves as the range 
limit of a DO loop, it must not be used as the 
transfer point for IF or GO TO statements which 
are outside the DO loop. If it serves as the range 
limit of several DO loops, as above, it must not 
be used as the transfer point for IF or GO TO 
statements which are outside the innermost loop. 

PAUSE STATEMENT 
General Form: 

PAUSE 

or 
PAUSE n 
where: 

n is an unsigned decimal integer constant whose 

value is equal to or less than 9999. 

The PAUSE statement causes the program to stop 
on a Wait instruction. To resume execution the 
START key must be pressed. Execution starts with 
the next executable statement following the PAUSE 
statement. If n is specified, it is treated as a 
hexadecimal number and displayed on the console in 
the accumulator (A -register in the IBM 1800) lights. 



STOP STATEMENT 

General Form: 

STOP 

or 
STOP n 

where: 
n is an unsigned decimal integer constant whose 

value is equal 'to or less than 9999. 

The STOP statement terminates program execu- 
tion. If n is specified it is treated as a hexadecimal 
number and displayed on the console in the accumula- 
tor (A -register in the IBM 1800) lights. 

In FORTRAN under the IBM 1130 Disk Monitor 
Systems, the IBM 1800 TSX and MPX Systems, 
the STOP statement is equivalent to a PAUSE state- 
ment followed by a CALL EXIT statement. Under 
the IBM 1800 TSX and MPX Systems, the STOP 
statement is valid only in nonprocess programs. 

END STATEMENT 
General Form: 

END 

The END statement defines the end of a program 
or subprogram for the compiler. Physically, it 
must be the last statement of each program or sub- 
program. The END statement is not executable. 
Any source program statements following the END 
statement will not be compiled. 

CALL STATEMENT 

The CALL statement is used only to call a 
SUBROUTINE subprogram. 

General Form: 



CALL name (a l( a n) a n) ...a ) 
l 2 3 n 

where: 

name is the symbolic name of a SUBROUTINE 

subprogram, 
a^, a£, a3, . . . a n are the actual arguments that are 

being supplied to the SUBROUTINE subprogram. 

Examples: 

CALL MATMP (X, 5,40, Y, 7, 2) 
CALLQDRTI(X,Y,Z,ROOTl, ROOT2) 

The CALL statement transfers control to the 
SUBROUTINE subprogram and replaces the dummy 
variables with the values of the actual arguments 
that appear in the CALL statement. The arguments 
in a CALL statement may be any of the following: 
any type of constant, any type of subscripted or 



Statements 13 



nonsubscripted variable, any other kind of arithmetic 
expression, or a subprogram name (except that they 
may not be statement function names). 

A subprogram named as an argument in a CALL 
statement must also be named in an EXTERNAL state- 
ment in the calling program. Such a subprogram 
must be a CALL-type, rather than an LIBF-type, 
subprogram. 

The arguments in a CALL statement must agree 
in number, order, and type with the corresponding 
arguments in the SUBROUTINE subprogram. 

Note that a constant should be specified as an 
actual argument only when the programmer is cer- 
tain that the corresponding dummy argument is not 
assigned a value in the subprogram. For example: 
Calling SUBROUTINE 

Program Subprogram 



CALL JOE (5,6) 



SUBROUTINE JOE (K,M) 

K=M + 10 

RETURN 

END 



100 N=5 



In this case the constant 5 in the calling program 
is replaced by the value of K as computed in the 
subroutine (K=M +10). Subsequent execution 
of statement 100 in the calling program results 
in the variable N being assigned a value other 
than 5. 

For descriptions of the SUBROUTINE sub- 
programs that can be called in FORTRAN under 
the IBM 1130 and 1800 Programming Systems, 
see the appropriate Subroutine Library publica- 
tion as listed in the Preface , above. 

SPECIAL CALL STATEMENTS 

CALL EXIT Statement 

In FORTRAN under the IBM 1130 Disk Monitor 
Systems, the CALL EXIT statement is used 
when control is to be returned to the Supervisor 
portion of the system. 

In FORTRAN under the IBM 1800 TSX System, the 
CALL EXIT statement is used when control is to be 
returned to the Supervisor portion of the Nonprocess 
Monitor. The CALL EXIT statement is therefore 
valid only in nonprocess programs. 

For use of CALL EXIT in the MPX System see 
IBM 1800 Multiprogramming Executive Operating 
System Programmer's Guide . The CALL EXIT 
statement is not valid in FORTRAN under the IBM 
1130 and 1800 Card/Paper Tape Programming 
Systems. 



CALL LINK Statement 

The CALL LINK statement is used when control is 
to be transferred from one program (link) to the next. 

General Form: 



CALL LINK (Name) 

where: 

Name is the name of the program to be loaded 
into core storage and given control. The pro- 
gram name consists of 1-5 alphameric charac- 
ters (excluding special characters) the first of 
which must be alphabetic. 

The link program that is called is loaded with all 
subprograms and library subroutines that it refer- 
ences. Any link called by this statement must 
already be in disk storage. If the logic of the pro- 
gram allows any one of several links to be called, 
it is necessary that all of the link programs be in 
disk storage prior to execution. 

Note: Link programs called under the IBM 1800 
TSX and MPX Systems must be in disk storage in 
core image format. 

The COMMON area of the program relinquishing 
control is not destroyed during the loading of the link 
program. If the size of COMMON differs between 
programs, the COMMON area size that remains 
undisturbed is determined by the link program called. 

In FORTRAN under the IBM 1800 Time-Sharing 
Executive System, the CALL LINK statement is 
valid only in nonprocess programs. Also, the name 
specified in the CALL LINK statement may be the 
name of a nonprocess program only. 

The CALL LINK statement is not valid in the IBM 
1130 and 1800 Card/Paper Tape Programming 
Systems. For use of CALL LINK in the 1800 MPX 
System see IBM 18 00 Multiprogramming Executive 
Operating System Programmer's Guide . 



CALL LOAD Statement 



The CALL LOAD statement , which is valid only in 
FORTRAN for the card forms of the IBM 1130 and 
1800 Card/Paper Tape Programming Systems, is used 
to link to another program without requiring the core 
image loader to precede the link program. CALL 
LOAD causes the next program in the card reader to 
be read in and executed. 



14 



Page of GC26-37 15-8 
Added February 1974 
ByTNLGN34-0181 



For example: 



CALL LOAD 

STOP 

END 

The CALL LOAD statement may only be used in a 
core image program and may only call a core image 
program. (See the description of the *SAVE 
LOADER control record in the appropriate corequisite 
publication, as listed in the Preface, above.) 



CALL PDUMP Statement 

In FORTRAN for the IBM 1130 Disk Monitor System, 
Version 2, the dump program PDUMP can be called 
to print the contents of one or more parts of core 
storage. 

General Form: 



CALL PDUMP (a., b , f , , a , b , f ) 

l i i n n n' 

where: 



aj and b[ are variable data names, subscripted 
or non-subscripted, indicating the inclusive 
limits of a block of core storage to be dumped. 
Even though either a- or b. can indicate the upper 
or lower limit of the block 1 to be dumped, they do not 
affect how the block is dumped (just the limits). How 
the block is dumped depends on f.. 

f is an integer constant indicating the format and 
how the block is dumped (high-core address to low- 
core address or vice versa), fj is specified as 
follows: 



Tips and Techniques for PDUMP Usage : 

1. To dump a single value, specify the variable or 
constant name as both a^ and bi. 

Example : 

CALL PDUMP (1, 1, 4) Dump the value of I in 

integer format. 

2. To dump a subscripted array, specify the first 
element in the array as ai and the last element 
in the array as bi. 

Example : 

CALL PDUMP (A(l,l), Dump the array 
A(10,10),5) A(10, 10) in real 

format. 

3. To obtain a dump from the beginning of your 
program to the end of core, assign a variable 
to COMMON (example: COMMON IN). This 
variable should be the first (or only) variable 
in your COMMON list. Specify the first 
variable or constant name that appears in your 
program as aj, and specify the value in 
COMMON as bi. 



Example : 

CALL PDUMP (I, IN, 0) 



Dump the contents of 
core storage from the 
beginning of your 
program to the end of 
core. 



f. Format How dumped 

0~ Hexadecimal low to high 

4 Integer high to low 

5 Real high to low 

Note: If any of the variables a. , b. appear in 
CALL PDUMP before appearing elsewhere in the 
program, their relative locations in storage are 
affected by the call to PDUMP. 



Statements 14. 1 



Page of GC26-37 15-8 
Added February 1974 
ByTNLGN34-0181 



This page intentionally left blank 



14.2 



MACHINE AND PROGRAM INDICATOR TESTS 

The FORTRAN language provides machine and pro- 
gram indicator tests even though some of the machine 
components referred to by the tests do not physically 
exist. The machine indicators that do not exist are 
simulated by subroutines provided in the system 
library. 

To use any of the following machine and program 
indicator tests, the user supplies the proper argu- 
ments and writes a CALL statement. In the following 
listing, i is an integer expression; j and k are integer 
variables. 

General Form and Function 

CALL SLITE (i) If i = 0, all sense lights are 
turned off. If i = 1,2,3, or 4, the correspond- 
ing sense light is turned on. 

CALL SLITET (i,j) Sense light i (equal to 1, 2, 3, 
or 4) is tested. If i is on, j is set to 1; if i is 
off, j is set to 2. After the test, sense light 
i is turned off. 

CALL OVERFL (j) This indicator is on if an 
arithmetic operation with real variables and/or 
constants results in an overflow or underflow 
condition; that is, j is set to 1 if the absolute 
value of the result of an arithmetic operation 
is greater than 2 (10 38 ); j is set to 2 if no 
overflow condition exists; j is set to 3 if the 
result of an arithmetic operation is not zero 
but less than 2" 129 (10~ 39 ). The machine is 
left in a no overflow condition. 



Page of GC26-37 15-8 
Revised February 1974 
ByTNLGN34-0181 

CALL SSWTCH (i, j) Sense switch i is tested. 
If i is on, j is set to 1; if i is off, j is set to 
2. 

This CALL is valid only in FORTRAN 
under the IBM 1800 Card/Paper Tape Pro- 
gramming System, and the IBM 1800 TSX 
and MPX Systems. 

CALL DVCHK (j) This indicator is set on if an 
arithmetic operation with real constants and/or 
variables results in the attempt to divide by 
zero. If the indicator is on, j is set to 1; if 
off, j is set to 2. The indicator is set off after 
the test is made. 

CALL DATSW (i, j) Data entry switch i is tested. 
If data entry switch i is on, j is set to 1; if 
data entry switch i is off, j is set to 2. 

Note; For the 1130, the Data Entry switches are 
the same as the Console Entry switches. This is 
not true of the 1800. 

CALL TSTOP The TSTOP subroutine may be 
used to stop the tracing mode if trace control 

. has been specified to the compiler by the use of 
a trace FORTRAN Control Card. 



Statements 15 



CALL TSTRT The TSTRT subroutine may be 
used to re-establish the trace mode if trace 
control has been specified to the compiler. 



Tracing occurs only if 

1. A trace control card was compiled with the 
source program, see the appropriate Opera- 
ting Procedures manual. 

2. Data Entry switch 15 is on (it can be turned 
off at any time) . 

3. A CALL TSTOP has not been executed, or a 
CALL TSTRT has been executed since the last 
CALL TSTOP. 



CALL FCTST (j, k) The FCTST subroutine 
checks an indicator word that is set on if a 
FORTRAN-supplied FUNCTION subprogram 
detects an error or an end-of-file condition 
is detected during an unformatted I/O opera- 
tion, k is set to the value of the indicator 
word. If the indicator word is zero, j is set 
to 2; otherwise, j is set to 1. The indicator 
word is set to after the test. 

NOTE: SSWTCH, SLITET, and OVERFL contain six 
characters in order to be compatible with other IBM 
FORTRANs; SSWTCH, SLITET, and OVERFL are 
changed by the FORTRAN compiler to SSWTC, 
SLITT, and OVERF, respectively. 

Examples: 

CALL SLITE (3) 
CALL SLITET (K*J,L) 
CALL OVERFL (J) 
CALL DVCHK (I) 
CALL SSWTCH (I, J) 
CALLDATSW(15,N) 
CALL TSTOP 
CALL TSTRT 
CALL FCTST (IM, JM) 

As an example of how the sense lights can be 
used in a program, assume that it is desired to 
continue with the program, without writing results, 
if sense light 3 is ON, and to write results , before 
continuing, if sense light 3 is OFF. This can be 
accomplished by using the IF statement or a Com- 
puted GO TO statement, as follows: 



CALL SLITET (3, KEN) 
5 IF (KEN-2) 10,9,10 
9 WRITE (3,36) (ANS(K),K=1, 10) 



10 



24 
25 
26 



CALL SLITET (3, KEN) 

GO TO (26,25), KEN 

WRITE (3,36) (ANS(K) , K=l , 1 0) 



In statement 5, if KEN is not equal to 2, statement 
9 is not executed. In statement 24, if KEN equals 2, 
statement 25 is executed. 

INPUT/OUTPUT STATEMENTS 



The input/output (I/O) statements control the trans- 
mission of information between the computer and the 
I/O units. On the IBM 1130 Computing System these 
units are: 2310 Disk Storage; 1442 Card Read Punch, 
Models 6 and 7; 1442 Card Punch, Model 5; 2501 
Card Reader; 1132 Printer; 1403 Printer; 1134 Paper 
Tape Reader; 1055 Paper Tape Punch; Console 
Printer; Keyboard; and 1627 Plotter. On the IBM 
1800 Data Acquisition and Control System these units 
are: 1810 Disk Storage; 2401 and 2402 Magnetic Tape 
Units; 1442 Card Read Punch, Models 6 and 7; 1053 
Printer; 1443 Printer; 1054 Paper Tape Reader; 
1055 Paper Tape Punch; 1816 Printer Keyboard; 
and 1627 Plotter. 

I/O statements are classified as follows: 

1. Non-disk I/O Statements. These statements 
cause transmission of formatted information 
between the computer and I/O units other than 
the disk. They are READ and WRITE. 

2. Disk I/O Statements. These statements cause 
transmission of information between the com- 
puter and the disk. They are READ, WRITE, 
and FIND. 

3. Unformatted I/O Statements. These statements 
cause transmission of unformatted information 
as follows: 

a) under the IBM 1800 Card/Paper Tape Pro- 
gramming and TSX Systems: between the 
computer and magnetic tape units in FORTRAN; 

b) under the IBM 1800 MPX System: between the 
computer and magnetic tape units or disk storage 
units; 

c) under the IBM 1130 Disk Monitor System, Ver- 
sion 2: between the computer and a special disk 
area for the simulation of magnetic tape I/O in 
FORTRAN. 

These statements are READ and WRITE. 

4. Manipulative I/O Statements . These statements 
manipulate magnetic tape units in FORTRAN 
under the IBM 1800 Card/Paper Tape Program- 



16 



ming System, the IBM 1800 TSX and MPX Sys- 
tems; they manipulate the unformatted I/O area 
on disk in FORTRAN under the IBM 1130 Disk 
Monitor System, Version 2. These statements 
are BACKSPACE, REWIND, and END FILE. 
5. FORMAT Statements. These are nonexecutable 
statements that specify the arrangement of the 
data to be transferred, and the editing transfor- 
mation required between internal and external 
forms of the data. The FORMAT statements are 
used in conjunction with the non-disk I/O state- 
ments. 

NON-DISK I/O STATEMENTS 
READ Statement 

The READ statement is used to transfer information 
from any input unit to the computer. Two forms of 
the READ statement may be used, as follows: 

READ (a,b) List 

or 
READ (a,b) 

where: 

a is an unsigned integer constant or integer 
variable that specifies the logical unit number 
to be used for input data (see Logical Unit 
Numbers ), 
b is the statement number of the FORMAT state- 
ment describing the type of data conversion. 

List is a list of variable names, separated by 
commas, for the input data. 

The READ (a,b) List form is used to read a 
number of items (corresponding to the variable 
names in the list) from the file on unit a, using 
FORMAT statement b to specify the external re- 
presentation of these data (see FORMAT Statement) . 

The List specifies the number of items to be 
read and the locations into which the items are to 
be placed. For example, assume that a card is 
punched as follows: 

Card Columns Contents 



1-2 


25 


5-7 


102 


61-64 


-101 


70-71 


10 


80 


5 



If the following statements appear in the source 
program: 

READ (2,25) I,J,K,L,M 

25 FORMAT(I2, 2X, 13, 53X, 14, 5X, 12, 8X, II) 

the card is read (assuming that 2 is the unit number, 
associated with the card reader) , and the program 
operates as though the following statements had 
been written: 

I =25 
J =102 
K = -101 
L = 10 

M = 5 

After the next execution of the READ statement, 
I, J,K,L, and M will have new values, depending 
upon what is punched in the next card. read. 

Any number of quantities may appear in a single 
list. Integer and real quantities may be transmitted 
by the same statement. 

If there are more quantities in an input record 
than there are items in the list, only the number of 
quantities equal to the number of items in the list 
are transmitted; remaining quantities are ignored. 
Thus, if a card contains three quantities and a list 
contains two, the third quantity is lost. Conversely, 
if a list contains more quantities than the number of 
input records, succeeding input records are read 
until all the items specified in the list have been 
transmitted. 

When an array name appears in an I/O list in non- 
subscripted form, all of the quantities in the array 
are transmitted in column order (see Arrangements 
of Arrays in Storage) . For example, assume that A 
is defined as an array of 25 quantities. Then, the 
statement: 

READ (2, 15) A 

causes all of the quantities A(l), . . . , A(25) to be read 
into storage (in that order) with an appropriate 
FORMAT statement. 

The READ (a,b) form may be used in conjunction 
with a FORMAT statement to read H-type alphameric 
data into an existing H-type field in core storage (see 
Conversion of Alphameric Data) . The size of the 
data field determines the amount of data to be read. 
For example, the statements: 



Statements 17 



10 FORMAT (23HTHIS IS ALPHAMERIC DATA) 



READ (INPUT, 10) 

cause the next 23 characters to be read from the file 
on the unit named INPUT and placed into the H-type 
alphameric field whose contents were: 

THIS IS ALPHAMERIC DATA 
WRITE Statement 

The WRITE statement is used to transfer information 
from the computer to any of the output units. Two 
forms of the WRITE statement may be used, as 
follows: 

WRITE (a,b) List 

or 
WRITE (a,b) 

where: 

a is an unsigned integer constant or integer vari- 
able that specifies the logical unit number to 
be used for output data (see Logical Unit 
Numbers) . 

b is the statement number of the FORMAT state- 
ment describing the type of data conversion. 

List is a list of variable names separated by 
commas for the output data. 

The WRITE (a,b) List form of the WRITE state- 
ment is used to write the data specified in the list on 
the file on unit a, using FORMAT statement b to 
specify the data format (see FORMAT Statement ). 

NOTE 1: The 1442 Card Read Punch, Model 6 or 7, 
has one input hopper. Therefore, if a READ or 
WRITE statement references a 1442-6 or -7, care 
should be taken to avoid punching a card that was 
only meant to be read or reading a card that was 
only meant to be punched. 

NOTE 2: If the first I/O operation is a WRITE to 
the 1442 Card Read Punch, Model 6 or 7, and the 
1442 contains cards that are not to be punched, one 
of the following two options may be used to avoid 
punching the cards remaining in the 1442: 

Option 1. Stack no cards behind the last card to 



be read. This causes an interrupt to occur when 
the WRITE is encountered. The cards remaining 
in the 1442 can then be run out (NPRO) and blank 
cards placed in the hopper before the WRITE 
is executed. 

Option 2. Place blank cards behind the last card 
to be read; in addition, include in the program, as 
the first I/O operation, a dummy READ such as 

READ (a,b) 

where a is the logical unit number of the 1442 
and b is the statement number of any FORMAT 
statement in the program that does not contain 
an H or apostrophe type of specification. The 
dummy READ causes the last cards read to be 
fed through the 1442 and the first blank card to 
be positioned for punching. The WRITE to the 
1442 can then be executed. 

Option 2 is preferable since it allows uninterrupted 
execution and requires no operator intervention. 

The WRITE (a, b) form is used to write alphameric 
data (see Conversion of Alphameric Data) . The 
actual data to be written is specified within the 
FORMAT statement; therefore, an I/O list is not 
required. The following statements illustrate the 
use of this form: 

25 FORMAT (24HWRITE ANY DATA IN H TYPE) 



WRITE (2,25) 



DISK I/O STATEMENTS 

The generalized READ and WRITE statements and the 
FIND statement for disk I/O appear as: 

READ (a'b) List 
WRITE (a'b) List 
FIND (a'b) 

where: 

a (an unsigned integer constant or integer variable) 

is the symbolic file number, 
b (an integer expression) is the record number 

where transmittal will start, and 
List is a list of variable names, separated by 

commas, for the input or output data. 

Note that the symbolic file number and record number 
(a and b) must be separated by an apostrophe. 



18 



An example is: 

READ (IFILE'200) OUTX, OUTY, OUTZ 

Note: Only information that requires no data 
conversion can be transmitted to and from disk 
storage. 

The READ (a'b) List form is used to read infor- 
mation from the disk. The List specifies the number 
of items to be read and the locations into which the 
items are to be placed. It functions the same as the 
List in the non-disk I/O READ/WRITE statements. 
For example, assume a file defined as: 



DEFINE FILE 3 (400, 2, U, K) 
contains the following information: 



RECORD NUMBER 

253 
254 
255 



CONTENTS 
Word 1 Word 2 



4800 
5000 
6800 



0084 
0084 
0084 



Then, if X, Y, and Z are two-word standard 
precision real variables, 

READ (3'253) X, Y, Z 

would result in the following values being read into 
X, Y, and Z: 

X = 48000084 

Y = 50000084 
Z = 68000084 

or, converting from binary to decimal: 

X = 9.0 

Y = 10.0 
Z =■ 13.0 

As is the case in the non-disk I/O statements, if 
there are more quantities in an input file than there 
are items in the list, only the number of items in the 
list are transmitted. Thus, in the above example, 
only records 253, 254, and 255 were transmitted; 
the rest were ignored. If a list contains more 
quantities than the input file, an error results. 

Variables within an I/O list may be indexed and 
incremented in the same manner as with a DO state- 
ment. For example, if we have: 



DIMENSION X(400) 

DEFINE FILE 3(400, 2, U, K) 



READ (3*1) (X(I), 1-1,5) 



records 1 through 5 of file 3 will be read into the 
first 5 elements of the array X (see Indexing I/O 
Lists) . 

The WRITE (a'b) List form operates in the same 
way as the READ (a'b) List statement and is used to 
transmit data to the disk. 

The purpose of the FIND statement is to move the 
disk read/write mechanism to the specified record. 
The use of the FIND statement is optional. 

The user should be aware that disk operations, 
such as calls to LOCAL subprograms on the same 
disk drive, may move the access mechanism and 
nullify the effect of the FIND statement. Therefore, 
in certain cases there may be no advantage to a 
FIND statement preceding a READ or WRITE state- 
ment. The following examples illustrate the use of 
disk I/O statements. 

For the IBM 1800 MPX, the FIND will function 
for the 1810 drives whether the drive is a physical 
1810 drive or mapped to a 2311 disk drive. If the 
symbolic file number refers to a 2311 data set, the • 
FIND statement will have no effect. 

Example: The following program reads real 
values, in standard precision, from 10 cards and 
writes them on a predefined disk file that 
occupies one sector. In this example, the logical 
unit number of the card reader is 2. 

DIMENSION A(10) 

DEFINE FILE 4 (10, 20, U, J) 

J=l 

DO 5 1=1,10 

READ (2,100)A 
100 FORMAT (10F8.0) 
WRITE (4 'J) A 
5 CONTINUE 
CALL EXIT 
END 

Note: For the FORMAT statement see F-Conversion 
on page 24. 

The following program will read the disk file 
written by the program above and print the results 



Statements 19 



where a typical data card may be: 



4SE 



10 



12.0 



123.01 
I 



230.11 125.43 



0000000000000000000000000000000|000000|00000000|000000|0000000|00000|00000000000 
i } ) 4 i i ) i i it n i! n 14 1! it i; ii t) 20 ii n n » ;i h n a a » li » » m is k u n » « «i « « u « « <i m « so si smj si ss st s> si si h ti u u h h « n u « 70 n n a » is « ir ;i n to 

iriiiiiiiiiiiiiiiiiiiiiiiitiii|iii>ii|t|iiii|iii]iiiiiiiii|itii|iiiiit||ii|iiiii 

2222 22222222 22|22 222 22 2|222222 22 2222|2 2222222|222 2 222|2 222 2|222222|2222 2 222|2222 
33333||333333|3|3333333 3333333333 333 3333333333| 33333 33 3 |3333||33333|3|333 3333|3| 
444444444444444444444|444444444444444444444444 4 4 4444444444444444444444<4444444|4 

5555555|5 5555555555555|5 555 55 555 55 55 55 55555 55 5 5555555 55555 5 55 55 5 5555555 5 5555|55 3 
C66666666666|6E666(666666666666666666S6666E66666666S6666666666SG6S6666666666666G 
7777|777777 7 7777777777777777777777777 77777777777777777777777777 777777 7777777777 7 
8B888|888888888|8888B88888888B8888888888888888|8B8888S8|88888|8888888|8388888|88 

S39S 3 



on the printer (logical unit number 3). Note that 
since the same data file is used by both programs, 
the file numbers in the two DEFINE FILE statements 
must both refer to this file. 

DIMENSION A(10) 
DEFINE FILE 4(100, 2, U,K) 
K=l 

DO 5 1=1,10 
READ (4'K)A 
WRITE (3, 100) A 
100 FORMAT (6F20. 8) 
5 CONTINUE 
CALL EXIT 
END 

In this case, every time the WRITE statement is 
executed one line with six numbers and one line 
with four numbers will be printed. 

UNFORMATTED I/O STATEMENTS 

The READ and WRITE statements for unformatted 
I/O, i.e., I/O without data conversion, appear as: 



The READ (a) List form is used to read a core- 
image record, without data conversion, into core 
storage from unit a. No FORMAT statement is 
required; the amount of data that is read corresponds 
to the number of list items. The total length of the 
list of variable names must not be longer than the 
logical record length. If the length of the list is 
equal to the logical record length, the entire record 
is read. If the length of the list is shorter than the 
logical record length, the unread items in the record 
are skipped. 

The READ (a) form is used to skip an unedited 
record on unit a. 

The WRITE (a) List form is used to write a core- 
image record, without data conversion, on unit a. 

For detailed information concerning the creation 
and use of the unformatted I/O area under the IBM 
1130 Disk Monitor System, Version 2, see the 
corequisite publication for that system as listed 
in the Preface . 

For the specific use of unformatted I/O for MPX, 
see IBM Multiprogramming Executive Operat- 
ing System Programmer^ Guide . 



READ (a) List 
READ (a) 
WRITE (a) List 



where: 



a is an unsigned integer constant or integer 
variable that specifies a logical unit number to 
be used for I/O data (see Logical Unit 
Numbers). 



List is a list of variable names, separated by 
commas, for the I/O data. 



INDEXING I/O LISTS 



Variables within an I/O list may be indexed and 
incremented in the same manner as with a DO state- 
ment. For example, suppose it is desired to read 
data into the first five positions of the array A. This 
may be accomplished by using an indexed list, as 
follows: 

READ (2,15) <A(I), 1=1,5) 
15 FORMAT (F10.3) 



20 



Page of GC26-37 15-7 
Revised May 1972 
By TNL GN34-0085 



As with DO statements, a third indexing parameter 
may be used to specify the amount by which the 
index is to be incremented at each iteration. Thus, 

READ (2,15) (A(I), 1=1,10,2) 

causes transmission of values for A(l), A(3), A(5), 
A(7), and A(9). Furthermore, this notation may 
be nested. For example, the list: 

((C(I,J), D(I,J), J=l,5), 1=1, 4) 

would transmit data in the following order, reading 
from left to right: 

C(l,l), D(l,l), C(l,2) C(l,5), D(l,5) 

C(2,l), D(2,l), C(2,2) C(2,5), D(2, 5) 

C(3,l), D(3,l), C(3,2) C(3,5), D(3,5) 

C(4,l), D(4,l), C(4,2),...,C(4,5), D(4, 5) 

The maximum depth of implied DO loops in an I/O list 
is three. The results of four or more nested loops are 
unpredictable. 



MANIPULATIVE I/O STATEMENTS 

The statements BACKSPACE, REWIND, and END 
FILE are used in FORTRAN under the IBM 1800 
Card/Paper Tape Programming System and the IBM 
1800 TSX System to manipulate magnetic tape units. 
In the IBM 1800 MPX System, manipulative I/O 
statements are used to manipulate both disk units 
and magnetic tape units in unformatted mode. In 
FORTRAN under the IBM 1130 Disk Monitor System, 
Version 2, these statements are used to manipulate 
the unformatted I/O area on disk. 

BACKSPACE Statement 

General Form; 

BACKSPACE n 

where: 

n is an unsigned integer constant or integer variable 
specifying the logical unit number (see Logical Unit 
Numbers) . 

In FORTRAN under the IBM 1130 Disk Monitor 
System, Version 2, the BACKSPACE statement 
causes a pointer to the next available logical 
record in the unformatted I/O area to be decre- 
mented by one. The statement has no effect if 
this pointer indicates the first logical record 
in the area. 

In FORTRAN under the IBM 1800 MPX System, 
the BACKSPACE statement causes the following 
actions to occur. 



Unformatted Disk I/O 

A backspace over one logical record is 
accomplished by decrementing a pointer in the 
device table. This pointer always points to the 
sector address of the next available logical record 
in process or batch process Working Storage. A 
BACKSPACE statement has no effect if the 
unformatted disk pointer is set at the beginning of 
Working Storage. 

Magnetic Tape 

Tape unit n is backspaced one logical record. If 
the tape unit is at load point, the BACKSPACE 
statement has no effect. 
REWIND Statement 

General Form : 

REWIND n 

where: 

n is an unsigned integer constant or integer vari- 
able specifying the logical unit number (see 
Logical Unit Numbers ). 
In FORTRAN under the IBM 1130 Disk Monitor 
System, Version 2, the REWIND statement causes 
a pointer to the next available logical record in the 
unformatted I/O area to be reset to one. The state- 
ment has no effect if this pointer already indicates 
the first logical record in the area. 

In FORTRAN under the IBM 1800 Card/Paper 
Tape Programming System and the IBM 1800 TSX 
System , the REWIND statement causes the tape on 
unit n to be rewound to its load point. The statement 
has no effect if the tape is positioned at its load point. 
The statement does not cause the tape on unit n to 
be unloaded. 

In FORTRAN under the IBM 1800 MPX System the 
REWIND statement causes either a pointer to the 
next logical record to be set to one for unformatted 
disk , or the tape on unit n to be rewound to its load 
point for unformatted tape. If the logical record 
pointer in the unformatted disk area is already one 
or if the tape on unit n is already at its load point, 
the statement has no effect. 

END FILE Statement 

General Form : 

END FILE n 

where: 

n is an unsigned integer constant or integer 
variable specifying the logical unit number 
(see Logical Unit Numbers) . 

In FORTRAN under the IBM 1130 Disk Monitor 
System, Version 2, the END FILE statement causes 



Statements 21 



an end-of-file record to be written in the unformatted 
I/O area. 

In FORTRAN under IBM 1800 Card/Paper Tape 
Programming System and the IBM 1800 TSX, the END 
FILE statement causes an end-of-file mark to be 
written on the tape on unit n. 

In backspacing and in skipping forward over 
records, the end-of-file record or mark is equivalent 
to one logical record. 

In FORTRAN under the IBM 1800 MPX System the 
END FILE statement causes either an end-of-file 
record to be written in the unformatted I/O area for 
unformatted disk operations or an end-of-file record 
to be written on the tape on tape unit n. 

LOGICAL UNIT NUMBERS 

The logical unit numbers used in FORTRAN I/O 
statements under the IBM 1130 Card/Paper Tape 
Programming System and the IBM 1130 Disk 
Monitor System are: 

1 Console Printer 

2 1442 Card Read Punch, Model 6 or 7 

3 1132 Printer 

4 1134 Paper Tape Reader/1055 
Paper Tape Punch 

6 Keyboard 

7 1627 Plotter 

The logical unit numbers used in FORTRAN 
I/O statements under the IBM 1130 Disk Monitor 
System, Version 2, are: 

Console Printer -^ " 
1442 Card Read Punch, Model 6 or 7 
1132 Printer 

1134 Paper Tape Reader/1055 
Paper Tape Punch 
1403 Printer- 
Keyboard 
1627 Plotter 

8 2501 Card Reader 

9 1442 Card Punch, Model 5 

10 Unformatted I/O area on disk 

The logical unit numbers used in FORTRAN 
I/O statements under the IBM 1800 Card/Paper 
Tape Programming System are assigned by 
each installation during system edit. 

The logical unit numbers used in FORTRAN 



I/O statements under the 1800 TSX and MPX Systems 
are assigned by each installation during system 
generation. 

FORMAT STATEMENT 

In order for data to be transmitted from an external 
storage medium (e. g. , cards or paper tape) to the 
computer or from the computer to an external 
medium (cards, paper tape, or printed line), it is 
necessary that the computer know the form in which 
the data exists. This is accomplished by a FORMAT 
statement. The FORMAT statement describes the 
type of conversion to be performed between the in- 
ternal and the external representation of each quantity 
in an I/O list by the use of data conversion specifica- 
tions (see Conversion of Numeric Data) . FORMAT 
statements may appear any place within the source 
program after all Specification statements. 

General Form: 
m FORMAT (k^k,,, . . . *\/\^ 2 * • • • . V' . .) 
where: 



, t n represent data 



m represents a statement number, 

ki, k 2 ,... ,k n andtj, t 2 ,.. 

conversion specifications, and 

/ represents the beginning of a new record (see 

Multiple Field Format) . 

Examples: 



5 FORMAT (15, F8.4) 
18 FORMAT (I4/F6.2, F8.4) 
20 FORMAT (Ell. 4/18) 

FORMAT statements are not executed but they 
must be given a statement number. 

Successive items in the I/O list are transmitted 
according to successive specifications in the 
FORMAT statement, until all items in the list are 
transmitted. If there are more items in the list 
than there are specifications in the FORMAT state- 
ment, control transfers to the preceding left 
parenthesis (including any preceding repeat constant) 
of the FORMAT statement and the same specifica- 
tions are used again with the next unit record. For 
example, suppose a program contains the following 
statements: 



22 



10 FORMAT (F10. 3, E12.4, F12.2) 



WRITE (3,10) A,B,C,D,E,F,G 

The following table shows the data transmitted in 
the column on the left and the specification by which 
it is converted in the center column. The column 
on the right shows the number of the record that 
contains the data. 

Data Transmitted Specification Record Number 



A 


F10. 3 


1 


B 


E12.4 


1 


C 


F12.2 


1 


D 


F10.3 


2 


E 


E12.4 


2 


F 


F12.2 


2 


G 


F10. 3 


3 



A specification may be repeated as many times as 
desired (within the limits of the unit record 
size) by preceding the specification with an unsigned 
integer constant. Thus, 

(2F10.4) 
is equivalent to: 
(F10.4, F10.4) 

A limited, one-level, parenthetical expression is 
permitted to enable repetition of data fields according 
to certain format specifications within a longer 
FORMAT statement. For example, the statement: 

10 FORMAT (14, 2 (IX, F4.1, 5X, E8.1)) 
is equivalent to: 

10 FORMAT (14, (IX, F4.1, 5X, E8.1, IX 
F4.1, 5X, E8.1)) 

If there had been 12 items in the list, the above 
FORMAT statement would have been equivalent to: 

10 FORMAT (14, IX, F4.1, 5X, E8.1, IX, 
F4.1, 5X, E8.1/1X, F4.1, 5X, 
E8.1, IX, F4.1, 5X, E8.1/1X, 
F4.1, 5X, E8.1, IX, F4.1) 

The following two-level parenthetical expression is 
not permitted because it is two-level: 

10 FORMAT (2(F10.6, 3 (E10. 2, 14))) 

The specifications in a FORMAT statement must 
correspond in mode with the list items in the I/O 
statement. Numeric data read into integer variables 



require an I-type format specification, and numeric 
data read into real variables require an F-type or an 
E-type specification. Alphameric data may be read 
into either integer or real variables by using the 
A-type format specification. This requirement holds 
for variables in both the READ and the WRITE state- 
ment list. For a more detailed description of I-, 
E-, F-, and A-type formats see Conversion of 
Numeric Data and Conversion of Alphameric Data . 



Conversion of Numeric Data 

Three types of specifications (or conversion codes) 

are available for the conversion of numeric data. 

These types of conversions are specified in the 

following form: 
Iw 

Fw.d 

Ew.d 
where: 

I, F, and E specify the type of conversion. 

w is an unsigned integer constant specifying the 
total field length of the data. (This specifica- 
tion may be greater than that required for the 
actual digits in order to provide spacing 
between numbers. ) 

d is an unsigned integer constant specifying the 
number of decimal places to the right of the 
decimal point. 

Note : The decimal point between the w and d 
portions of the specification is required. 

With all numeric input conversions, leading blanks 
are not significant and other blanks are zero. Plus 
signs may be omitted. A field of all blanks is con- 
sidered to be zero. 

For purposes of simplification, the following 
discussion of conversion codes deals with the printed 
line. The concepts developed apply to all permis- 
sible input/output media. 

I-Conversion (Iw) 

The specification Iw may be used to print a number 
in integer form; w print positions are reserved for 
the number. It is printed in this w-position field 
right-justified (that is, the units position is at the 
extreme right). If the number to be converted is 
greater thanw-1 positions, an error condition will 
exist if the number is negative. A print position 
must be reserved for the sign if negative values 
are printed, but positive values do not require a 
position for the sign. If the number has less than 



Statements 23 



w digits, the leftmost print positions are filled with 
blanks. If the quantity is negative, the position 
preceding the leftmost digit contains a minus sign. 

The following examples show how each of the 
quantities on the left is printed, according to the 
specification 13: 

Internal Value Printed 





721 


721 




-721 


*** 




-12 


-12 




8114 


*** 












-5 


-5 


Notes: 


9 


9 



1. All error fields are filled with asterisks. 

2. A number for I-conversion input may have an 
exponent field, starting with an E or a plus or 
minus sign, indicating that the number is to be 
multiplied by ten raised to the power of the 
exponent. Thus, 1200, 12000-01, 120+1, 12E+2, 
and 12E2 are all valid input for I-conversion, 
each representing the value 1200. 



Notes: 

1. All error fields are filled with asterisks. 

2. Numbers for F-conversion input need not have 
their decimal points appearing in the input field. 
If no decimal point appears, space need not be 
allocated for it. The decimal point will be sup- 
plied when the number is converted to an internal 
equivalent; the position of the decimal point will 
be determined by the format specification. How- 
ever, if the decimal point does appear within the 
field and it is different from the format specifica- 
tion, this position overrides the position indicat- 
ed in the format specification. 

3. Fractional numbers for which F-type output con- 
version is specified are normally printed with a 
leading zero. If F-conversion is used and zero 
decimal width is specified (for example, F5. 0), 
a fractional value is printed as a sign, a zero, 
and a decimal point. A zero value is printed 
with a zero preceding the decimal point. 

4. F-conversion will accept input data in E-type 
format. 



F-Conversion (Fw.d) 

For F-type conversion, w is the total field length 
reserved and d is the number of places to the right 
of the decimal point (the fractional portion). For 
output, the total field length reserved must include 
sufficient positions for a sign, if any, a digit to the 
left of the decimal point, and a decimal point. The 
sign, if negative, is printed. In general w should 
be at least equal to d + 3 for output. 

If insufficient positions are reserved by d, the 
fractional portion is truncated from the right. If 
excessive positions are reserved by d, zeros are 
filled in from the right to the extent of the specified 
precision. The integer portion of the number is 
handled in the same fashion as numbers converted 
by I-type conversion on input and output. 

The following examples show how each of the 
quantities on the left is printed according to the 
specification F5.2: 

Internal Value Printed 



12.17 

-41.16 

-.2 

7.3542 
-1. 
9.03 
187.64 



12.17 

-0.20 
7.35t 

-1.00 
9.03 



E -Conversion (Ew.d) 

For E -conversion, the fractional portion is again 
indicated by d. For output, the w includes the field 
d, a space for a sign, space for a digit preceding 
the decimal point, a decimal point, and four spaces 
for the exponent. Space must be reserved for each 
of these on output. An output error condition will 
result if w<; d+5. For input, it is not necessary to 
reserve all of these positions. In general, w should 
be at least equal to d+7. 

The exponent is a signed or unsigned one- or two- 
digit integer constant not greater than 38 and preceded 
by the letter E. Ten (10) raised to the power of the 
exponent is multiplied by the number to obtain its 
true internal value. 

The following examples show how each of the 
quantities on the left is printed, according to the 
specification E9.3: 



tLast two digits of accuracy lost due to insufficient 
specification. 



Internal Value 

238 

-.002 

.00000000004 

-21.0057 



Printed 

0.238ED03 

0.400E-10 



24 



If the last example above had been printed with a 
specification of El 0. 3, it would appear as: 

-0.210Eb02f 



NOTES: 

1. All error fields are filled with asterisks. 

2. For input, the start of the exponent field must 
be marked by an E, or, if that is omitted, by a 
+ or - sign (not blank). Thus, E2, E+2, +2, 
+02, E02, and E+02 are all permissible exponent 
fields for input. 

3. For input, the exponent field may be omitted 
entirely (i. e. , E -conversion will accept input 
data in F-type format). 

4. Numbers for E -conversion input need not have 
their decimal points appearing in the input field. 
If no decimal point appears, space need not be 
allocated for it. The decimal point will be 
supplied when the number is converted to an 
internal equivalent; the position of the decimal 
point will be determined by the format specifica- 
tion. However, if the decimal point does appear 
within the field and it is different from the 
format specification, this position overrides 

the position indicated in the format specification. 

5. A leading zero is always printed to the left 
of the decimal point. 



Conversion of Alphameric Data 

There are two specifications available for input/ 
output of alphameric data: H-conversion (including 
literal data enclosed in apostrophes), and A-con- 
version. H-cdhversion is used for alphameric data 
that is not going to be changed by the object program 
(e.g. , printed headings); A-conyersion is used for 
alphameric data in storage that is to be operated 
on by the program (e.g., modifying a line to be 
printed). The characters that can be handled are 
listed in Appendix C. 



Blanks are considered alphameric data and must be 
included as part of the count n. A comma following 
the last alphameric character is optional. 

The effect of nH depends on whether it is used 
with an input or output statement. 

Input, n characters are extracted from the input 
record and replace the n characters included in the 
specification. For example, 

READ (4, 5) 
5 FORMAT (8HHEADINGS) 

would cause the next 8 data characters to be read 
from the input file on the I/O unit associated with the 
logical unit number 4 (Paper Tape Reader on the 
1130); these characters would replace the data 
HEADINGS in storage. 



Output. The n characters following the specification 
are written as part of the output record. Thus, the 
statements : 

WRITE (1,6) 
6 FORMAT (15H CUST. NO. NAME) 

would cause the following record to be written on the 
I/O unit associated with the logical unit number 1 
(Console Printer on the 1130): 

CUST. NO. NAME 



A -Conversion 

The specification Aw is used to transmit alphameric 
data to/from variables in storage. It causes the 
first w characters to be read into, or written from, 
the area of storage specified in the I/O list. For 
example, the statements: 

10 FORMAT (A3) 



H-Conversion 

The specification nH is followed in the FORMAT 
statement by n alphameric characters. For example: 

24H THIS IS ALPHAMERIC DATA 



tLast three digits of accuracy lost due to insufficient 
specification, b represents a blank. 



READ (4,10) ERROR 



would cause three alphameric characters to be read 
from the I/O unit associated with the logical unit 
number 4 (Paper Tape Reader on the 1130) and 
placed (left-justified) into the variable named 
ERROR. 

The following statements: 



Statements 25 



INTEGER OUT 
15 FORMAT (4HbXY=, F9. 3, A4) 



WRITE (OUT, 15) A, ERROR, B, ERROR 

may produce the following lines: 

XY=b5976.214 

XY=b6173.928 

where represents the contents of the field 

ERROR. 

Thus, A -conversion provides the facility for 

reading alphameric data into a field in storage, 

manipulating the data as required and printing it out. 

If the number of alphameric characters is less 
than the capacity of a field in storage into which 
the characters are to be read, the remaining 
characters in the field are loaded with blanks. How- 
ever, if the number of characters is greater than 
the capacity of the field in storage, the excessive 
characters are lost. It is important, therefore, 
to allocate enough area in storage to handle the 
alphameric characters being read in. The output 
case is very similar, unused areas in an output 
medium are loaded with "blanks" while excessive 
characters are lost. 

Each real variable has sufficient space for 4 or 
6 characters (the precision of real variables is spe- 
cified at compile time — see REAL Constants) ; each 
integer variable has space for 2 characters. For 
example, 10 characters could be read into, or 
written from, the first five variables of the array 
I if the following format is used: 
101 FORMAT (5A2) 



Arithmetic operations involving variables con- 
taining alphameric characters should be performed 
in integer mode. Alphameric characters are 
represented internally in eight -bit EBCDIC 
(refer to the appropriate Subroutine Library 
publication, as listed in the Preface , above, 
for a description of the EBCDIC used for 
internal representation of alphameric characters) . 

Literal Data Enclosed in Apostrophes 

Literal data can consist of a string of alphameric 
and special characters written within the FORMAT 
statement and enclosed in apostrophes. For example: 

25 FORMAT (' 1966 INVENTORY REPORT') 

A comma following the last apostrophe is optional. 

An apostrophe character within literal data is 
represented by two successive apostrophes. For 
example, the characters DON'T are represented as: 

DON"T 

The effect of the literal format code depends on 
whether it is used with an input or output statement. 

Input. A number of characters, equal to the number 
of characters specified between the apostrophes, are 
read from the designated I/O unit. These characters 
replace, in storage, the characters within the 
apostrophes. For example, the statements: 



5 FORMAT (' HEADINGS') 



READ (IN, 101) I 



WRITE (IOUT, 101) I 

Thus, two characters are contained in each of the 
five consecutive positions: 1(1), 1(2), 1(3), 1(4), 1(5). 
On output the leftmost character is written first. 
Note that the format 

101 FORMAT (A10) 

would not work since 10 characters would be read 
from an array element of two characters , causing the 
last 8 alphameric characters to be ignored. 



READ (4,5) 



would cause the next 9 characters to be read from the 
I/O unit associated with the logical unit number 4 
(Paper Tape Reader on the 1130). These char- 
acters would replace the blank and the 8 char- 
acters H,E,A,D,I,N,G, and S in storage. 



Output. All characters (including blanks) within 
the apostrophes are written as part of the output 
data. Thus the statements: 



26 



FORMAT ('THIS IS ALPHAMERIC DATA') 



WRITE (1,5) 



would cause the following record to be written on the 
I/O unit associated with the logical unit number 1 
(Console Printer on the 1130): 

THIS IS ALPHAMERIC DATA 

If it is required that literal data be repeated a 
number of times, it must be enclosed in parentheses. 
For example, if the above record is to be printed 
five times, the FORMAT statement should read: 
5 FORMAT (5('THIS IS ALPHAMERIC DATA')) 

X-Type Format 

Blank characters may be provided in an output 
record, or characters of an input record may be 
skipped, by means of the specification, nX; n is 
the number of blanks desired or the number of 
characters to be skipped. 

When the nX specification is used with an input 
record, n characters are skipped over before the 
transmission of data begins. 

For example, if a card has six 10-column fields 
of integers, the statement: 



T-Format Code 

Input and output may begin at any position by using 
the format code Tw where w is an unsigned integer 
constant specifying the position in a FORTRAN 
record where the transfer of data is to begin. Only 
when the output is printed on an 1132, 1403, or 1443 
Printer does the correspondence between w and the 
actual print position differ. In this case, because of 
the carriage control character, the print position 
corresponds to w-1, as may be seen in the following 
example: 



5 FORMAT (T40, '1964 INVENTORY REPORT' 
T80, 'DECEMBER* T2, 'PART NO. 10095') 

The preceding FORMAT statement would result 
in a printed line as follows: 



Print Print Print 

Position 1 Position 39 Position 79 

1 \ I 

PART NO. 10095 1964 INVENTORY REPORT DECEMBER 



The following statements: 

5 FORMAT (T40, SHEADINGS') 



5 FORMAT (110, 1 OX, 4110) 

would be used, along with the appropriate READ 
statement, to avoid reading the second quantity. 
When this specification is used with an output 
record, n positions are left blank. Thus, the facility 
for spacing within a printed line is available. For 
example, the statement: 

10 FORMAT (3(F6. 2, 5X)) 

may be used with the appropriate WRITE statement 
to print a line as follows: 

-23. 45bbbbbbl7. 32bbbbbb24. 67bbbbb 

where b represents a blank. 



READ (2,5) or READ (1,5) 



would cause the first 39 characters of the input data 
to be skipped, and the next 9 characters would then 
replace the blank and the characters H, E, A, D, I, 
N, G and S in storage. 

The T-format code may be used in a FORMAT 
statement with any type of format code. For example, 
the following statement is valid: 

5 FORMAT (Tl 00, F10.3, T50, E9.3, Tl, 
'bANSWER IS') 



where b represents a blank. 



Statements 27 



Multiple Field Format 

Slashes are used in a FORMAT statement to delimit 
unit records, which must be one of the following: 

1. A punched paper tape record with a maximum 

of 80 characters (1054 Paper Tape Reader, 1055 
Paper Tape Punch, or 1134 Paper Tape Reader). 

2. A punched card record with a maximum of 80 
characters (1442 Card Read Punch, Model 6 or 7, 
or 1442 Card Punch, Model 5). 

3. A printed line with a maximum of 120 print 
characters and 1 carriage control character 
(1132 Printer or 1403 Printer). 

4. A printed line with a maximum of 144 print 
characters and 1 carriage control character 
(1443 Printer). 

5. An output typewritten line with a maximum of 
156 characters for 1800 systems, 120 
characters for 1130 systems (Console Printer, 
1053 Printer, or 1816 P rinter -Keyboard. ) 

6. An input record from the keyboard with a maxi- 
mum of 80 characters (Console Keyboard or 
1816 Printer-Keyboard). 

7. A plotted output record with a maximum 
of 120 characters (1627 Plotter). 

8. A magnetic tape record with a maximum length 
of 145 characters (2401 and 2402 Magnetic Tape 
Units). 



Thus, the statement: 

5 FORMAT (F9. 2/E14. 5) 

specifies the data conversion specification F9. 2 for 
the first unit record, and the data conversion 
specification E14. 5 for the second unit record. 

Blank lines may be introduced between output 
records, or input records may be skipped, by using 
consecutive slashes (/) in a FORMAT statement. The 
number of input records skipped, or blank lines 
inserted between output records, depends upon the 
number and placement of the slashes within the 
statement. 



If there are n consecutive slashes at the beginning 
or end of a format specification, n records are 
skipped or n blank lines are inserted between printed 
output records. If n consecutive slashes appear any- 
where else in a format specification, the number of 
records skipped or blank lines inserted is n-1. For 
example, the statements: 

10 FORMAT (///I6) 

READ (INPUT, 10) MULT 

cause 3 records to be skipped on the input file before 
data is read into MULT. 
The statements: 

15 FORMAT (I5////F5. 2 , 12//) 
WRITE (IOUT, 15) K,A,J 

result in the following output: 

Integer 

(blank line) 

(blank line) 

(blank line) 

Real Number Integer 

(blank line) 

(blank line) 



To obtain a multiline listing in which the first two 
lines are to be printed according to a special format 
and all remaining lines according to another format, 
the last-line specification should be enclosed in a 
second pair of parentheses. For example, in the 
statement: 

FORMAT (I2,3E12.4/2F10.3,3F9.4/(3F12.4)) 

when data items remain to be transmitted after the 
format specification has been completely used, the 
format repeats from the last left parenthesis. Thus, 
the listing would take the following form: 

I2,E12.4,E12.4,E12.4 
F10. 3, F10. 3, F9. 4, F9. 4, F9. 4 
F12.4,F12.4,F12.4 
F12.4,F12.4, F12.4 



28 



Page of GC26-37 15-8 
Revised Feburary 1974 
ByTNLGN34-0181 



Carriage Control 

If a unit record is to be printed on an 1132, 1403, or 
1443 Printer, the first character in that unit record 
is used for carriage control. Normally the character 
is specified at the beginning of the format specifi- 
cation for the unit record as lHx, where x is a blank, 
0, 1, or +. This character is not printed; it only 
controls carriage spacing as follows: 

blank causes a single space before the unit record 
is printed 

causes a double space before the unit record 
is printed 

1 causes a skip to the next channel 1 before the 
unit record is printed 

+ causes all spacing or skipping to be sup- 

pressed before the unit record is printed 



All Specification statements must precede any 
statement function definition statement and the first 
executable statement of the source program. They 
should appear in the following order: 

Type Statements (REAL, INTEGER) 

EXTERNAL Statements 

DIMENSION Statements 

COMMON Statements 

EQUIVALENCE Statements 

Statement Function Definition Statements 

First Executable Statement 

DATA and DEFINE FILE statements must appear 
within the Specification group and must not be intermixed 
with EQUIVALENCE statements. Placement of these 
two statements is optional. But, for most efficient use 
of core storage, they should be placed between the 
EQUIVALENCE statements and the statement function 
definition statements. 



Data Input to the Object Program 

Data input to the object program is contained in unit 
records, as described under Multiple Field Format, 
above. The following information should be consider- 
ed when preparing input data on punched cards: 

1. The input data record must correspond to the 
field width specifications defined in the FORMAT 
statement. 

2. Leading blanks are ignored. All other blanks 
are treated as zeros. 

3. A plus sign may be implied by no sign or in- 
dicated by a plus sign; a negative number, how- 
ever, must be preceded by a minus sign. 

I 4. Data within each field must be right-justified. 



SPECIFICATION STATEMENTS 

The Specification statements provide the compiler 
with information about: 

1. The nature of the variables used in the program. 

2. The allocation in storage for certain variables 
and/or arrays. 

3. The names of subprograms to be used at object 
time. 

The Specification statements are non-executable 
because they do not cause the generation of instruc- 
tions in the object program. 



TYPE STATEMENTS (REAL, INTEGER) 

General Form: 

INTEGER a,b,c,... 
REAL a,b, c, ... 

where: 

a,b, c, . . . are variable, array, FUNCTION sub- 
program or statement function names appear- 
ing in a program or subprogram. Arrays 
named in this statement must also be dimen- 
sioned in this statement. Array dimensions 
specified in this statement should not be in- 
cluded in references to the array in 
DIMENSION or COMMON statements. 
Repetition or respecification of the array 
dimensions results in an error. 

Examples: 

INTEGER DEV, JOB,XYZ12, ARRAY(5, 2, 6) 
REAL ITA, SMALL, ANS,NUMB(3, 14) 

The REAL and INTEGER statements explicitly 
define the type of variable, array, or function. In 
the first example, the variable DEV (implicitly 
defined as a real variable, because its initial letter 
is not I, J,K,L,M, or N) is explicitly defined as an 
integer variable and is, therefore, handled as an 
integer variable in the program. The appearance 
of a variable name in either of these statements 



Statements 29 



overrides any implicit type specification determined 
by the initial letter of the variable. Type statements 
must precede any other Specification statements. 

EXTERNAL STATEMENT 

General Form: 

EXTERNAL a, b,c 

where: 

a , b , c , . . . are the names of subprograms that 
appear in any other subprogram argument list. 
Only the subprogram name is used with the 
EXTERNAL statement. Other subprogram para- 
meters must not be included. Subprograms 
declared external may be FUNCTION subpro- 
grams, SUBROUTINE subprograms, FORTRAN 
supplied FUNCTION subprograms, or subpro- 
grams written in Assembler language (must be 
CALL-type subprograms). 

Example: 

EXTERNAL SIN, MATRX , INVRT 



CALL 



CALL 



SIMUL (A, SIN, INVRT) 



SIMUL (X, SIN, MATRX) 



END 

Any subprogram named in the EXTERNAL state- 
ment may be used as an argument for other sub- 
programs (see Subprogram Statements ). Subprograms 
named in an EXTERNAL statement are loaded when 
the executable core load is built, not during compi- 
lation. 

DIMENSION STATEMENT 

General Form: 

DIMENSION a(k ), b(k ), c(k_),...x(k ) 
x & o n 

where: 

a, b, c, . . ,x are names of arrays. 

ki,k2,k 3 , . . .k n are each composed of 1, 2, or 3 
unsigned integer constants that specify the 
maximum value for 1, 2, or 3 subscripts, 
respectively. 

Example: 

DIMENSION A(10), B(5,15), C(9,9,9) 

The DIMENSION statement provides information 
to allocate storage for arrays in an object program 



(unless the information appears in a Type or 
COMMON statement). It defines the maximum size 
of each array listed. 

Each variable that appears in subscripted form in 
a source program must appear in a Type, 
DIMENSION, or COMMON statement contained within 
the source program. The first of these statements 
that refers to the array must give dimension in- 
formation, (See COMMON Statement with Dimen- 
sions .) 

The dimension information for an array argu- 
ment in a FUNCTION subprogram or a SUBROUTINE 
subprogram must generally be identical to the 
corresponding dimension information in the calling 
program. (See Subprogram Statements. ) 



COMMON STATEMENT 
Blank COMMON 
General Form: 

COMMON a,b,c,...n 
where: 

a, b, c, . . . n are variable or array names. 

Note: All arrays whose names are specified in a 
COMMON statement must be dimensioned, either 
in the COMMON statement itself (COMMON state- 
ment with dimensions) , or in a preceding 
DIMENSION statement in the same program. 

Variables or arrays that appear in the main pro- 
gram or a subprogram may be made to share the 
same storage locations with variables or arrays of 
the same type and size in other subprograms, by use 
of the COMMON statement. For example, if one 
program contains the statement: 

COMMON TABLE 
and a second program contains the statement: 

COMMON LIST 
the variable names TABLE and LIST refer to the 
same storage locations (assuming the data associated 
with the names TABLE and LIST are equal in length 
and type). 

If the main program contains the statement: 

COMMON A, B,C 
and a subprogram contains the statement: 

COMMON X, Y, Z 
and A, B, and C are equal in length to X, Y, and Z, 
respectively, then A and X refer to the same storage 
locations, as do B and Y, and C and Z. 

Within a specific program or subprogram, vari- 
ables and arrays are assigned storage locations in the 



30 



sequence in which their names appear in a COMMON 
statement. Subsequent sequential storage assign- 
ments within the same program or subprogram are 
made with additional COMMON statements. 

A dummy variable can be used in a COMMON 
statement to establish shared locations for variables 
that would otherwise occupy different locations. For 
example, the variable S can be assigned to the same 
location as the variable Z of the previous example 
with the following statement: 

COMMON Q, R, S 



The assignment of variables or constants to the 
COMMON areas can be mixed in the same COMMON 
statement by preceding the Skeleton COMMON items 
with /INSKEL/ and by preceding the blank COMMON 
items with //. For example, in the statement 

COMMON/INSKEL/ A, B, C//D, E, F 

the variables A, B, and C will be assigned locations 
in the Skeleton COMMON area and D, E, and F will 
be assigned locations in the blank COMMON area. 
The same assignment could be made with the fol- 
lowing statement. 



where Q and R are dummy names that are not used 
elsewhere in the program. 

Redundant COMMON entries are not allowed. For 
example, the following is invalid: 



COMMON D, E, F/INSKEL/A, B, C 

In this case, the double slashes are not necessary 
because the blank COMMON items were not pre- 
ceded by a Skeleton COMMON assignment. 



COMMON A, B, C, A 



NOTE: INSKEL COMMON may be used in one word 
integer programs only. 



Named COMMON 

Named COMMON is valid only in FORTRAN under 
the IBM 1800 TSX and MPX Systems, where the 
name INSKEL specifies Skeleton COMMON. The 
Skeleton COMMON is located in the low core 
addressed Skeleton Area. It is not altered by the 
IBM System and provides the capability for com- 
plete communications between process core loads, 
non-process core loads, INSKEL interrupt sub- 
routines, in-core -with -mainline interrupt subroutines 
(TSX only), interrupt core loads, and special core 
loads. Process and non-process programs (either 
as part of mainline or interrupt core loads) can 
refer to the Skeleton COMMON area by the following 
statement: 

COMMON/lNSKEL/a, b, c,...n 
where: 

INSKEL is the name of Skeleton COMMON. 

INSKEL must be enclosed in slashes, 
a, b, c, . . . n are variable or array names as 

described for the blank COMMON statement. 

NOTE: Non-process core loads should reference 
INSKEL COMMON only for processor iented functions 
such as updating conversion factors after time- 
shared instrument calibration. 



COMMON Statement with Dimensions 

General Form: 

COMMON A^), B(k 2 ), C(k 3 ),...N(k n ) 

where: 

A, B, C, . . . N are array names and 

ki , k2 , kg , . . . k n are each composed of 1 , 2 , or 3 

unsigned integer constants that specify the 

dimensions of the array. 

Example: 

COMMON A(l), B(5,5,5), C(5,5,5) 

This form of the COMMON statement, besides 
performing the functions discussed previously for 
the COMMON statement, performs the additional 
function of specifying the size of arrays. Array 
dimensions may be specified for both blank COMMON 
and named COMMON variables. 

NOTES: 

1. Dummy arguments for SUBROUTINE or 
FUNCTION statements cannot appear in 
COMMON statements , if they appear on 
the SUBROUTINE or FUNCTION state- 
ment. 



Statements 31 



2. A single COMMON statement may contain 
variable names, array names, and dimensioned 
array names. For example, the following are 
valid: 

DIMENSION B (5, 15) 
COMMON A, B, C(9,9,9) 

3. All dimensioned arrays in a main program or 
subprogram and all items in COMMON are 
stored in descending storage locations. 

4. All two-word variables, i. e. two word integers 
and standard precision real variables , are 
allocated to even addresses. Thus the common 
area might contain several unused words if 
variables of different length are mixed in the 
COMMON statement. 

EQUIVALENCE STATEMENT 

Different variables and arrays are usually assigned 
unique storage locations. However, it may be desir- 
able to have two or more variables share the same 
storage location. This facility is provided by the 
EQUIVALENCE statement. 

General Form: 

EQUIVALENCE (a,b, ...), (d, e, ...),.. . 
where: 

a,b,d,e,... are simple variables or subscripted 
variables. Subscripted variables may have 
either multiple subscripts (which must agree 
with the dimension information) or single 
subscripts. The subscripts must be integer 
constants. In a subprogram, dummy vari- 
ables must not be present in an EQUIVALENCE 
statement. Standard precision real variables 
must be equivalenced to an even address. 

Each pair of parentheses in the EQUIVALENCE 
statement encloses a list of two or more variable 
names that refer to the same location during the 
execution of the object program. 

Any number of variables may be listed in a 
single EQUIVALENCE statement. 

Examples : 

EQUIVALENCE (X, Y, SAVE, AREA), 

(E(l), F(l)), (G(l), H(5)) 
EQUIVALENCE (A(4), C(2), D(l)) 

In the second example, making A(4), C(2), and 
D(l) equivalent to one another sets up an equivalence 
among the elements of each array as follows: 



A(2) 






A(3) 


C(l) 




A(4) 


C(2) 


D(l) 


A(5) 


C(3) 


D(2) 



NOTE: Any EQUIVALENCE statement that lists 
an array must reference elements of that array. 
That is, if A and B are both 30 element arrays to 
be equated, 

EQUIVALENCE (A,B) 

is not allowed. The arrays may be equated by a 
statement of the form: 

EQUIVALENCE (A(l), B(l)) 

Note : None of the dummy arguments in a 
SUBROUTINE subprogram can be specified in 
an EQUIVALENCE statement. 

The combination of all equivalence lists in a program 
must not: 

1. Equate two variables or array elements that 
are already assigned to COMMON. 

2. Contradict any previously established equival- 
ences. 

3. Extend an array beyond the dimensions defined 
in a DIMENSION, TYPE, or COMMON state- 
ment. 

Example 1: Violating Rule 1 

DIMENSION A(10), B(5) 
COMMON A, B 
EQUIVALENCE (A(l), B(l)) 

Example 2: Violating Rule 2 

EQUIVALENCE (A(10), B(l)) 
EQUIVALENCE (B(10), C(l)) 
EQUIVALENCE (A(10), C(l)) 

Example 3 : Violating Rule 3 

DIMENSION A(3), B(3) 
EQUIVALENCE (A(4), B(l)) 



However, EQUIVALENCE statements may extend the 
size of the COMMON area. For example, the follow- 
ing is valid: 



32 



DIMENSION C(4) 
COMMON A, B 
EQUIVALENCE (B,C(2)) 

for it would produce the following relationship in the 

COMMON area: 

A C(l) 

B C(2) 

C(3) 

C(4) 

Since arrays must be stored in descending storage 
locations, a variable may not be made equivalent 
to an element of an array in such a manner as to 
< cause the array to extend beyond the beginning of the 
COMMON area. For example, the following coding 
is invalid: 

DIMENSION C(4) 

COMMON A, B 

EQUIVALENCE (A,C(2)) 
for it would force C(l) to precede A in the COMMON 
area, as follows: 



C(l) 
C(2) 
C(3) 
C(4) 



(outside the COMMON area) 



Conversion to Single Subscripts 

Two- and three-dimensional arrays actually appear 
in storage in a one-dimensional sequence of core 
storage words. 

In an EQUIVALENCE statement it is possible to 
refer to elements of multi-dimensioned arrays by 
single-subscripted variables. For example, in an 
array dimensioned A(3,3,3), the fourth element of 
the array can be referenced as A(l,2,l) or as A(4). 

The rules for converting multiple subscripts to 
single subscripts are as follows: 



1. 



2. 



For a two-dimensional array, dimensioned as 

A(I, J): the element A(i, j) can also be referenced 

as A(n), where n = i + I(j-l). 

For a three-dimensional array, dimensioned as 

A(I,J,K): the element A(i,j,k) can also be 

referenced as A(n), where n = i + I(j-l) + 

I * J(k-l). 



NOTE: Conversion to single subscripts is permitted 
only in EQUIVALENCE statements. 

DATA STATEMENT 

The DATA statement is used to define initial values 
of variables and array elements assigned to areas 
other than COMMON. Values assigned to variables 



Page of GC26-37 15-7 
Revised May 1972 
By TNL GN34-0085 

or array elements during execution override values 
assigned via the DATA statement. 

General Form: 



DATA Vx, V 2 V n /ii*d lf i 2 *d V^n/' 

V n +i. • • • > v r/i m+1 *d m+ i, . . . ,i s *cl s / f .../.../ 



where: 



L l> 



Vi, . . . , V r are variables or subscripted variables 
(subscripts must be integer constants). 

d^, . . . , d g are data constants. They may be 
integer, real, hexadecimal, or literal data 
constants. Integer and real constants may be 
specified as negative. See Data-Variable 
Combinations for the valid name and constant 
combinations. 

. . . , i s are optional unsigned integer constants 
that indicate the number of variables and/or 
array elements that are to be assigned the 
value of the data constant. These constants 
must be less than 4096, that is 1 < i <4095. 
They are separated from the data constants 
by asterisks. Each data constant must be of 
the same type (integer or real) as its corre- 
sponding variable. 

The slash is used to separate and enclose data con- 
stants. 

When an unsubscripted array name is specified, 
constants are assigned from the first element toward 
the end of the array. Only a single data constant is 
assigned when an array element is specified. 

There is an upper limit for the number of assigned 
different values in one data statement. This limit 
is 50 for subscripted extended precision variables, 
60 for subscripted standard precision variables, and 
75 if only subscripted integer variables are used. 

If a variable is given more than one value by DATA 
statements, the last specified value is the one available 
at execution time. 

If a given constant is not exhausted by assignment 
to a given variable or array, the remainder will be 
assigned to succeeding variables or arrays. 

An error condition occurs if all constants are not 
exhausted when the last variable or array has been 
satisfied. Similarly, an error occurs when a variable 
or array is specified for which no constants are 
available. 

Example 1 : 

DATA A/5 *1. 0,2.0,3*3.0/ 

If A is a nine-element array for real variables, the 
first five elements are initialized to 1.0, the sixth 
to 2. 0, and the remaining three to 3. 0. 



Statements 33 



Example 2 : 

DATA A, B/12*1.0/ 

If A is a nine-element array for real variables and B 
is an array containing positions for at least three 
real variable elements, all nine elements of A and 
the first three elements of B will be initialized to 1.0. 



Example 3 : 

DATA A(3)/5. 0/ 

If A is an array for real variables of at least 3 
elements, the third element will be initialized to 5.0. 

Hexadecimal Constants 

Hexadecimal constants are written as the letter Z 
followed by one to four hexadecimal digits (0 through 
F). Each constant is assigned one word and the 
constant is right -justified if three or less hexa- 
decimal digits are used. Each constant must be 
separated by a comma. 

Any variable, array, or array element to which 
a hexadecimal constant value is assigned by the 
DATA statement must be an integer variable, 
integer array, or an element of an integer array. 

Example 4 : 
DATA 1/6* Z24, ZAB19/ 

The first 6 elements of array I will be initialized to 
the following configuration: 



0000000000100100 



2 4 

The seventh element will be initialized to: 



01010110001100 



Literal Data 



Literal data must be enclosed in single quotes. A 
quote mark within a literal field is represented by 
two consecutive quote marks. A literal constant may 



not exceed the length of the variable or array 
element to which it is assigned. Where necessary, 
blanks are included, with the constant left-justified. 
Literal data is written in 8 -bit EBCDIC, packed two 
characters per word. 

Example 5 : 
DATA A/3*'ABCD', 2*'AB', *A"BC*, »A. BC'/ 

If the array A contains at least seven elements , and 
is of standard (two word) precision, the first three 
elements will be assigned the value ABCD, the fourth 
and fifth the value ABbb, where the b's are blanks, 
the sixth element the value A'BC, and the seventh 
A.BC. 

Example 6 : 

DATA KEYWD/2*'AB','A"VB. VAB','X'/ 

If literal data is assigned to an integer array, a 
maximum of two characters per element may be 
specified, regardless of the precision of the program. 
In the array KEYWD, which consists of at least 6 
elements, the first two elements are assigned the 
value AB, the third element A', the fourth element 
B. , the fifth element AB, and the sixth element Xb 
where b is a blank. 

Data-Variable Combinations 



>v data 
variable^*^ 


real 


integer 


hexadecimal 


literal 


real 
integer 


yes 

no 


no 
yes 


no 
yes 


yes 
yes 



DEFINE FILE STATEMENT 

The DEFINE FILE statement specifies to the 
FORTRAN Compiler the size and quantity of disk 
data records within files that will be used with a 
particular program and its associated subprograms. 
This statement must not appear in a subprogram; 
it may appear only in a main program. Therefore, 
all subprograms used by the main program must use 
the defined files of the main program. 

The purpose of the DEFINE FILE statement is to 
divide the disk into files to be used in the disk 
READ, WRITE, and FIND statements. 

General Form: 



DEFINE FILE a 2 (mi, li, U, v^, 

a 2 (m 2 , 1 2 , U, v 2 ),... 



34 



where: 

a is an integer constant (1 through 32767) that is the 
symbolic designation for this file. 

m is an integer constant that defines the number 
of file records in this symbolic file. 
NOTE: The sector count of a defined file must not 
exceed 1600 except under 1800 MPX using mapped 
1810 drives. In this case the sector count of the 
defined file must not exceed 4096. The sector 
count of a file is the number of file records divided 
by the number of records that can be contained in 
one sector of 320 words. 

1 is an integer constant that defines the length 
(in words) of each file record in this symbolic 
file. The value of 1^ must be less than or 
equal to 320. 

U is a fixed letter. It is used to designate that 
the file must be read/written with the disk 
READ/WRITE statements and will handle no 
data conversion, 
v is a non-subscripted integer variable name. 
This variable, called the associated variable, 
is set at the conclusion of each disk 
READ, WRITE, and FIND statement referenc- 
ing this symbolic file. After a READ or 
WRITE statement, it is set to the number of the 
next available file record. After a FIND 
statement, it is set to the number of the. indicated 
record. 

This variable must be set initially by the 
user if it is to be used in disk I/O statements 
as a symbolic record number. This variable 
must appear in COMMON if it is to be 
referenced by more than one program during 
execution. 

Note: The associated variable for a defined 
file should not appear in the I/O list of a disk 
READ or WRITE statement referencing that 
file. 
An example of defining a data file is: 
DEFINE FILE 3 (400, 60, U, K) 

The DEFINE FILE statement furnishes execution 
time FORTRAN I/O subroutines with the necessary 
parameters to manipulate data files that are user- 
generated or system-generated. 

The user-generated data files are a result of Disk 
Utility Program functions requested by the user 
(refer to the sections describing the *FILES control 
record and the ST ORE DATA function of the Disk 
Utility Program or MPX Disk Management Program, 
in the appropriate operating procedures publication 
as listed in the Preface , above). The *FILES 
control records supply at the time the executable 



Page of GC26-37 15-8 
Revised February 1974 
ByTNLGN34-0181 

core load is built those parameters not supplied 
by DEFINE FILE statements. That is they 
provide a correlation between the file 
numbers found on the DEFINE FILE 
statements and data file names on the disk. 

System- generated data files are temporary 
disk storage areas allocated by the Core Load 
Builder. They are a result of DEFINE FILE 
statements for which no matching file numbers 
exist on * FILES control records. 

NOTE: Since records that require no data con- 
version are transmitted, care must be exercised to 
ensure that the programs using a data file have the 
same precision (standard or extended). 



SUBPROGRAM STATEMENTS 

Suppose that a program is being written that, at 
various points, requires the same computation to be 
performed with different data for each calculation. 
It would simplify the writing of that program if the 
statements required to perform the desired com- 
putation could be written only once and then could be 
referred to freely. Each reference to the statements 
would have the same effect as if the statements were 
written at the. point in the program where the 
reference was made. For example, if a general 
program were written to take the square root of any 
number, it would be desirable to be able to in- 
corporate that program (or subprogram) into other 
programs where square root calculations are required. 

The FORTRAN language provides for the preceding 
situation through the use of subprograms. There are 
three classes of subprograms: statement functions, 
FUNCTION subprograms, and SUBROUTINE sub- 
programs. In addition, there is a group of 
FORTRAN -supplied FUNCTION subprograms. 

The first two classes of subprograms are called 
functions. Functions differ from the SUBROUTINE 
subprograms in that functions always return a single 
value to the calling program, whereas, a SUB- 
ROUTINE subprogram can return any number of 
values to the calling program. A function is 
employed (or called) by writing the name of the 
function (see Subprogram Names) and an argument 
list in a standard arithmetic expression. A 
SUBROUTINE subprogram must be called by a 
special FORTRAN statement, namely, the CALL 
statement. 

The statement function is written and compiled as 
part of the program in which it appears. The other 
subprograms are written and compiled separately 
and linked to the main program at the time they are 
loaded for execution. 



Statements 35 



SUBPROGRAM NAMES 

A subprogram name consists of 1-5 alphameric 
characters, excluding special characters, the first 
of which must be alphabetic. The type (real or 
integer) of a subprogram (except SUBROUTINE) 
can be indicated in the same manner as variables. 
The first four characters of a SUBROUTINE name 
must not be either LINK or EXIT. A CALL to a so 
named subprogram will result in a compilation 
error. 

The type of statement function may be indicated 
implicitly by the initial character of the name or 
explicitly by the REAL or INTEGER type statement. 

The type of a FORTRAN-supplied FUNCTION sub- 
program is indicated implicitly by the initial char- 
acter of its name. 

The type of a FUNCTION subprogram may be 
indicated implicitly by the initial character of the 
name or explicitly by a Type specification (see 
Type Specification of the FUNCTION Subprogram) . 
In the latter case, the implicit type is overriden by 
the explicit specification. 

The type of a SUBROUTINE subprogram is not 
defined, because the result returned to the main pro- 
gram is dependent only on the type of the variable 
names in the argument list. 

FUNCTIONS 

In mathematics, a function is a statement of the 
relationship between a number of variables. The 
value of the function depends upon the values assigned 
to the variables (or arguments) of the function. The 
same definition of a function is true in FORTRAN. 
To use a function in FORTRAN, it is necessary to: 

1. Define the function. That is: 

a. Assign a unique name by which it may be 
called 

b. State the arguments of the function 

c. State the procedure for evaluating the 
function 



2. 



Call the function, where required, in the 
program. 



When the name of a function appears in any FORTRAN 
arithmetic expression, program control is transferred 
to the function subroutine. Thus, the appearance of 
the function with its arguments causes the computa- 
tions indicated by the function definition to be per- 
formed. The resulting quantity replaces the function 
reference in the expression and assumes the mode 



of the function. The mode of a function, as with 
variables, is determined either implicitly by the 
initial character of its name, or explicitly by a Type 
statement. 



Statement Function Definition Statement 



General Form: 
a = b 
where: 

a is a function name followed by parentheses 

enclosing its arguments, which must be distinct, 
nonsubscripted variables separated by commas. 

b is an expression that does not involve sub- 
scripted variables. 

Examples: 

FIRST(X) = A*X+B 
OTHER(D) = FIRST (E)+D 

If the statement Y = OTHER(Z) appears in a program 
in which the above functions are defined, the current 
values of A,B,E, and Z will be used in a calculation 
which is equivalent to: 
Y = A*E+B+Z 

Since the arguments of a are dummy arguments , 
their names may be the same as names appearing 
elsewhere in the program. Those variables in b 
that are not included in the dummy argument list are 
the parameters of the function and are defined as the 
ordinary variables appearing elsewhere in the source 
program. The type of each dummy argument is 
defined implicitly. 

A maximum of fifteen variables appearing in 
the expression m ay be used as arguments of the 
function. Since the variables used in references 
to the statement function will replace the dummy 
arguments, they must correspond in number 
and type to the dummy arguments. 

Any statement function appearing in b must have 
been previously defined. All definitions of statement 
functions must follow the Specification statements 
and precede the first executable statement of the 
source program. 

Statement functions are compiled as internal 
subprograms; therefore, they will appear only once 
in the object program. 

NOTE: The same dummy arguments may be used in 
more than one statement function definition and may 
also be used as variables outside statement function 
definitions. 



36 



FUNCTION Subprogram 

The FUNCTION subprogram is a FORTRAN sub- 
program consisting of any number of statements. 
It is like a FORTRAN-supplied FUNCTION sub- 
program in that it is an independently written pro- 
gram that is executed whenever its name appears in 
another program. In other words, if a user needs a 
function that is not available in the library, he can 
write it with FORTRAN statements. 



General Form : 

FUNCTION name (ai,a2,a3, 
(FORTRAN statements) 



• a n) 



The relationship between variable names in the 
calling program and the dummy names in the 
FUNCTION subprogram is illustrated in the follow- 
ing example: 



Calling 
Program 



A = SOMEF (B,C) 



FUNCTION 
Subprogram 

FUNCTION SOMEF (X,Y) 



SOMEF = X/Y 

RETURN 
END 



RETURN 
END 

where: 

name is a subprogram name. 

a]_, a.2, a3, ... a n are dummy arguments to be re- 
placed at execution time. Each argument used 
must be either a nonsubscripted variable name, 
an array name, or some other subprogram 
name (but it cannot be a statement function 
name). None of the dummy arguments may 
appear in an EQUIVALENCE statement in a 
FUNCTION subprogram. A FUNCTION sub- 
program must have at least one argument. 



The FUNCTION subprogram may contain any 
FORTRAN statement except a SUBROUTINE state- 
ment, a DEFINE FILE statement, or another 
FUNCTION statement and must return control to the 
calling program with a RETURN statement. Because 
the FUNCTION is a separate subprogram, the 
variables and statement numbers do not relate to 
any other program (except the dummy argument 
variables). 

The arguments of the FUNCTION subprogram may 
be considered to be dummy variable names. These 
are replaced at the time of execution by the actual 
arguments supplied in the function reference in the 
main program. The actual arguments must cor- 
respond in number, order, and type to the dummy 
arguments. They may be any of the following: any 
type of constant, any type of subscripted or non- 
subscripted variable, any other kind of arithmetic 
expression, or a subprogram name (they may not be 
statement function names). 



In the preceding example, the value of the variable 
B of the calling program is used in the subprogram as 
the value of the dummy variable X; the value of C is 
used in place of the dummy variable Y. Thus, if 
B = 10. and C = 5. 0, then A = 2. 0, that is, B/C. 

When a dummy argument is an array name, a 
DIMENSION statement must appear in the FUNCTION 
subprogram. The dimension information must 
generally be identical to the corresponding informa- 
tion in the calling program. For one- dimensional 
arrays it is sufficient if the dimension specified is 
equal to the highest constant subscript used in the 
subprogram. The DIMENSION statement in the 
FUNCTION subprogram permits the dummy argu- 
ment to be subscripted. Thus, if B is a 40-element 
array defined in a calling program, a method of 
passing elements of the array to a FUNCTION sub- 
program would be: 



Calling 
Program 



DIMENSION B(40) 



D = SOMEF (B,J) 



FUNCTION 
Subprogram 

FUNCTION SOMEF (X,ITER) 
DIMENSION X(40) 
SOMEF = 
DO 5 1 = 1,ITER 
5 SOME F = SOME F+X(I) 
RETURN 
END 



When an argument is a subprogram name, it must 
be declared in an EXTERNAL statement in the calling 
program. The following example illustrates the use 
of the EXTERNAL and DIMENSION statements with 
subprograms. 



Statements 37 



Page of GC26-37 15-7 
Revised May 1972 
By TNL GN34-0085 




Calling Program: 




EXTERNAL 


ABS 


DIMENSION 


A(4) 



1 = 3 

B = COMP(A,I,ABS) 



For example: 

Calling Program: 

ANS = ROOTl*CALC (X,Y,I) 

Function Subprogram: 

FUNCTION CALC (A,B,J) 



1 = J*2 



Called Subprogram: 

FUNCTION COMP(X, J, FUNCT) 
DIMENSION X(4) 
TEMP = 
DO 10 K = 1,J 
10 TEMP = TEMP + X(K) 
COMP = FUNCT (TEMP) 
RETURN 
END 

In this example, the resulting value of B returned to 
the calling program is equivalent to: 

B = ABS(A(1) + A(2) + A(3)) 



The value of the dummy arguments of a FUNCTION 
subprogram must not be redefined in the subprogram. 
That is, they must not appear on the left side of an 
arithmetic statement, in the I/O list of a READ 
statement, or as the index in a DO statement. 
Neither may variables that appear in COMMON be 
redefined within the FUNCTION subprogram. For 
example, the following violates this rule: 



FUNCTION SAM (A,B,K) 
COMMON J 
J = J + l 
K = J 



Within the called program, the name of a function 
may be defined by using it as 

1. a variable name on the left side of an arithmetic 
statement, 

2. in the I/O list of a read statement, 

3. in the argument list of a CALL statement, or 

4. as the index of a DO loop. 



CALC = A**I/B 



RETURN 
END 

In this example, the values of X,Y, and I are used 
in the FUNCTION subprogram as the values of A, B, 
and J, respectively. The value of CALC is computed 
and this value is returned to the calling program 
where the value of ANS is computed. 



Type Specification of the FUNCTION Subprogram 

The type of function may be explicitly stated by the 
inclusion of the word REAL or INTEGER before the 
word FUNCTION. For example: 

REAL FUNCTION SOMEF (A,B) 



RETURN 

END 

INTEGER FUNCTION CALC (X,Y,Z) 



RETURN 
END 

NOTE: The function type, if explicitly stated, must 
be defined in the calling program by use of the 
INTEGER or REAL Type statement. 

FORTRAN-supplied FUNCTION Subprograms 

FORTRAN-supplied FUNCTION subprograms are 
predefined FUNCTION subprograms that are part of 
the system library. A list of all the FORTRAN- 



38 



Page of GC26-37 15-8 
Revised February 1974 
ByTNLGN34-0181 

supplied FUNCTION subprograms is given in Table 1. 
Note that the type (real or integer) of each FUNCTION 
subprogram and its arguments are predefined and 
cannot be changed by the user. 

To use a FORTRAN-supplied FUNCTION sub- 
program, simply use the function name with the 
appropriate arguments in an arithmetic statement. 
| The arguments may be non-subscripted variables, 
constants, other types of arithmetic expressions, 
or other FORTRAN-supplied FUNCTION sub- 
programs. 



prefix is added to any variable name that is the same 
as the FORTRAN-supplied FUNCTION subprogram 
names. 

For detailed descriptions of the FORTRAN- 
supplied FUNCTION subprograms , refer to the 
appropriate Subroutine Library publication as 
listed in the Preface) . 



Examples : 

DISCR = SQRT(B**2-4.0*A*C) 
A = ABS(COS(B)) 

The use of the SQRT function in the first example 
causes the calculation of the square root of the 
expression (B**2-4. 0*A*C). This value replaces 
the current value of DISCR. 

In the second example, cosine B is evaluated and 
its absolute value replaces the current value of A. 

The FORTRAN compiler adds an E or an F in 
front of the names of FORTRAN-supplied FUNCTION 
subprograms to specify required precision. The 



SUBROUTINE SUBPROGRAM 

The SUBROUTINE subprogram is similar to the 
FUNCTION subprogram in many respects: the 
naming rules are the same, they both require a 
RETURN statement and an END statement, and they 
both contain the same sort of dummy arguments. 
Like the FUNCTION subprogram, the SUBROUTINE 
subprogram is a set of commonly used operations; 
but the SUBROUTINE subprogram is not restricted 
to a single result, as is the FUNCTION subprogram. 
A SUBROUTINE subprogram can be used for almost 
any operation with as many results as desired. 

The SUBROUTINE subprogram is called by the 
special FORTRAN statement, the CALL statement 
(see CALL Statement) . 



Table 1 . 


FORTRAN-supplied FUNCTION Subprograms 




Name 


Function Performed 


No. of 
Argu- 
ments 


Type of 
Argu- 
ment^) 


Type of 
Func- 
tion 


SIN 


Trigonometric sine (argument 
in radians) 




Real 


Real 


COS 


Trigonometric cosine (argu- 
ment in radians) 




Real 


Real 


ALOG 


Natural logarithm 




Real 


Real 


EXP 


Argument power of e 
(r.e.,e x ) 




Real 


Real 


SQRT 


Square root 




Real 


Real 


ATAN 


Arctangent 




Real 


Real 


ABS 


Absolute value 




Real 


Real 


IABS 


Absolute value 




Integer 


Integer 


FLOAT 


Convert integer argument 










to real 




Integer 


Real 


IFIX 


Convert real argument to 










integer 




Real 


Integer 


SIGN 


Transfer of sign (Arg, given 
sign of Arg 2 ) 


2 


Real 


Real 


ISIGN 


Transfer of sign (Arg, given 
sign of Arg 2 ) 


2 


Integer 


Integer 


TANH 


Hyperbolic tangent 


1 


Real 


Real 



General Form: 



SUBROUTINE name (a , a , a , . . . a ) 



RETURN 
END 

where: 

name is the subprogram name (see Subprogram 
Names ). 

a-L, a 2 , a3, . . . a n are the arguments (arguments are 
not necessary or may be located in COMMON). 
Each argument used must be a nonsubscripted 
variable name, array name, or other sub- 
program name (except that it may not be a 
statement function name). 

The SUBROUTINE subprogram may contain any 
FORTRAN statement except a FUNCTION statement, 
another SUBROUTINE statement, a DEFINE FILE 



Statements 39 



statement, or any other statement in which the 
SUBROUTINE name is used as a variable in an 
expression or list. 

Because the SUBROUTINE is a separate sub- 
program, the variables and statement numbers do 
not relate to any other program (except the dummy 
argument variables). The SUBROUTINE subprogram 
may use one or more of its arguments to return 
values to the calling program. Any arguments so 
used must appear on the left side of an arithmetic 
statement or in the I/O list of a READ statement 
within the subprogram. 

The arguments may be considered dummy variable 
names that are replaced at the time of execution 
by the actual arguments supplied in the CALL state- 
ment. The actual arguments must correspond in 
number, order, and type to the dummy arguments. 
None of the dummy arguments may appear in an 
EQUIVALENCE statement in a SUBROUTINE sub- 
program. When the argument is an array name, a 
DIMENSION statement must appear in the 
SUBROUTINE subprogram. The dimension informa- 
tion must generally be identical to the corresponding 
information in the calling program. For one- 
dimensional arrays it is sufficient if the dimension 
specified is equal to the highest constant subscript 
used in the subprogram. 



END AND RETURN STATEMENTS IN SUBPROGRAMS 

Note that all of the preceding examples of sub- 
programs contain both an END and at least one 
RETURN statement. The END statement specifies 
the end of the subprogram for the compiler; the 
RETURN statement signifies the conclusion of a 
computation and returns any computed value and 
control to the calling program. There may, in fact, 
be more than one RETURN statement in a FUNCTION 
or SUBROUTINE subprogram. For example: 

FUNCTION DAV (D, E , F) 
IF(D-.1)2,3,2 



DAV = 



RETURN 
DAV = . . 



RETURN 
END 



40 



SUBPROGRAMS WRITTEN IN ASSEMBLER 
LANGUAGE 



Subprograms can be written in the 1130 or 1800 
Assembler Language to be called by a FORTRAN 
program. In order to write such subprograms, the 
user must know the linkage generated by the 
FORTRAN Compiler and the location of the arguments. 

The linkage to all three types of subprograms 
(SUBROUTINE subprograms, FUNCTION subpro- 
grams, FORTRAN- supplied FUNCTION subprograms) 
is assembled and executed in the same way as the 
Assembler Language CALL statement (see the 
appropriate Assembler Language publication 
as listed in the Preface ). 

The arguments in the linkage are located as 
follows: At execution time, the Branch instruction 
corresponding to the CALL is followed in storage 
by a list of the addresses of the arguments. 



If any of the parameters is another subroutine, 
the generated entry for the parameter is a branch 
instruction. This is a short BSI 3 to a three word 
Transfer Vector entry for Library Subroutines, or 
a long BSI I(through a table of branch addresses) or 
BSI L (directly to the subroutine) if the parameter is 
a CALL -type subroutine. The BSI L instruction ap- 
pears only in 1800 systems and only when the sub- 
routine is in the same part of core as the call. 

When a SUBROUTINE subprogram CALL is used, 
results of the computations within the subprogram 
will be returned by means of the arguments. The 
Assembler coded SUBROUTINE subprogram must 
return control to the calling program at the next 
location following the last argument in the list. 

FUNCTION Subprogram reference or 
FORTRAN-supplied FUNCTION 
subprogram reference: 

X = Y+ JOE(A,B,C) 



Examples: 

SUBROUTINE subprogram CALL: 
CALL JOE (A, B, C) 
Contents of core storage at execution: 







BSI L (Address of entry point of JOE), 
for 1800 systems, 

BSI (Address of CALL TV entry for JOE), 
for 1130 systems. 



ADDRESS OF A 



ADDRESS OF B 



ADDRESS OF C 



First Word of Next Instruction 



Subprogram should return here. 



The underlined section of the above statement 
produces the same result in core storage as the 
SUBROUTINE subprogram example. It must be noted, 
however, that the Assembler coded FUNCTION sub- 
program must return a single result to the calling 
program by means of the real number pseudo- 
accumulator, referred to as FAC, or the machine 
accumulator (A -register in the 1800), depending on 
whether the function type is real or integer. That 
is , assuming JOE is a real function in the above 
example, the computed result of JOE(A,B, C) must 
be placed in FAC by the Assembler coded subpro- 
gram, since the contents of FAC will be added to 
Y to yield X. (For a description of FAC, refer to 
the Real Number Pseudo-Accumulator in the 
applicable Subroutine Library manual. ) The 
argument list must not be used to return a result 
of the subprogram computation. 



Statements 41 



COMPILATION MESSAGES 



This section lists the FORTRAN messages and 
error codes that apply to the 1130 Disk Monitor 
System, Version 2, the 1800 Multiprogramming 
Executive Operating System, and the 1800 Time- 
Sharing Executive Operating System. 
At the end of the compilation, information about 
main- storage usage and the features supported is 
printed. 

Table 2. 1130 Disk Monitor System, Version 2, Special Error 



Error Number and Message 


Cause of Error 


C85 ORIGIN IN 


An ORIGIN control record was 


SUBPROGRAM 


detected in a subprogram 




compilation. 


C86 INVALID ORIGIN 


An attempt has been made to 




relocate a word at an address 




exceeding 7FFF (hexadecimal). 


C96 WORKING STORAGE 


The working storage area on disk 


EXCEEDED 


is too small to accommodate the 




compiled program in disk system 




format. 


C97 PROGRAM LENGTH 


The program in internal compiler 


EXCEEDS CAPACITY 


format is too large to be contained 




in core working storage, and the 




program must be reduced in size in 




order to compile. 


C98 SUBROUTINE 


During compilation of subprograms 


INITIALIZE TOO 


a subroutine initialize statement 


LARGE 


(CALL SU BIN) is generated. 




The CALL SUBIN statement 




initializes all references to dummy 




variables contained within the 




subprogram to the appropriate main 




storage location in the calling 




program. 




The nature of the FORTRAN 




Compiler limits the size of any 




statement in internal compiler 




format to 51 1 words. In the case 




of CALL SUBIN, the size is 




calculated by the following formula: 




S=5+ARG+N 




where ARG is the number of 




arguments in the subroutine 




parameter list and N is the total 




number of times the dummy 




arguments are used within the 




subprogram. S is the total size of 




the CALL SUBIN statement; if S 




ever exceeds 51 1 , the above error 




message is printed. 


C99 CORE REQUIREMENTS 


The total main-storage requirements 


EXCESSIVE 


exceed 32,767 words. 



1130 Disk Monitor System, Version 2 
The following information is printed. 

FEATURES SUPPORTED 

EXTENDED PRECISION 

ONE WORD INTEGERS 

TRANSFER TRACE 

ARITHMETIC TRACE 

ORIGIN 

IOCS 
CORE REQUIREMENTS FOR XXXXX 
COMMON YYYYY VARIABLES YYYYY 
PROGRAM YYYYY 

where XXXXX is the name of the program 
designated in the *NAME control statement or in 
the SUBROUTINE or FUNCTION statement, and 
YYYYY is the number of words allocated for the 
specified parts of the program. 

The following messages are printed in the case 
of successful and unsuccessful compilations 
respectively. 

END OF COMPILATION 
COMPILATION DISCONTINUED 

1800 Multiprogramming and Time- Sharing Executive 
Operating Systems 

The following information is printed. 

FEATURES SUPPORTED 
NONPROCESS 
EXTENDED PRECISION 
ONE WORD INTEGERS 
TRANSFER TRACE 
ARITHMETIC TRACE 
IOCS 

CORE REQUIREMENTS FOR XXXXX 
COMMON YYYYY INSKEL COMMON YYYYY 
VARIABLES YYYYY PROGRAM YYYYY 



where XXXXX is the name of the program 
designated by a // FOR control statement or by 
a SUBROUTINE or FUNCTION statement, and 
YYYYY is the number of words allocated for the 
specified parts of the program. Unreferenced 
statement numbers are also listed. 



42 



Page of GC26-3715-7 
Revised October 1972 
By TNL GN34-0085 



Table 3. 1800 MPX Special Messages 



COMPILATION ERROR MESSAGES 



Message 


Cause of Message 


INVALID 


The statements containing errors are 


STATEMENTS 


about to be printed. 


PROGRAM LENGTH 


String/Symbol Table overlap has occurred 


EXCEEDS CAPACITY 


during compilation, that is, VCORE is 




too small to compile the program. 




Compilation is terminated. 


UNDEFINED 


The following variables do not appear in 


VARIABLES 


a DATA statement, as a subprogram 




argument, or to the left of an equals sign. 




Compilation is terminated. 


UTAPE/UDISK 


Both unformatted tape and unformatted 


BOTH SPECIFIED 


disk I/O were requested. Compilation is 




terminated. 


OUTPUT HAS BEEN 


This message follows all the above error 


SUPPRESSED 


messages. No object code is stored to 




working storage. 


UNREFERENCED 


The following statement numbers are not 


STATEMENTS 


referenced. They may be deleted. 




Compilation continues. 


COO NO PROGRAM 


No name was specified for the program by 


NAME SPECIFIED 


the // FOR statement or a SUBROUTINE 




or FUNCTION statement. Compilation 




is terminated. 


CARD READER 


The card reader was found to be off line. 


OFF LINE 


Compilation is terminated. 


CORE 


The sum of all main storage necessary for 


REQUIREMENTS 


the compiled object program exceeds 32K. 


EXCEED 32K 




INVALID *SRFLE 


The disk file containing the source 


FILE 


program is in error, the file protect 




characters of the // FOR statement do not 




match the file protect characters of the 




*SRFLE statement that stored the 




program, or the file does not contain an 




END statement. 


SUBROUTINE 


The SUBROUTINE INITIALIZE 


INITIALIZE 


statement used for dummy arguments is 


TOO LARGE 


too long for the string area available. 




Compilation is terminated. 


WORKING STORAGE 


The working storage area on disk is too 


EXCEEDED 


small to accommodate the object code of 




the program being compiled. Compilation 




is terminated. 


COMPILATION 


Compilation was unsuccessful. The object 


DISCONTINUED 


program is not stored to working storage 




and may not be executed. 


END OF 


Compilation was successful. The object 


COMPILATION 


program has been stored to working 




storage and may be executed or stored 




elsewhere. 



During compilation, a check is made to determine 
whether certain errors have occurred. If one or 
more of these errors have been detected, the error 
indications are printed at the conclusion of 
compilation, and no object program is stored on 
disk. Only one error is detected for each 
statement. In addition, because of the interaction 
of error conditions, the occurrence of some errors 
may prevent the detection of others until those which 
have been detected are corrected. 

With the exception of the messages listed in Tables 
2-4, the error messages appear, for both specification 
and executable statements, in the following format: 

C NN ERROR IN STATEMENT NUMBER XXXXX+YYY 

C NN is the error code number in Appendix F. 
XXXXX is all zeros until the first numbered state- 
ment is encountered in your program. When a valid 
statement number is encountered, XXXXX is re- 
placed by that statement number. Statement numbers 
on specification statements and statement functions 
are ignored. 

When XXXXX is all zeros, YYY is the statement 
line in error (excluding comments and continuation 
lines). When XXXXX is a valid statement number, 
YYY is a count of statements from that numbered 
statement (counted as 0) to the statement in error. 
If the erroneous statement has a statement number, 
YYY is not printed. 



Compilation Messages 43 



Page of GC26-3715-7 
Revised October 1972 
By TNL GN34-0085 



Table 4. 1800 TSX 00 and Special Error Messages 



Message 



COO NO PROG NAME 
SPECIFIED 

COO WORKING 

STORAGE 

EXCEEDED 

COO COMMON 
EXCEEDS 32K 

SUBROUTINE 
INITIALIZE 
TOO LARGE 



PROGRAM 
LENGTH EXCEEDS 
CAPACITY 

END OF 
COMPILATION 

OUTPUT HAS BEEN 
SUPPRESSED 



Cause of Error 



No name for the program being compiled 
was specified. Compilation is terminated 
and control is returned to the Supervisor. 

The working storage area on disk was too 
small to accommodate the source string 
and symbol table for the program being 
compiled. Compilation is terminated. 
COMMON or COMMON/INSKEL/ 
was defined larger than 
32K in the program being compiled. 

During compilation of subprograms a 
subroutine initialize statement (CALL 
SUBIN) is generated. 

The CALL SUBIN statement initializes all 
references to dummy variables contained 
within the subprogram to the appropriate 
main-storage location in the calling 
program. 

The nature of the FORTRAN Compiler 
limits the size of any statement in internal 
compiler format to 51 1 words. In the case 
of CALL SUBIN, the size is calculated by 
the following formula: 
S = 5 + ARG + N 
where ARG is the number of arguments 
in the subroutine parameter list and N is 
the total number of times the dummy 
arguments are used within the subprogram. 
S is the total size of the CALL SUBIN 
statement; if S ever exceeds 51 1 , the above 
error message is printed. 

An overlap error has occurred during 
compilation, that is, VCORE is too small 
to compile the program. Compilation 
is terminated. 

Compilation has ended, with or without 
errors. 

Output to disk by the outputting phases 
has been suppressed because of 
compilation syntax errors. 



For example: 

DIMENSION E (1, 6, 6) 
DIMENSION F(4, 4), G(2, 7), 
1H(34,21),I(5,8) 



DIMENSION J (3, 2, 6)) 
FORMAT (150, F5. 2)) 
10 WRITE (l'C) ARRAY 
WRITE (l'C) ARRAYS 



(error C 08) 

(recall that the 1 
in column 6 indi- 
cates a continua- 
tion line) 
(error C 16) 
(error C 27) 

(error C 07) 



This sequence of statements will cause the 
following error messages to be printed. 

C 08 ERROR AT STATEMENT 00000+001 
C 16 ERROR AT STATEMENT 00000+003 
C 27 ERROR AT STATEMENT 00000+004 
C 07 ERROR AT STATEMENT 10 +001 



Note that a FORTRAN error message can be 
caused by an illegal character in the source 
statement. In that case, the character in question 
is replaced by an ampersand in the listing. 



44 



APPENDIX A. SYSTEM/STATEMENT CROSS-REFERENCE TABLE 



In the table below, the FORTRAN statements 
described in this publication are listed alphabetically 
at the left. There is one column at the right for each 



of the IBM 1130 and 1800 programming systems 
supported. An 'x' in a column indicates that the 
statement on the left applies to the programming 
system named at the top of that column. 





8. 






Cc 






o S E 


o'c E c 


o'H E c 


o fc E 


85 I 




~ §•■£ 


2JS-S 


= 3 5-S 


g S.U 


2 && 




"O 


■X<^ S 




-fi- 








a ~" 


a ~- 








U 






u 




Arithmetic Statement 


X 


X 


X 


X 


X 


BACKSPACE 






X 1 


X 


X 


CALL EXIT 




X 


X 




X 


CALL LINK 




X 


X 




X 


CALL LOAD 


X 2 






X 2 




CALL name 


X 


X 


X 


X 


X 


CALL PDUMP 






X 






CALL SSWTCH 








X 


X 


Comments statement 


X 


X 


X 


X 


X 


COMMON 


X 


X 


X 


X 


X 


COMMON/INSKEL/ 










X 


CONTINUE 


X 


X 


X 


X 


X 


DATA 






X 




X 


DEFINE FILE 




X 


X 




X 


DIMENSION 


X 


X 


X 


X 


X 


DO 


X 


X 


X 


X 


X 


END 


X 


X 


X 


X 


X 


END FILE 






X 1 


X 


X 


EQUIVALENCE 


X 


X 


X 


X 


X 


EXTERNAL 


X 


X 


X 


X 


X 


FIND 




X 


X 




X 


FORMAT 


X 


X 


X 


X 


X 


FUNCTION 


X 


X 


X 


X 


X 


GO TO, computed 


X 


X 


X 


X 


X 


GO TO, unconditional 


X 


X 


X 


X 


X 


IF 


X 


X 


X 


X 


X 


INTEGER 


X 


X 


X 


X 


X 


INTEGER FUNCTION 


X 


X 


X 


X 


X 


PAUSE 


X 


X 


X 


X 


X 


READ, disk I/O 




X 


X 




X 


READ, non-disk I/O 


X 


X 


X 


X 


X 


READ, unformatted I/O 






X 


X 


X* 


REAL 


X 


X 


X 


X 


X 


REAL FUNCTION 


X 


X 


X 


X 


X 


RETURN 


X 


X 


X 


X 


X 


REWIND 






X 1 


X 


X3 


Statement Function Statement 


X 


X 


X 


X 


X 


STOP 


X 


X 


X 


X 


X 


SUBROUTINE 


X 


X 


X 


X 


X 


WRITE, disk I/O 




X 


X 




X 


WRITE, non-disk I/O 


X 


X 


X 


X 


X 


WRITE, unformatted I/O 






X 


X 


X 4 



1. Simulated in the 1130 Disk Monitor System, Version 2 

2. Card version only. 

3. Simulated for unformatted disk in 

4. Both unformatted disk and magn. 



1800 MPX. 
tic tape operations are supported under 1800 MPX. 



Appendix A. System/ Statement Cross-Reference Table 45 



APPENDIX B. COMPARISON OF USA STANDARD FORTRAN AND IBM 1130/1800 FORTRAN LANGUAGES 



This appendix compares the USA Standard FORTRAN, 
as found in the following documents: 



BASIC FORTRAN 
FORTRAN 



X 3. 10-1966 
X 3.9-1966 



with the FORTRAN language for the IBM 1130 Card/ 
Paper Tape Programming System, the IBM 1130 Disk 
Monitor System, Version 1, the IBM Disk Monitor 
System, Version 2, the IBM 1800 Card/Paper Tape 
Programming System, and the IBM 1800 TSX and 
MPX Systems. 





USA 

Standard, 

Full 


USA 

Standard, 
Basic 


1130 
Card/ 
Paper 
Tape 


1130 
Monitor, 
Version 1 


1130 
Monitor, 
Version 2 


1800 

Card/ 
Paper 
Tape 


1800 
TSX/MPX 


Character Set 

A-Z 

0-9 
blank=+ -*/(),. 

S 
(apostrophe) 


Yes 
Yes 
Yes 
Yes 

No 


Yes 
Yes 

Yes 
No 
No 


Yes 
Yes 
Yes 
Yes 
Yes 


Yes 
Yes 
Yes 
Yes 
Yes 


Yes 
Yes 
Yes 
Yes 
Yes 


Yes 
Yes 
Yes 
Yes 
Yes 


Ye * 
Yes 
Yes 
Yes 
Yes 


Statement Continuation 
Lines 


19 


5 


5 


5 


5 


5 


5 


Numeric Statement 
Label 


1 to 5 


1 to 4 


1 to 5 


1 to 5 


1 to 5 


1 to 5 


1 to 5 


Variable Name 


1 to 6 


1 to 5 


1 to 5 


1 to 5 


1 to 5 


1 to 5 


1 to 5 


Data Types 
Integer 
Real* 

Double Precision 
Complex 
Logical 
Hollerith 


Yes 
Yes 
Yes 
Yes 
Yes 
Yes 


Yes 
Yes 
No 
No 

No 
No 


Yes 
Yes 
No 
No 
No 
No 


Yes 
Yes 
No 
No 
No 
No 


Yes 
Yes 
No 
No 
No 
No 


Yes 
Yes 
No 
No 
No 
No 


Yes 
Yes 
No 
No 
No 
No 


Real Constant 

Basic Real Constant 
Integer Constant 
followed by a 
decimal exponent 


Yes 
Yes 


Yes 
No 


Yes 

No 


Yes 

No 


Yes 
No 


Yes 

No 


Yes 

No 


Double Precision Constant 
Real Constant with 
D ' in place of ' E 


Yes 


No 


No 


No 


No 


No 


No 


Number of Array 
Dimensions 


3 


2 


3 


3 


3 


3 


3 


Relational Exoressions 


Yes 


No 


No 


No 


No 


No 


No 


Logical Operators 


Yes 


No 


No 


No 


No 


No 


No 


Assigned GO TO 


Yes 


No 


No 


No 


No 


No 


No 


Logical IF 


Yes 


No 


No 


No 


No 


No 


No 


DO - Extended Range 


Yes 


No 


Yes 


Yes 


Yes 


Yes 


Yes 


READ and WRITE 

READ/WRITE (Formatted) 
READAVRITE (Unformatted) 


Yes 
Yes 


Yes 
Yes 


Yes 
No 


Yes 

No 


Yes 
Yes 


Yes 
Yes 


Yes 
Yes 


Auxiliary I/O Statements 
REWIND 
BACKSPACE 
ENDFILE 


Yes 
Yes 
Yes 


Yes 
Yes 
Yes 


N.A. 
N.A. 
N.A. 


N.A. 
N.A. 
N.A. 


Yes 
Yes 
Yes 


Yes 
Yes 
Yes 


Yes 
Yes 
Yes 


Formatted Records 

1st character not printed 
Space before printing 
blank 1 line 

2 lines 

1 1st line, new page 
+ no advance 


Yes 

Yes 
Yes 
Yes 
Yes 


Yes 

No 
No 
No 
No 


Yes 

Yes 
Yes 
Yes 
Yes 


Y'es 

Ye! 
Yes 
Yes 
Yes 


Yes 

Yes 
Yes 
Yes 
Yes 


Yes 

Yes 
Yes 
Yes 
Yes 


Yes 

Yes 
Yes 
Yes 
Yes 


Adjustable Dimension 


Yes 


No 


No 


No 


No 


No 


No 



* Precision specified at compile time. 



46 





USA 

Standard, 

Full 


USA 

Standard, 

Basic 


1130 
Card/ 
Paper 
Tape 


1)30 
Monitor, 
Version 1 


1130 
Monitor, 
Version 2 


1800 
Card/ 
Paper 
Tape 


1800 
TSX/MPX 


Common 
Blank 
Named 
Array Size Declared 


Yes 
Yes 
Yes 


Yes 
No 
No 


Yes 

No 
Yes 


Yes 
No 
Yes 


Yes 
No 
Yes 


Yes 

No 
Yes 


Yes 

Yes*'' 

Yes 


External Statement 


Yes 


No 


Yes 


Yes 


Yes 


Yes 


Yes 


Type Statement 

Dimension Information 


Yes 
Yes 


No 
No 


Yes 
Yes 


Yes 
Yes 


Yes 
Yes 


Yes 
Yes 


Yes 
Yes 


Data Statement 


Yes 


No 


No 


No 


Yes 


No 


Yes 


Format Types 
A 
D 
E 
F 
G 
H 

" " (Literal) 

1 

L 
T 

X 


Yes 
Yes 
Yes 
Yes 
Yes 
Yes 
No 
Yes 
Yes 
No 

Yes 


No 
No 
Yes 
Yes 
No 
Yes 

No 
Yes 
No 
No 
Yes 


Yes 
No 
Yes 
Yes 
No 
Yes 
Yes 
Yes 
No 
No 
Yes 


Yes 
No 
Yes 
Yes 
No 
Yes 

Yes 

Yes 
No 
No 
Yes 


Yes 
No 
Yes 
Yes 
No 
Yes 

Yes 
Yes 
No 
Yes 
Yes 


Yes 
No 
Yes 
Yes 
No 
Yes 

Yes 
Yes 
No 
No 
Yes 


Yes 
No 
Yes 
Yes 
No 
Yes 

Yes 
Yes 
No 
Yes 
Yes 


Format 

(Parenthesis Levels) 


2 


1 


1 


1 


1 


1 


1 


Scale Factor 


Yes 


No 


No 


No 


No 


No 


No 


Blanks in Numeric Conversions 
High -Order 
Within the field 


Zero 
Zero 


Zero 
Error 


Zero 
Zero 


Zero 
Zero 


Zero 
Zero 


Zero 
Zero 


Zero 
Zero 


Real Conversions 

Integer plus Exponent 
E Type Exponent 
D Type Exponent 


Yes 
Yes 


Yes 

No 


Yes 

No 


Yes 

No 


Yes 
No 


Yes 

No 


Yes 
No 


Format During Execution 


Yes 


No 


No 


No 


No 


No 


No 


Statement Function must 
precede the first 
executable statement and 
follow the specification 
statements 


Yes 


Yes 


Yes 


Yes 


Yes 


Yes 


Yes 


Type Specification in a 
Function Statement 


Yes 


No 


Yes 


Yes 


Yes 


Yes 


Yes 


Function May Define or 
Redefine its Arguments 


Yes 


No 


No 


No 


No 


No 


No 


Transmit in a Call 
Hollerith Arguments 
External Subprogram 
Names 


Yes 
Yes 


No 
No 


No 
Yes 


No 
Yes 


No 
Yes 


No 
Yes 


No 
Yes 


Block Data Subprogram 


Yes 


No 


No 


No 


No 


No 


No 


Specification Statements 
Precede first executable 
Statement 
Must be ordered 
DIMENSION 
COMMON 
EQUIVALENCE 


Yes 

No 


Yes 
Yes 


Yes 
Yes 


Yes 
Yes 


Yes 
Yes 


Yes 

Yes 


Yes 
Yes 



*" Only the name INSKEL, specifying the Skeleton COMMON area, is allowed. 



Appendix B. Comparison of USA Standard FORTRAN and IBM 1130/1800 FORTRAN Languages 47 





USA 

Standard, 

Full 


USA 

Standard, 

Basic 


1130 

Card/ 
Paper 
Tape 


1130 
Monitor, 
Version 1 


1130 
Monitor, 
Version 2 


1800 

Card/ 
Paper 
Tape 


1800 
TSX/MPX 


External Function may alter 
variables in COMMON 


Yes 


No 


No 


No 


No 


No 


No 



LANGUAGE FEATURES NOT IN USA STANDARD FORTRAN 



Feature 


1130 
Card/ 
Paper 
Tape 


1 130 

Monitor, 
Version 1 


1130 
Monitor, 
Version 2 


1800 

Card/ 
Paper 
Tape 


1800 
TSX/MPX 


Mixed mode Arithmetic 


Yes 


Yes 


Yes 


Yes 


Yes 


Disk Statements 


No 


Yes 


Yes 


No 


Yes 


T format 


No 


No 


Yes 


No 


Yes 


Literal Format code 


Yes 


Yes 


Yes 


Yes 


Yes 


Expression of the 












form A»» B »»C 


Yes 


Yes 


Yes 


Yes 


Yes 


Machine indicator tests 


Yes 


Yes 


Yes 


Yes 


Yes 


Source characters 












(3), &, *, <, % 


Yes 


Yes 


Yes 


Yes 


Yes 



48 



Page of GC26-37 15-8 
Revised February 1974 
ByTNLGN34-0181 



APPENDIX C. 1130/1800 FORTRAN SOURCE PROGRAM CHARACTER CODES 







PTTC/8 Hex 






PTTC/8 Hex 






(U = Upper Case) 






(U = Upper Case) 


Character 


IBM Card Code 


(L = Lower Case) 


Character 


IBM Card Code 


(L = Lower Case) 


Numeric Characters* 




Alphabetic Characters* 










1A(L) 


S 


0-2 


32 (U) 


1 


1 


01 (L) 


T 


0-3 


23 (U) 


2 


2 


02 (L) 


U 


0-4 


34 (U) 


3 


3 


13 (L) 


V 


0-5 


25 (U) 


4 


4 


04 (L) 


W 


0-6 


26 (U) 


5 


5 


15 (L) 


X 


0-7 


37 (U) 


6 


6 


16 (L) 


Y 


0-8 


38 (U) 


7 


7 


07 (L) 


Z 


0-9 


29 (U) 


8 


8 


08 (L) 








9 


9 


19 (L) 








Alphabetic Characters* 




Special Characters* 




A 


12-1 


61 (U) 




12-8-3 


6B(L) 


B 


12-2 


62 (U) 


< 


12-8-4 


02 (U) 


C 


12-3 


73 (U) 


( 


12-8-5 


19 (U) 


D 


12-4 


64 (U) 


+ 


12-8-6 


70 (U) 


E 


12-5 


75 (U) 


& 


12 


70 (L) 


F 


12-6 


76 (U) 


$ 


11-8-3 


5B(L) 


G 


12-7 


67 (U) 


* 


11-8-4 


08 (U) 


H 


12-8 


68 (U) 


) 


11-8-5 


1A(U) 


I 


12-9 


79 (U) 


- 


11 


40 (L) 


J 


11-1 


51 (U) 


/ 


0-1 


31 (L) 


K 


11-2 


52 (U) 


» 


0-8-3 


3B(L) 


L 


11-3 


43 (U) 


% 


0-8-4 


15 (U) 


M 


11-4 


54 (U) 


# 


8-3 


0B(L) 


N 


11-5 


45 (U) 


@ 


8-4 


20 (L) 


O 


11-6 


46 (U) 


t 


8-5 


16 (U) 


P 


11-7 


57 (U) 


= 


8-6 


01 (U) 


Q 


11-8 


58 (U) 


Space 


Blank 


10 ( ) 


R 


11-9 


49 (U) 








NOTES: 






with an 


asterisk by the 1130 DM2 system or 



1. At compilation time, the following character 
punches are treated as equal, and the characters 
to the left of the "and" are printed: 

' and @ ) and < 

+ and & ( and % 

= and# 
Any invalid character is printed as an ampersand 
on all systems except 1800 TSX and MPX. If the 
FORTRAN compiler in the TSX system uses the 
card routine in the skeleton, a blank will be 
printed out. If the TSX FORTRAN compiler uses 
its own card routine, an ampersand is printed out. 
1800 MPX prints a blank for an invalid character. 

2. Only the 53 characters shown above can be 
handled at execution time through A or H type 
formatting in the FORTRAN Input/ Output 
routines. Any other character is replaced 



with a blank (space) by all other systems. 
3. At execution time no transformations, such as 
& converted to +, etc. , are made through A 
or H conversion; however, the & is converted 
to + when read with I, E, or F conversions at 
execution time, and when read with A or H 
conversions at compilation time. For example, 
the statement: 

FORMAT (1H , '&#') 
is listed as: 

FORMAT (1H , '4=') 
at compilation time, and as: 

at execution time. 



* The term, alphameric characters, as used in this publication, 
includes Special Characters. 



Appendix C. 1130/1800 FORTRAN Source Program Character Codes 49 



Page of GC26-37 15-8 
Revised February 1974 
ByTNLGN34-0181 



APPENDIX D. IMPLEMENTATION RESTRICTIONS 



. 1. No FORTRAN statement can be compiled that 
contains more than 15 different subscript 
expressions. 

2. Certain very long FORTRAN statements cannot be 
compiled since they expand to a size that is too 
long to be scanned. This expansion by the com- 
piler occurs in handling subscript expressions and 
in generating temporary storage locations for 
arithmetic expressions. 

3. FORTRAN supplied subprograms, FLOAT, and 
IFIX may not be used in EXTERNAL statements. 

4. Within A, H, I, T, and X specifications in 
FORMAT statements, the field width "w" may 
not be greater than 156. 

5. Within E and F specifications the field width 
"w" may not be greater than 127 and the number 
of decimal places specified for "d" may not be 
greater than 31. Within F specifications, if a 
field width "w" greater than 24 is specified for 
card input, the number of punched digits in the 
integer part plus the decimal part of the input 
field must not exceed 24. Leading zeros are 
not counted. 

6. The repetition specification for groups and fields 
and the total width specification for a record may 
not be greater than 156. 

7. The size of COMMON specified in a mainline 
program must be at least as large as the largest 
COMMON specified in any subprogram. 

8. A maximum of 75 files can be specified in 
DEFINE FILE statements per program. 



9. When standard precision is used, it is possible 
for two quantities representing the same value to 
yield a non-zero result when subtracted from one 
another due to the extra eight bits of precision in 
FAC not used by standard precision. The non- 
zero result, although not reflected in the first 
seven significant digits, will affect an IF state- 
ment test. 

10. Variables used in subscript expressions should 
not be equivalenced to other variables which 
may change their value. If they are equivalenced, 
the new value assumed by the equivalenced 
variable may be disregarded by the variable 

in the subscript expression. 

11. In a DATA'statement, the maximum value of the 
constant repeat index is 4095, for example, 

in DATA V/i*d/ , 1^ i^ 4095. 

12. The sequence of data card placement in the 
1442 Card Read Punch hopper must correspond 
to the sequence of I/O operations. A card 
will be read if it is the next card in the 

hopper when a READ operation is executed. The 
same card will also be punched if the next I/O 
operation in the FORTRAN program is a WRITE 
on the 1442 and the FORMAT specification for 
this output operation does not start by indicating 
a new record. 

13. In the definition of an array, the integer constant 
specifying a subscript must be a minimum of 2; 
for example, the statement: DIMENSION A(l, 4) 
would not be acceptable. 



50 



APPENDIX E. SOURCE PROGRAM STATEMENTS AND SEQUENCING 



Every executable statement in a source program 
(except the first) must have some programmed path 
of control leading to it. Control originates at the 
first executable statement in the program and is 
passed as follows. 



Statement 
a = b 
CALL 

COMMON 
CONTINUE 

DATA 

DEFINE FILE 

DIMENSION 

DO 

EQUIVALENCE 
EXTERNAL 

FORMAT 



Normal Sequence 

Next executable statement 

First executable statement of 
called subprogram 

Nonexecutable 

Next executable statement or 
first statement of a DO loop 

Nonexecutable 

Nonexecutable 

Nonexecutable 

DO sequencing, then the next 
executable statement 

Nonexecutable 
Nonexecutable 

Nonexecutable 



Statement 

FUNCTION 
GO TO n 

GO TO (n lf 
n 2 ,...n m ), i 



Normal Sequence 



INTEGER 

PAUSE 

READ 

REAL 

RETURN 



STOP 

SUBROUTINE 

WRITE 



Nonexecutable 
Statement n 

Statement n 5 



IF(a)S-^,S2,S3 Statement S^ if arithmetic a < 



Statement S 2 if arithmetic a = 



Statement S3 if arithmetic a ? 

Nonexecutable 

Next executable statement 

Next executable statement 

Nonexecutable 



The first statement following the 
reference to this subprogram un- 
less computation has not been 
completed for the statement con- 
taining the reference. 

Terminate execution 

Nonexecutable 

Next executable statement 



Appendix E. Source Program Statements and Sequencing 51 



Page of GC26-3715-7 
Revised October 1972 
By TNL GN34-0085 



APPENDIX F. ERROR CODES 



The error codes listed below are for the 1130 
Disk Monitor System, Version 2, the 1800 
Multiprogramming Executive Operating System 
(MPX), and the 1800 Time-Sharing Executive 
Operating System (TSX). Most of the error codes 
are the same for all three systems; where they 
differ in meaning, a separate definition is supplied 
for the system that is different from the others. 
In the table below, DM2 stands for the 



1130 Disk Monitor System, MPX for the 1800 
Multiprogramming Executive system, and TSX 
for the 1800 Time-Sharing Executive system. 
Some of the errors are caused by errors in control 
statements. For an explanation of these 
statements, refer to the appropriate manual: for 
DM2 — Programming and Operator's Guide, Form 
C26-3717; for MPX — Programmer's Guide, Form 
C26-3720; for TSX-Concepts and Techniques, Form 
C26-3703. 



Error 
Code 



C01 
C02 

C03 

C04 
C05 
C06 



C07 

C08 

C09 
C10 
C11 
C12 
C13 
C14 

C15 
C16 
C17 
C18 

C19 
C20 

C21 



Cause of Error 



Non-numeric character in statement number. 

More than five continuation cards, or continuation card out of 
sequence. 

Syntax error in CALL LINK or CALL EXIT statement, or, in 
TSX, CALL LINK or CALL EXIT in process program. 

Undeterminable, misspelled, or incorrectly formed statement. 

Statement out of sequence. 

First executable statement following STOP, RETURN, CALL 
LINK, CALL EXIT, GO TO, or IF statement does not have 
a statement number, or, in MPX or TSX, a CALL statement 
does not have a statement number. 

Name longer than five characters, or name not starting with 
an alphabetic character. 

Incorrect or missing subscript within dimension information 
(DIMENSION, COMMON, REAL, or INTEGER). 

DupJicate statement number. 

Syntax error in COMMON statement. 

Duplicate name in COMMON statement. 

Syntax error in FUNCTION or SUBROUTINE statement. 

Parameter (dummy argument) appears in COMMON statement. 

Name appears twice as a parameter in SUBROUTINE or 
FUNCTION statement. 

DM2 and TSX: *IOCS control statement in a subprogram. 

Syntax error in DIMENSION statement. 

Subprogram name in DIMENSION statement. 

Name dimensioned more than once, or not dimensioned on 
first appearance of name. 

Syntax error in REAL, INTEGER, or EXTERNAL statement. 

Subprogram name in REAL or INTEGER statement, or, in 
DM2, a FUNCTION subprogram containing its own name in 
an EXTERNAL statement. 

Name in EXTERNAL that is also in a COMMON or 
DIMENSION statement. 



Error 
Code 



C22 
C23 
C24 
C25 

C26 
C27 
C28 
C29 

C30 



C31 
C32 
C33 

C35 



C36 

C37 
C38 
C39 
C40 



Cause of Error 



IFIXor FLOAT in EXTERNAL statement. 

Invalid real constant. 

Invalid integer constant. 

More than 15 dummy arguments, or duplicate dummy 
argument in statement function argument list. 

Right parenthesis missing from a subscript expression. 

Syntax error in FORMAT statement. 

FORMAT statement without statement number. 

DM2 and TSX: Field width specification greater than 145 
columns. MPX: Field width specification greater than 156 
columns. 

In a FORMAT statement specifying E or F conversion, w 
greater than 127, d greater than 31, or d greater than w, where 
w is an unsigned integer constant specifying the total field 
length of the data, and d is an unsigned integer constant 
specifying the number of decimal places to the right of the 
decimal point. 

Subscript error in EQUIVALENCE statement. 

Subscripted variable in a statement function. 

Incorrectly formed subscript expression. 

DM2: Number of subscripts in a subscript expression, and/or 
the range of the subscript(s) does not .agree with the dimension 
information. MPX and TSX: Number of subscripts in a 
subscript expression does not agree with the dimension 
information. 

Invalid arithmetic statement or variable; or, in a FUNCTION 
subprogram, the left side of an arithmetic statement is a 
dummy argument, or, in DM2, TSX, and MPX, is in COMMON. 

Syntax error in I F statement. 

Invalid expression in IF statement. 

Syntax error or invalid simple argument in CALL statement. 

Invalid expression in CALL statement. 



52 



Error 
Code 



C41 
C42 
C43 

C44 
C45 

C46 
C47 

C48 
C49 

C50 
C51 



C52 
C53 
C54 
C55 

C56 
C57 
C58 
C59 

C60 
C61 

C62 



Cause of Error 



Invalid expression to the left of an equals sign in a statement 
function. 

Invalid expression to the right of an equals sign in a statement 
function. 

In an IF, GO TO, or DO statement, a statement number is 
missing, invalid, or incorrectly placed, or is the number of a 
FORMAT statement. 

Syntax error in READ, WRITE, or FIND statement. 

*IOCS record missing with a READ or WRITE statement 
(in DM2 and TSX mainline programs only). 

FORMAT statement number missing or incorrect in a READ 
or WRITE statement. 

Syntax error in input/output list; or an invalid list element; or, 
in a FUNCTION subprogram, the input list element is a dummy 
argument or is in COMMON. 

Syntax error in GO TO statement. 

Index of a computed GO TO is missing, invalid, or not preceded 
by a comma. 

'TRANSFER TRACE or "ARITHMETIC TRACE control 
record present, with no *IOCS control record in a mainline 
program. 

DO statements are incorrectly nested; or the terminal statement 
of the associated DO statement is a GO TO, IF, RETURN, 
FORMAT, STOP, PAUSE, or DO statement, or, in MPX or 
TSX, an MPX or TSX CALL statement. 

More than 25 nested DO statements. 

Syntax error in DO statement. 

Initial value in DO statement is zero. 

In a FUNCTION subprogram the index of DO is a dummy 
argument or is in COMMON. 

Syntax error in BACKSPACE statement. 

Syntax error in REWIND statement. 

Syntax error in END FILE statement. 

DM2: Syntax error in STOP statement. MPX and TSX: 
Syntax error in STOP statement or STOP statement in process 
program. 

Syntax error in PAUSE statement. 

Integer constant in STOP or PAUSE statement is greater than 

gggg. 

Last executable statement before END statement is not a STOP, 
GO TO, IF, CALL LINK, CALL EXIT, or RETURN statement, 
or, in MPX or TSX, an MPX or TSX CALL statement. 



Error 
Code 



C63 
C64 

C65* 
C66* 

C67* 



C68 
C69 

C70 

C71 
C72 

C73 

C74 

C75 
C76 

C77 
C78 
C7g 
C80 

C81 
C82 

C83 



Cause of Error 



Statement contains more than 15 different subscript 
expressions. 

Statement too long to be scanned, because of Compiler 
expansion of subscript expressions or Compiler addition of 
generated temporary storage locations. 

All variables in an EQUIVALENCE list are undefined. 

Variable made equivalent to an element of an array in such a 
manner as to cause the array to extend beyond the origin of 
the COMMON area. 

Two variables or array elements in COMMON are equated, or 
the relative locations of two variables or array elements are 
assigned more than once (directly or indirectly). This error 
is also indicated if an attempt is made to allocate a standard 
precision real variable at an odd address by means of an 
EQUIVALENCE list. 

Syntax error in an EQUIVALENCE statement; or an illegal 
variable name in an EQUIVALENCE list. 

Subprogram does not contain a RETURN statement, or, in 
TSX, a TSX CALL statement, or a mainline program contains 
a RETURN statement. 

No DEFINE FILE statement in a mainline program that has 
disk READ, WRITE, or FIND statements. 

Syntax error in DEFINE FILE statement. 

Duplicate DEFINE FILE statement, more than 75 DEFINE 
FILEs, or DEFINE FILE statement in subprogram. 

Syntax error in record number of disk READ, WRITE, or 
FIND statement. 

DM2: Defined file exceeds disk storage size. MPX and TSX: 
INSKEL COMMON referenced with two-word integer. 

Syntax error in DATA statement. 

Names and constants in a DATA statement not in a one to one 
correspondence. 

Mixed mode in DATA statement. 

Invalid Hollerith constant in a DATA statement. 

Invalid hexadecimal specification in a DATA statement. 

Variable in a DATA statement not used elsewhere in the 
program, or, in DM2, a dummy variable in DATA statement. 

COMMON variable loaded with a DATA specification. 

DATA statement too long to compile, because of internal 
buffering. 

TSX: TSX CALL statement appearing illegally. 



*The detection of a code 65, 66, or 67 error prevents any subsequent 
detection of any of these three errors. 



Appendix F. Error Codes 53 



INDEX 



ABS subprogram 39 

ALOG subprogram 39 

Alphabetic characters (Appendix C) 49 

Alphameric data conversion 17 

Arithmetic expressions 7 

Arithmetic operation symbols 7 

Arithmetic statements 9 

Arrays 5 

arrangement in storage 5 
dimensioning (see DIMENSION statement) 30 
element equivalence (see EQUIVALENCE statement) 32 

ATAN subprogram 39 

A -conversion 25 

BACKSPACE statement 21 

Blank character 

in formatted data (see X-type format) 27 
in coded statements (see coding form) 2 

Blank COMMON 30 

Blank I/O records (see multiple field format) 28, 2 

CALL DATSW 15 

CALL DVCHK 15 

CALL EXIT 14 

CALL FCTST 16 

CALL LINK 14 

CALL LOAD 14 

CALL OVERFL 15 

CALL PDUMP 15 

CALL SLITE 15 

CALL SLITET 15 

CALL SSWTCH 15 

CALL statement 13 

CALL statements, special 14 

CALL TSTOP 15 

CALL TSTRT 16 

Card character code s (Appendix C) 49 

Card Read Punch, loading Data Cards into hopper of 1 8 

Carriage control 29 

Coding form 2 

Comments (see coding form ) 2 

COMMON statement 30 

blank COMMON 31 

named COMMON 30 

with dimensions 31 
Compilation 

messages 42-44 
Computed GO TO statement 10 
Constants 3 

integer 3 

real 3 
Continuation line (see coding form) 2 
CONTINUE statement 12 
Control statements 9 

CALL 13 

computed GO TO 10 

CONTINUE 12 

DO 10 



END 13 

IF 10 

PAUSE 13 

STOP 13 

unconditional GO TO 10 
Conversion of alphameric data 25 

A -conversion 25 

H -conversion 25 

literal data enclosed in apostrophies 26 
Conversion of numeric data 23 

E -conversion 24 

F -conversion 24 

I-conversion 23 
Conversion of multiple subscripts to single subscripts 33 
COS subprogram 39 



Data conversion 

alphameric 25 

numeric 23 

(see also FORMAT statement) 
Data input to the object program 29 
DATA statement 33 

DATSW subprogram (see machine and program indicator tests) 1 5 
DEFINE FILE statement 34 
DIMENSION statement 30 
Disk I/O statements 18 

FIND 19 

READ 19 

WRITE 19 
DO statement 10 

increment 11 

index 1 1 

initial value of the index 1 1 

nesting 12 

range limit 11 

restrictions 12 

test value 1 1 
Dummy arguments (see subprogram statements) 35 
DVCHK subprogram (see machine and program indicator tests) 1 5 

END FILE statement 21 

END statement 13 

END statement in subprograms 40 

EQUIVALENCE statement 32 

(see also conversion of multiple subscripts to single subscripts) 
Error codes 

Appendix F 52 
Error messages 42-44 
EXP subprogram 39 
Explicit specification of type 

type statement 29 

variable types 4 
Expressions 7 

evaluation 7 

mode 7 

operators 7 

rules for construction 7 



Index 55 



EXTERNAL statement 
E -conversion 24 



30 



Loading 1442 Card Read Punch hopper 
Logical unit numbers 22 



FCTST subprogram (see machine and program indicator tests) 16 
FIND statement 18, 19 
FLOAT subprogram 39 
FORMAT statement 22 

carriage control 29 

conversion of alphameric data 25 

conversion of numeric data 23 

data input to the object program 29 

multiple field format 28 

T-format code 27 

X-type format 27 
FORTRAN-supplied FUNCTION subprograms 38 
FUNCTION subprogram 37 
Functions 36 
F-conversion 24 

GO TO statement 10 
computed 10 
unconditional 10 

Hierarchy of arithmetic operations 7 
H -conversion 25 

IABS subprogram 39 

Identification/sequence number field (see coding form) 2 

IF statement 10 

IFIX subprogram 39 

Implementation restrictions (Appendix D) 50 

Implicit specification of type 

type statement 29 

variable types 4 
Implied DO loops in I/O lists (see indexing I/O lists) 20 
Increment of a DO statement 11 
Index of a DO statement 11 
Indexing I/O lists 20 

Initial value of the index of a DO statement 11 
Input data to the object program 29 
Input data conversion (see FORMAT statement) 
Input/Output devices 16 
Input/output statements 16 

disk I/O 19 

FORMAT 22 

manipulative I/O 21 

non-disk I/O 17 

unformatted I/O 20 
INSKEL COMMOM (see named COMMON) 30 
Integer constants 3 

Integer mode (see arithmetic expressions) 7 
INTEGER statement 29 
Integer variables (see variable types) 4 
ISIGN subprogram 39 
I/O lists (see input/ output statements) 
I/O unit numbers (see logical unit numbers) 22 
Literal data conversion 26 



Machine and program indicator tests 15 

CALL DATSW 15 

CALL DVCHK 15 

CALL FCTST 16 

CALL OVERFL 15 

CALL SLITE 15 

CALL SLITET 15 

CALL SSWTCH 15 

CALL TSTOP 15 

CALL TSTRT 16 
Manipulative I/O statements 21 

BACKSPACE 21 

END FILE 21 

REWIND 21 
Messages 

compilation 42-44 
error 42 -44 
Mixed mode (see arithmetic expressions) 7 
Mode, computational 7 
Mode of expressions 7 

integer 7 

mixed 7 

real 7 
Multiple field format 28 
Named COMMON 31 
Names 

subprogram 36 

variable 4 
Nesting of DO statements 12 
Nonstandard items (Appendix D) 50 
Non-disk I/O statements 17 

READ 17 

WRITE 18 
Numeric characters (Appendix C) 49 
Numeric data conversion 23 
Object program input 29 

Operation symbols, Arithmetic 7 

Order of arithmetic operations 7 

Order of specification statements 29 

Output data conversion (see FORMAT statement) 

OVERFL subprogram (see machine and program indicator tests) 

Paper tape character codes (Appendix C) 49 

Parentheses, use of 8 

PAUSE statement 13 

Range of a DO statement 11 
READ statement 

disk I/O 19 

non-disk I/O 17 

unformatted I/O 20 
Real constants 3 

Real mode (see arithmetic expressions) 7 
REAL statement 29 
Real variables (see variable types) 4 
Restrictions on DO statements 12 



15 



56 



RETURN statement 40 
REWIND statement 21 

Sequence number/identification field . 2 

Sequence of source statements (Appendix E) 51 

Sequence of specification statements 29 

Sign subprogram 39 

Simulated machine indicators (see machine and program indicator 

tests) 1 5 

SIN subprogram 39 

Skeleton COMMON (see named COMMON) 30 

SLITE subprogram (see machine and program indicator tests) 15 

SLITET subprogram (see machine and program indicator tests) 1 5 

Source program chara cter codes (Appendix C) 49 

Source program statements (Appendix E) 51 

Special CALLs 14 

CALL LINK 14 

CALL LOAD 14 

CALLPDUMP ys i '1,1 
machine and program indicator tests 15 
Special characters (Appendix C) 49 
Specification statements 29 

COMMON 30 

DATA 33 

DEFINE FILE 34 

DIMENSION 30 

EQUIVALENCE 32 

EXTERNAL 30 

type (REAL, INTEGER) 29 
SORT subprogram 39 

SSWTCH subprogram (see machine and program indicator tests) 15 
Statement number (see coding form) 2 
Statements 9 

arithmetic 9 

control 9 

function definition 36 

input/ output 16 

specification 29 

subprogram 35 

(see also coding form) 2 
Statement/ system cross reference table (Appendix A) 45 
STOP statement 13 
Subprogram names 36 



Subprogram statements 35 

END 40 

FUNCTION 37 

RETURN 40 

statement function definition 36 

SUBROUTINE 39 
Subprograms 

FORTRAN-supplied FUNCTION 38 

FUNCTION 37 

statement function 36 

SUBROUTINE 39 
SUBROUTINE subprograms 39 
SUBSCRIPT forms 6 
Subscripts 5 

Symbols, Arithmetic operation 7 
System/statement cross-reference table (Appendix A) 



45 



TANH subprogram 39 

Test value of a DO statement 11 

TSTOP subprogram (see machine and program indicator tests) 15 

TSTRT subprogram (see machine and program indicator tests) 16 

Type statements (REAL, INTEGER) 29 

T-format code 27 

Unconditioned GO TO statement 7 
Unformatted I/O statements 20 

READ 20 

WRITE 21 
Unit record sizes (see multiple field format) 28 

Variables 
names 4 
subscripted 5 
types 4 

WRITE statement 
disk I/O 20 
non-disk I/O 18 
unformatted I/O 21 

X-type format 27 



Index 57 



READER'S COMMENT FORM 

IBM 1130/1800 Basic FORTRAN IV Language Order No. GC26-3715-7 



• How did you use this publication? 

As a reference source □ 

As a classroom text □ 

As a self-study text □ 

• Based on your own experience, rate this publication 

As a reference source: 



Very Good Fair Poor Very 

Good Poor 



As a text: 

Very Good Fair Poor Very 
Good Poor 



• What is your occupation? 



• We would appreciate your other comments; please give specific page and line references 
where appropriate. If you wish a reply, be sure to include your name and address. 



Thank you for your cooperation. No postage necessary if mailed in the U.S.A. 



GC26-3715-7 



YOUR COMMENTS, PLEASE. . . 



Your answers to the questions on the back of this form, together with your comments, will 
help us produce better publications for your use. Each reply will be carefully reviewed by 
the persons responsible for writing and publishing this material. All comments and sug- 
gestions become the property of IBM. 



o 



Note: Please direct any requests for copies of publications, or for assistance in using your 
IBM system, to your IBM representative or to the IBM branch office serving your locality. 



Fold 



Fold 



FIRST CLASS 
PERMIT NO. 110 
BOCA RATON, FLA 
33432 



BUSINESS REPLY MAIL 

NO POSTAGE STAMP NECESSARY IF MAILED IN THE UNITED STATES 



POSTAGE WILL BE PAID BY . . . 

IBM Corporation 
General Systems Division 
Boca Raton, Florida 33432 




Attention: Systems Publications, Department 707 



Fold 



Fold 



o 

CO 

o 
o 

-o 
5" 

r+ 
05 
Q. 

5' 

c 

CO 

> 

CD 
O 
ro 

O) 

c!o 

CJI 



International Business Machines Corporation 

Data Processing Division 

1133 Westchester Avenue, White Plains, New York 10604 

[U.S.A. only] 

IBM World Trade Corporation 

821 United Nations Plaza, New York, New York 10017 

[International] 



GC26-3715-7 



DO 



CO 
O 

00 
O 
O 



Q. 

5" 

c 

GO 

> 

a 
o 

CO 
O) 

00 

Ul 

•^1 



International Business Machines Corporation 

Data Processing Division 

1133 WestchBSter Avenue, White Plains, New York 10604 

[U.S.A. only] 

IBM World Trade Corporation 

821 United Nations Plaza, New York, New York 10017 

[International]