Fortran77 Programming Reference Manual
Fortran77 Programming Reference Manual
FORTRAN77
Programming Reference Manual
ClearPath MCP 13.1
You should be very careful to ensure that the use of this information and/or software material complies with the
laws, rules, and regulations of the jurisdictions with respect to which it is used.
The information contained herein is subject to change without notice. Revisions may be issued to advise of such
changes and/or additions.
Notice to U.S. Government End Users: This is commercial computer software or hardware documentation developed
at private expense. Use, reproduction, or disclosure by the Government is subject to the terms of Unisys standard
commercial license for the products, and where applicable, the restricted/limited rights provisions of the contract
data rights clauses.
Unisys and ClearPath are registered trademarks of Unisys Corporation in the United States and other countries.
All other brands and products referenced in this document are acknowledged to be the trademarks or registered
trademarks of their respective holders.
Contents
Section 1. FORTRAN77 Terms and Concepts
Purpose .................................................................................................................11
Scope .....................................................................................................................11
Audience ...............................................................................................................11
Prerequisites .......................................................................................................11
How to Use This Reference Manual .............................................................11
Documentation Updates ................................................................................. 12
Whats New? ...................................................................................................... 12
Syntactic Items .................................................................................................. 12
FORTRAN77 Character Set ............................................................................. 13
Basic Terms and Concepts ............................................................................. 14
Statements ..................................................................................... 14
Order of Statements .................................................................... 15
Constants ............................................................................................................ 21
Integer Constants.......................................................................... 22
Real Constants ............................................................................... 22
Double Precision Constants ...................................................... 24
Complex Constants ......................................................................25
Logical Constants ..........................................................................26
Character Constants .....................................................................26
Hollerith Constants ....................................................................... 27
Hexadecimal Constants ...............................................................28
Variables ............................................................................................................ 211
Arrays ................................................................................................................. 212
Array Declarers ............................................................................ 213
Substrings ......................................................................................................... 215
Section 3. Expressions
Operators ............................................................................................................ 31
Arithmetic Expressions .................................................................................. 33
Character Expressions .................................................................................... 34
Relational Expressions .................................................................................... 36
Logical Expressions ......................................................................................... 36
GO TO Statements ........................................................................................... 71
Unconditional GO TO .................................................................... 71
Assigned GO TO ............................................................................ 72
Computed GO TO .......................................................................... 72
IF Statements .....................................................................................................73
Arithmetic IF ...................................................................................73
Logical IF ..........................................................................................73
Block IF, ELSE IF, ELSE, END IF Statements .......................... 74
Block IF .................................................................................. 74
ELSE IF Statement ...............................................................75
ELSE Statement ...................................................................76
END IF Statement ................................................................76
DO Statement .................................................................................................... 77
CONTINUE Statement .................................................................................... 710
PAUSE Statement ........................................................................................... 710
STOP Statement .............................................................................................. 711
END Statement ................................................................................................ 712
Files .......................................................................................................................82
Units ..................................................................................................................... 83
Data Transfer Input/Output Statements .................................................... 84
Control Information List .............................................................. 84
Unit Specifier ....................................................................... 85
Format Specifier ................................................................. 86
Record Specifier ................................................................. 86
iv 3957 6053003
Contents
3957 6053003 v
Contents
Variable............................................................................................................... 152
Integer Variables .......................................................................... 152
Real Variables ............................................................................... 153
Double Precision Variables ....................................................... 153
Complex Variables ...................................................................... 155
Logical Variables .......................................................................... 155
Character Variables ..................................................................... 156
Arrays ................................................................................................................. 156
vi 3957 6053003
Contents
3957 6053003 ix
Contents
x 3957 6053003
Contents
3957 6053003 xi
Contents
Subroutines .................................................................................... B9
Character Arguments .................................................................. B9
Input/Output ...................................................................................................... B9
Files .................................................................................................. B9
Result Clauses .............................................................................. B9
I/O Statements .............................................................................. B9
Separate Compilation .................................................................................... B10
Binding ............................................................................................................... B11
Libraries ............................................................................................................. B11
Zip ........................................................................................................................ B11
Compiler Control Statements ...................................................................... B11
Compiler Files ................................................................................................... B11
Optimization..................................................................................................... B12
Debugging Aids .............................................................................................. B12
Index ..................................................................................................... 1
3957 6053003 xv
Tables
Purpose
This document is a reference manual for the FORTRAN77 programming language used
on the ClearPath Enterprise Servers of computer systems, revised relative to release
level 4.0. It describes the Unisys ClearPath Enterprise Servers implementation of
FORTRAN77, the designation for the American National Standard Programming
Language FORTRAN, ANSI X3.9-1978. It describes both the programming language
accepted by the FORTRAN77 compiler and various options and control statements
used with this compiler.
Note: Throughout this manual, any Unisys extensions to the national standard are
shaded.
Scope
This reference manual addresses all aspects of the FORTRAN77 language, from basic
constructs (constants, variables, operators, and so forth) to the different types of
statements used to build a program. The manual also addresses the more advanced
procedures used in FORTRAN77 including the use of libraries, subprograms, and
compiler options.
Audience
This manual is intended for all levels of programmers using FORTRAN77 as their
programming language.
Prerequisites
Anyone using this manual should have some familiarity with Unisys ClearPath
Enterprise Servers and the CANDE language. A basic understanding of FORTRAN77 is
helpful, but not necessary.
3957 6053003 11
FORTRAN77 Terms and Concepts
Documentation Updates
This document contains all the information that was available at the time of
publication. Changes identified after release of this document are included in problem
list entry (PLE) 18778718. To obtain a copy of the PLE, contact your Unisys
representative or access the current PLE from the Unisys Product Support Web site:
http://www.support.unisys.com/all/ple/18778718
Note: If you are not logged into the Product Support site, you will be asked to do
so.
Whats New?
New or Revised Information Location
Syntactic Items
The basic syntactic items of the FORTRAN77 language are constants, symbolic names,
statement labels, keywords, operators, and special characters. Letters, digits, and
special characters are used to form the syntactic items.
12 3957 6053003
FORTRAN77 Terms and Concepts
Statement label A statement label consists of one to five digits, one of which must
be nonzero. A statement label is used to identify a statement.
Keyword A keyword is a specified sequence of letters. (The keywords of the
FORTRAN77 language are described in Sections 4 through 14.)
Whether a particular sequence of characters identifies a keyword
or a symbolic name is inferred from context.
The set of special characters is described in this section. A special character may be
an operator or part of a constant or have some other special meaning. Interpretation is
inferred from context.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Lowercase letters may also appear in FORTRAN77 source statements. The lowercase
letters are equivalent to uppercase letters, except in character constants, Hollerith
constants, and quoted hexadecimal constants.
0123456789
Blank
= Equals
+ Plus
- Minus
* Asterisk
/ Slash
( Left parenthesis
) Right parenthesis
, Comma
. Decimal Point
$ Currency Symbol
' Apostrophe
: Colon
& Ampersand
% Percent Sign
" Quotation mark
_ Underscore
! Exclamation point
3957 6053003 13
FORTRAN77 Terms and Concepts
Statements
A statement is written on one or more lines, the first of which is called the initial line;
succeeding lines, if any, are called continuation lines. There is also a line called a
comment line, which is not part of any statement and is intended to provide
documentation.
A statement may contain a trailing comment. A "%" or a "!" indicates that the rest of
the line is a comment. An exception to this is if columns 1 through 5 are blank and line
6 contains a "!", the line is treated as a continuation line.
FORTRAN77 lines conform to the following formats, except when the compiler control
option FREE is set:
1. Continuation card images must contain a minus sign (-) or asterisk (*) as the first
non-blank character in the first six columns.
2. Comments must have a "C" in column one and a minus sign or asterisk in column
2.
3. For statements with labels, the label must appear in the first five columns.
14 3957 6053003
FORTRAN77 Terms and Concepts
4. Each free-form statement may contain 66 characters at most, including blanks and
not including sequence numbers. Any characters beyond the 66th character, but
before column 73, are flagged with a warning and ignored.
5. Continuation card images are shifted to the right until the continuation character "*"
or "-" is in column 6. If this shift causes a card image to extend past column 72, and
if there are blanks between the continuation character and the source, the source
is shifted to the left until either the card image no longer extends past column 72
or until the source begins in column 7.
6. Columns 73 through 80 of the source card image are reserved for the sequence
numbers, as in the case of formatted source input.
7. Compiler control images must have a dollar sign ($) in column 1, a blank in column
1 with a dollar sign in column 2, or a $ in columns 1 and 2.
8. FILE statements must have the string FILEbb in columns 1-6 where b represents a
blank.
An END statement is written only in an initial line. No other statement in a program
unit may have an initial line that appears to be an END statement. Note that a
statement must not contain more than 6600 characters (excluding labels and
continuation characters). Except as part of a logical IF statement, no statement may
begin on a line that contains any part of the previous statement.
Order of Statements
The order of statements in a main program or subprogram is determined by the
following rules:
3957 6053003 15
FORTRAN77 Terms and Concepts
10. The last line of a program unit must be an END statement. END statements may
not be continued.
11. The BLOCK GLOBALS subprogram must precede the main program, BLOCK DATA
subprograms, FUNCTION subprograms and SUBROUTINE subprograms.
Figure 1-1 is a diagram of the required order of statements and comment lines for a
program unit. Vertical lines delineate varieties of statements that may be interspersed.
For example, FORMAT statements may be interspersed with statement function
statements. Horizontal lines delineate varieties of statements that must not be
interspersed. For example, statement function statements must not be interspersed
among executable statements. Note that an END statement is also an executable
statement and must appear only as the last statement of a program unit.
Note: File statements may appear before any FORTRAN77 statement or between
subprograms. When appearing within a BLOCK GLOBALS subprogram, they must
precede all FORTRAN77 statements within the subprogram.
FILE STATEMENT
PROGRAM, FUNCTION, SUBROUTINE, BLOCK GLOBALS,
OR BLOCK DATA STATEMENT
IMPLICIT
STATEMENTS
PARAMETER
STATEMENTS
COMMENT
LINES OTHER SPECIFICATION
FORMAT STATEMENTS
AND
ENTRY
STATEMENTS
STATEMENT FUNCTION
STATEMENTS
DATA
STATEMENTS
EXECUTABLE
STATEMENTS
END STATEMENT
!"
16 3957 6053003
Section 2
Constants, Variables, Arrays, and
Substrings
At any given time during the execution of an executable program, the definition status
of each variable, array element, or substring is either defined or undefined.
A defined entity has a value. The value of a defined entity does not change until the
entity becomes undefined or is redefined with a different value.
Constants
Constants are FORTRAN77 data items and can be of the following types:
Integer
Real
Double Precision
Complex
Logical
Character
Hollerith
Hexadecimal
3957 6053003 21
Constants, Variables, Arrays, and Substrings
Integer Constants
The format for an integer constant is as follows:
<digit>
+
-
where the maximum absolute value allowed is 549755813887. The following are
examples of valid integer constants:
0 9999999999
+0 03770
-0 1254
17711 -5 7 (interpreted as -57)
Real Constants
The format for a real constant is as follows:
<real exponent>
<digit>
22 3957 6053003
Constants, Variables, Arrays, and Substrings
4.3135914667E68 = ((8**13)-1)*08**63
8.7581154021E-47 = 8**(-51).
3957 6053003 23
Constants, Variables, Arrays, and Substrings
A <basic double precision constant> is the same as a <basic real constant>, except
that the number of significant digits must be too large to represent in a real constant.
1234567890.1234567890123 D 29594
6.63D-034
9.80665D+0
3.1415926535897932
3.1415926535897932D0
3.1415926535897932D-0
24 3957 6053003
Constants, Variables, Arrays, and Substrings
1D3
+1D+003
+1.D+3
1.D0003
Complex Constants
The format for a complex constant is the following:
( <real constant> , <real constant> )
<integer constant> <integer constant>
The complex constant (m,n) represents the quantity m+ni, where i equals the square
root of -1. The following are examples of valid complex constants with the equivalent
mathematical expressions beside them:
3957 6053003 25
Constants, Variables, Arrays, and Substrings
Logical Constants
Two logical constants are provided to represent the logical values "true" and "false".
These two logical constants have the format:
The use of these logical constants is restricted to certain types of expressions. The
internal machine representations of these two constants are such that the data words
corresponding to the constant TRUE and the integer constant 1 are identical and the
data corresponding to the constant FALSE and the integer constant 0 are identical.
Character Constants
The format for a character string is as follows:
/255\ <EBCDIC character>
" /255\ <EBCDIC character> "
The apostrophe or the quotation mark may be used as the string delimiter. If the string
delimiter is the apostrophe, then the apostrophe is interpreted as part of the string
only if two adjacent apostrophes appear in the string in its place. These two
apostrophes are treated as representing one apostrophe character. If the quote is the
string delimiter, then two consecutive quotation marks inside a string are interpreted
as representing a single quotation character; that is, "ZYX""W" is interpreted as
"ZYX"W".
The length of the character constant is the number of characters between delimiting
apostrophes or quotation marks, except that each pair of consecutive delimiters
counts as a single character. Blanks embedded between delimiters are significant.
Note that it is not legal to have a string of length 0.
26 3957 6053003
Constants, Variables, Arrays, and Substrings
Hollerith Constants
The format for a Hollerith string is as follows:
<width> H /255\ <EBCDIC character>
Hollerith strings are used in format statements, data statements, and in initial value
lists of type declaration statements. They may also appear as actual arguments to a
subroutine, but not to a function.
2HbQ
4H"C'.
7Hbb"ABC"
3HbbbAB Character string may not be longer than the integer preceding
the H indicates
-6HABBCDEF String width specification may not be negative
0HA String width specification may not be zero
3957 6053003 27
Constants, Variables, Arrays, and Substrings
Hexadecimal Constants
Another alternate representation of program values is the hexadecimal constant literal
that corresponds to notation in a number system with a radix of 16.
Z /24\ <hexadecimal digit>
/24\ <hexadecimal digit> X
" /24\ <hexadecimal digit> "
<hexadecimal digit>
0
1
2
...
A
B
C
D
E
F
The "Z" format can only be used for data initialization in DATA and TYPE statements.
The quote format can be used anywhere a numeric constant is allowed (including data
initialization in DATA and TYPE statements.)
28 3957 6053003
Constants, Variables, Arrays, and Substrings
A hexadecimal constant may specify up to two words (96 bits, 24 hex digits) of data.
The exact value that a hexadecimal constant represents depends upon how it is used.
REAL and LOGICAL types imply that a maximum of 12 hexadecimal digits can be
specified to represent a constant. INTEGER types imply that a maximum of eight hex
digits (32 bits) can be specified. The exception to this is using the "Z" format for data
initialization in DATA and TYPE statements. Here, a hexadecimal constant can specify a
maximum of 12 hex digits for INTEGERs.
When an INTEGER, REAL, or LOGICAL type is required and has a length requirement
that is greater than the number of hexadecimal digits specified, the constant is stored
right-justified with leading zeros appended to fill the word. If this type has a length that
is less than the number of hexadecimal digits, the left- most digits are retained and the
remaining digits are truncated. A warning message is given to flag the truncation.
The following rules are used to determine which type a hexadecimal constant
represents:
1. When the constant is used for initialization in DATA and TYPE statements, the
constant assumes the type of the item it is initializing.
Examples Type of Constant
INTEGER I/'89ABC'X/,J/Z1234/,K Both INTEGERs
REAL X
DATA K,X/'FFF'X,'9A1B5C'X/ INTEGER and REAL
1. When the hexadecimal constant is used with a binary operator, the constant
assumes the type of the other operand. Note that this includes the assignment
operator.
Examples Type of Constant
REAL X
DOUBLE PRECISION D
INTEGER I REAL
3957 6053003 29
Constants, Variables, Arrays, and Substrings
1. When a hexadecimal constant is used in any other context, the constant assumes
the type INTEGER (specifying a maximum of 32 bits, that is, 8 hex digits).
Examples Type of Constant
X = '155'X + 'F32' X INTEGER
IF ('6774'X) 100,200,300 INTEGER
The following are examples of valid hexadecimal constants and their decimal
equivalents:
Hexadecimal Decimal
Constant Equivalent
Z0 0
Z10 16
Z100 256
ZFF 255
'1A'X 26
"203"x 515
Invalid Reason
Constant
FFF60 Missing Z or missing quotes and X
ZABCDGF Contains the character G, which is not a hexadecimal digit
Z333.33 033 Contains a decimal point, which is illegal for a hexadecimal
constant
'AB C'X Contains a blank in the hexadecimal string, which is illegal for
the quote format
543DB"X Missing initial quote
'ZF94'X Contains the character Z, which is not a hexadecimal digit
'477B' Missing X after second apostrophe
Variables
A variable is an entity that has a symbolic name and type. The value of the data
represented by a variable may be altered during program execution.
A variable identifies one or more storage locations for purposes of data storage and
retrieval. The contents of these storage locations are accessed by referencing the
associated variable name. Note that the term variable refers to a simple variable and
does not include array elements.
Integer
Real
Double precision
Complex
Logical
Character
The following are examples of valid variable names with the type assigned to them
when they are not affected by TYPE or IMPLICIT statements:
Arrays
An array is an ordered set of data organized into dimensions. An array is referenced by
an array name that is of the same form as a variable name. A variable name is
designated as an array name by its appearance in an array declarer. All of the elements
of an array are of the same type and this type is indicated by the array name in the
same manner as for variable names.
An array element name identifies one element of the array. An array element name is
an array name qualified by a subscript.
,
<array name> ( /31\ <integer expression> )
<real expression>
Array Declarers
An array declarer declares the size and number of dimensions of an array.
The format for an array declarer is as follows:
,
<array name> ( /31\ <dimension declarer> )
The number of dimensions in the array is the number of dimension declarers in the
array declarer. The minimum number of dimensions is 1 and the maximum is 31.
The lower and upper dimension bounds are integer arithmetic expressions. The value
of a dimension bound may be positive, negative, or zero; however, the value of the
upper dimension bound must be greater than or equal to the value of the lower
dimension bound. If only the upper dimension bound is specified, the value of the
lower dimension bound is assumed to be 1. An array declarer must precede the first
use of that array in an executable statement, DEBUG statement, or DATA statement.
Each array declarer is either a constant array declarer, an adjustable array declarer, or
an assumed-size array declarer. A constant array declarer is an array declarer in which
each of the dimension bounds is a constant. An adjustable array declarer is an array
declarer that contains one or more variables. An assumed-size array declarer is a
constant array declarer or an adjustable array declarer, except that the upper bound of
the last dimension is an asterisk.
Furthermore, each array declarer is either an actual array declarer or a dummy array
declarer. An actual array declarer is one in which the array name is not a dummy
argument. An actual array declarer must be a constant array declarer and is permitted
in DIMENSION statements, COMMON statements, and type statements. A dummy
array declarer is one in which the array name is a dummy argument. A dummy array
declarer may be either a constant array declarer, an adjustable array declarer, or an
assumed-size array declarer. A dummy array declarer is permitted in DIMENSION
statements and TYPE statements, and may appear only in function or subroutine
subprograms.
The size of a dimension is the value d2-d1+1, where d1 and d2 are the dimension
bounds for that dimension. The size of an array is equal to the number of elements in
the array and to the product of the sizes of the dimensions specified by the array
declarer for that array. In the case of an assumed-size dummy array, the size is
determined as follows:
The total size of a character array may not exceed (2**20-1) characters on MCP/AS
processors or (2**28-1)*6 characters on MCP/AS (Extended) processors.
Substrings
A substring is a contiguous portion of character data. It is of type character. A
character substring is identified by a substring name and may be assigned values and
referenced.
E )
<integer expression>
For example A(2:4) specifies characters in positions two through four of the character
variable A, and B(4,3) (1:6) specifies characters in positions one through six of the
character array element B(4,3). The values of the left and right integer expressions
must be such that 1 <= left int exp <= right int exp <= length of the character variable
or array element. If the left int exp is omitted, a value of 1 is assumed. If the right is
omitted, a value of length is implied for it. Both expressions may be omitted; for
example, the form v(:) is equivalent to v, and the form a(i,i ...)(:) is equivalent to a(i,i ...).
The length of a character substring is: (right int exp - left int exp + 1).
The integer expression used to define the substring may contain array element
references and function references. Evaluation of a function must not alter the value
of any other expression within the same substring name.
The following are examples of valid substrings where I and JK are integer variables:
AB(5:6)
CX(5)(2:I)
G(5:)
ZB(:)
GY(:JK*03)
Operators
There are four types of operators that may be used to form FORTRAN77 expressions.
They are arithmetic operators, relational operators, logical operators, and character
operators.
** Exponentiation
- Subtraction or Negation
/ Division
* Multiplication
+ Addition
The precedence among the arithmetic operators that determines the order in which
the operands are to be combined (unless the order is changed by parentheses) is from
highest to lowest as follows:
** Highest
* and / Intermediate
+ and - Lowest
There is only one character operator, concatenation, which is denoted by two adjacent
parallel slashes. Parentheses do not affect the evaluation of character expressions.
// Concatenation
3957 6053003 31
Expressions
The seven relational operators are of equal precedence and are as follows:
The precedence among the logical operators that determines the order in which the
operands are to be combined (unless the order is changed by parentheses) is from
highest to lowest as follows:
.NOT. Highest
.AND.
.OR.
.EQV. or .NEQV. Lowest
Arithmetic Highest
Character
Relational
Logical Lowest
Operations of equal precedence are performed from left to right, except for
exponentiation, which is carried out from right to left. Parentheses may be used to
override operator precedence in the usual manner. The unary + operator is ignored.
Note that adjacent operators are not permitted.
32 3957 6053003
Expressions
Arithmetic Expressions
An arithmetic expression is used to express a numeric computation. Evaluation of an
arithmetic expression produces a numeric value. An arithmetic expression may
contain only arithmetic operators, symbolic names of arithmetic constants, arithmetic
constants, array elements, variables, arithmetic functions and intrinsic function
references, and grouping parentheses. The format for integer, real, and double
precision expressions is as follows:
<operand>
The types of operands in an arithmetic expression determine the type of the value
obtained from the evaluation of the expression. The resultant types of arithmetic
operations depend upon the types of the operands and the operator involved.
"DOUBLE" indicates type double precision.
For the operators +, -, *, and /, the result of the operation is of the following type:
3957 6053003 33
Expressions
For exponentiation (**), the type and the interpretation of the expression X1**X2 is as
follows:
X2 I2 R2 D2 C2
X1
....
I1 I =I1**I2R =REAL(I1)**R2D =DBLE(I1)**D2C =CMPLEX(REAL(I1),0.)**C2
R1 R =R1**I2R =R1**R2 D =DBLE(R1)**D2C =CMPLX(R1,0.)**C2
D1 D =D1**I2D =D1**DBLE(R2)D =D1**D2 Prohibited
C1 C =C1**I2C =C1**CMPLX Prohibited C =C1**C2
(R2,0.)
6
J + 6
XALPHA(8) / A + (ZZ + XALPHA(9)) / ZETA
LBD / (A(1) + A(2))
20 ** FCN1 (XND(1,2) ,12)
-B * A
-(-P)
Character Expressions
A character expression is used to express a character string. Evaluation of a character
expression produces a result of type character.
34 3957 6053003
Expressions
//
<character constant>
<constant name>
<variable name>
<array element name>
<substring name>
<function reference>
<character expression>
The result of a concatenation operation (X1 // X2) is a character string whose value is
the value of X1 concatenated on the right with the value of X2 and whose length is the
sum of the lengths of X1 and X2. For example, the value of 'AB' // 'CDE' is the string
ABCDE. Except in a character assignment statement, a character expression must not
involve concatenation of a character operand whose length specification is an asterisk
in parentheses (that is (*)length), unless the operand is the symbolic name of a
constant.
CHARACTER*03 C
CHARACTER*04 D, E, F, G
C = ABC
D = DEFG
E = FG // HI
F = C // D
G = AB // D(1:2)
C = C(2:) // Z
C = BCZ
D = DEFG
E = FGHI
F = ABCD
G = ABDE
3957 6053003 35
Expressions
Relational Expressions
A relational expression is used to compare the values of two arithmetic expressions
or two character expressions.
The relational operator .IS. returns a value of true if the data words referenced on
either side of the operator are bit-by-bit identical. Complex operands may not be used
with this operator. The .IS. operator allows a real, integer, or double precision variable
to be compared to a character string constant. The length of the string must be short
enough to fit into the variable type (maximum of four characters for integers, six for
reals, and twelve for double precision variables).
When the operands of the relational expression are of type character, they are
compared for their relative value in the EBCDIC collating sequence. If the character
operands are of unequal length, the shorter operand is considered to be extended on
the right with blanks to the length of the longer operand.
B + A .GT. D
C1 .EQ. C2
CA // CB .GE. CD
CA(2:3) .LT. CB
A * B / 9.2 .LE. C
C1 .NE. A
Logical Expressions
A logical expression represents a rule for computing a value corresponding to .TRUE.
or .FALSE. and consists of any valid combination of logical operands, logical operators,
and parentheses. A logical operand may be a logical constant, symbolic name of a
logical constant, logical variable, logical array element, logical function reference, a
relational expression, or a logical expression in parentheses.
36 3957 6053003
Expressions
Logical negation is expressed by the operator .NOT., which complements the value of
a logical operand.
The .AND. operator is used to express the logical product of two operands. The
operation A.AND.B yields the value .TRUE. if, and only if, both A and B are .TRUE..
Otherwise the value of A.AND.B is .FALSE.
The .OR. operator is used to express the logical sum of any two logical operands. The
operation A.OR.B yields the value .FALSE. only if both A and B are .FALSE.. Otherwise,
the value of A.OR.B is .TRUE.
The .EQV. operator is used to express the logical equivalence of two logical operands.
The operation yields the value .TRUE. if both A and B are .TRUE. or both A and B are
.FALSE.. Otherwise the value of A.EQV.B is .FALSE..
The .NEQV. operator is the negation of the logical equivalence. The operation
A.NEQV.B yields the value .FALSE. if both A and B are .TRUE. or both A and B are
.FALSE.. Otherwise, the value of A.NEQV.B is .TRUE..
3957 6053003 37
Expressions
T T F T T T F
T F F F T F T
F T T F T F T
F F T F F T F
The following are examples of logical expression: A, B, and C are real variables; L1, L2,
and array L3 are logical variables; TRU is the symbolic name of a logical constant; and
EVAL is a logical function.
A + B .GT. C .OR. L2
.NOT. (L1 .OR. L3 (1)) .AND. TRU
EVAL(A) .NEQV. L1
L3(3) .OR. L2 .EQV. L1 .AND. L3(2)
38 3957 6053003
Section 4
Specification Statements
1. DIMENSION
2. EQUIVALENCE
3. COMMON
4. TYPE statements - INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL and
CHARACTER
5. IMPLICIT
6. PARAMETER
7. EXTERNAL
8. SAVE
9. INTRINSIC
DIMENSION Statement
The non-executable DIMENSION statement specifies the name and dimensions of an
array.
3957 6053003 41
Specification Statements
,
DIMENSION <array declarer>
<array declarer>
,
<array name> ( /31\ <dimension declarer> )
<dimension declarer>
<bound expression>
Each array referenced in a program unit must have its array bounds specified exactly
once in an array declarer in that program unit. Array declarers may appear in
COMMON and TYPE statements in addition to the DIMENSION statement. Refer to
"Array Declarers" in Section 2 for further information.
Examples:
DIMENSION D(2:3), E(2:5,-1:0)
DIMENSION A(10)
DIMENSION B(N,2),C(6)
DIMENSION Q(J)
EQUIVALENCE Statement
An EQUIVALENCE statement is used to specify the sharing of memory locations by
two or more entities in a program unit. If the equivalent entities are of different data
types, the EQUIVALENCE statement does not cause type conversion or imply
mathematical equivalence.
42 3957 6053003
Specification Statements
,
,
EQUIVALENCE ( <equiv entity> , <equiv entity> )
<equiv entity>
Names of dummy arguments must not appear in the list. If a variable name is also a
function name, that name must not appear in the list.
An entity of type character may be equivalent only with other entities of type
character. The lengths of the equivalent entities are not required to be the same. If an
array element name appears in an EQUIVALENCE statement, the number of subscript
expressions must be the same as the number of dimensions specified in the array
declarer for the array name.
An EQUIVALENCE statement must not specify that the same storage unit is to occur
more than once in a storage sequence, as shown in the following example:
DIMENSION A(2)
EQUIVALENCE (A(1),B), (A(2),B)
This is prohibited because it specifies the same storage location for A(1) and A(2).
An EQUIVALENCE statement must not specify that consecutive storage units are to
be non-consecutive. For example, the following is prohibited:
REAL A(2)
DOUBLE PRECISION D(2)
EQUIVALENCE (A(1), D(1)), (A(2),D(2))
Y, X(1), and Z(6) all share the same memory location. Z(7) through Z(10) share locations
with X(2) through X(5).
3957 6053003 43
Specification Statements
01020304050607
0A
0C(1)KC(2)
0B
COMMON Statement
The non-executable COMMON statement associates variables and arrays with blocks
of storage that may be shared among several program units.
L%%
*%% / %% / <nlist> ,
* , , * <common block name> ,
<nlist>
,
% <variable name> %
0 <array name>
* <array declarer> ,
A symbolic name associated with each block of common storage is called a common
block name. Any program unit may access the block of storage associated with this
name by means of a common statement using this name. Common storage
associated with a common block name is called named common. A common block
name is constructed the same as a variable name is constructed. This name may not
be a dummy argument, subroutine function, named block data, external procedure, or
named main program. A common block name is considered as such only in the
context of a COMMON statement. A common block need not be named; common
storage associated with no name is called blank common.
44 3957 6053003
Specification Statements
The following statements are equivalent and define a blank common block:
COMMON//A,B(10)
COMMON A,B(10)
Variables and arrays are assigned contiguous locations in common storage in the order
in which they appear in a COMMON statement. Entire arrays, but not individual array
elements, may be assigned storage locations in common storage.
If a character variable or character array is in a common block, all of the entities in that
common block must be of type character.
If the same common name appears more than once in a program unit, the common
elements associated with a second or subsequent appearance are considered as
extensions to the list of the previous appearances.
Variables and array names may not be duplicated in COMMON statements. One
variable or array may not be assigned to more than one block of common storage
within a program unit. Symbolic constants from a PARAMETER statement may not be
included in a COMMON statement.
Program units that specify the same common block have access to the same area.
The associated values are retained even if a RETURN or END statement is executed.
TYPE Statement
The TYPE statement is used to override or to confirm implicit typing and may specify
dimension information.
3957 6053003 45
Specification Statements
,
<type> %% <variable list> %%
* , , * /<initial value list>/ ,
<type>
,
% <variable name> %%%
0 <array declarer> * * <length spec> ,
0 <array name>
0 <function name>
* <constant name> ,
<length spec>
A length immediately following the data type specifier is the length specification for
each entity in the statement not having its own length specification. A length
specification immediately following an entity is the length specification for that entity
only.
For character items, the length specification indicates the number of characters that an
entity contains. Note that for an array the length specified is for each array element.
The total length of a character variable or array may not exceed (2**20-1) characters on
MCP/AS processors or (2**28-1)*6 characters on MCP/AS (Extended) processors. If a
length is not specified for an entity, its length is assumed to be 1. When a length
specification is used with an entity declared in a CHARACTER statement, it must be an
integer constant expression, unless that entity is an external function, a dummy
argument of an external procedure, or an integer constant that has a symbolic name.
46 3957 6053003
Specification Statements
For non-character items, length specifications are allowed for compatibility with other
FORTRAN implementations. These length specifications are ignored unless associated
with items declared REAL*8 and REAL*16, whose types are set to DOUBLE
PRECISION.
If a character dummy argument has a length of (*) declared, the dummy argument
assumes the length of the associated actual argument for each reference to the
subroutine or function. If the associated actual argument is an array name, the length
assumed by the character dummy argument is the length of an array element in the
associated actual argument array.
The length specified for a character function in the program unit that references the
function must be an integer constant expression and must agree with the length
specified in the subprogram that specifies the function. Note that there is always
agreement of length if a length of (*) is specified in the subprogram that specifies the
function.
If a character constant that has a symbolic name has a length of (*) declared, the
constant assumes the length of its corresponding constant expression in a
PARAMETER statement.
The length specified for a character statement function or statement function dummy
argument of type character must be an integer constant expression.
The length specifier of (*) may only be used for character items.
3957 6053003 47
Specification Statements
IMPLICIT Statement
The IMPLICIT statement allows alteration of the default types that are normally
assigned to variable names.
,
,
IMPLICIT % <type> ( <letter> %% ) %
* - <letter> ,
* NONE ,
<type>
An IMPLICIT statement specifies a type for all variables, arrays, symbolic names of
constants, and functions (except intrinsic functions) that begin with any letter that is
specified, either as a single letter or included in a range of letters. In addition, the
symbol "$" can be used, either singly, or within a range of letters. The symbol "$" is
collated after the letter "Z". IMPLICIT statements do not change the type of any
intrinsic functions. An IMPLICIT statement applies only to the program unit that
contains it. Type specification by an IMPLICIT statement may be overridden or
confirmed by the use of a TYPE statement. An explicit type specification in a
FUNCTION statement overrides an IMPLICIT statement for the name of that function
subprogram. Note that the length is also overridden when a particular name appears in
a CHARACTER or CHARACTER FUNCTION statement.
48 3957 6053003
Specification Statements
The IMPLICIT NONE statement cancels the default type association for a program unit.
When present, it must appear before any other specification statement in the program
unit, including PARAMETER statements. Use of the IMPLICIT NONE statement
requires that variables, arrays, symbolic names of constants, and functions (except
intrinsic functions) have their type explicitly declared. The appearance of IMPLICIT
NONE with any other form of the IMPLICIT statement within a program unit results in
a syntax error. When set, the IMPLICITNONE compiler control option causes all
program units encountered to be treated as though there was an IMPLICIT NONE
statement in them.
The same letter or the symbol "$" must not appear singly or be included in a range
more than once in all of the IMPLICIT statements in a program unit.
PARAMETER Statement
The PARAMETER statement is used to give a constant a symbolic name.
,
PARAMETER ( <constant name> = <constant expression> )
If the symbolic name is of type integer, real, double precision, or complex, the
corresponding expression must be an arithmetic constant expression. If the symbolic
name is of type character or logical, the corresponding expression must be a
character constant expression or a logical constant expression, respectively.
The constant is defined with the value of the expression that appears on the right of
the equal sign, in accordance with the rules for assignment statements.
Any symbolic name of a constant that appears in an expression must have been
defined previously in the same or a different PARAMETER statement in the same
program unit. A symbolic name of a constant must not be defined more than once in a
program unit.
If a symbolic name of a constant is not of default implied type, its type must be
specified by a TYPE statement or IMPLICIT statement prior to its first appearance in a
PARAMETER statement. If the length specified for the symbolic name of a constant of
type character is not the default length of 1, its length must be specified in a TYPE
statement or IMPLICIT statement before the first appearance of the symbolic name of
the constant. Its length must not be changed by subsequent statements, including
IMPLICIT statements.
3957 6053003 49
Specification Statements
Once a constant is defined, it may appear in that program unit in any subsequent
statement as a primary in an expression, in a DATA statement, or be included in a
COMMON statement. A symbolic name of a constant must not be part of a format
specification or must not be used to form part of another constant (for example, any
part of a complex constant). A symbolic name in a PARAMETER statement may
identify only the corresponding constant in that program unit.
Examples:
PARAMETER (PVALUE=5.6789)
PARAMETER (RFACT=3.563, R2FACT=2*RFACT, T=.TRUE.)
EXTERNAL Statement
An EXTERNAL statement is used to indicate that a symbolic name represents an
external procedure or dummy procedure and to permit such a name to be used as an
actual argument.
,
EXTERNAL % <subroutine name> %
0 <function name>
* <block data subprogram name> ,
EXTERNAL EQUIV
EXTERNAL SUBA, FCN1
INTRINSIC Statement
An INTRINSIC statement is used to identify a symbolic name as representing an
intrinsic function. It also permits a name that represents a specific intrinsic function to
be used as an actual argument.
,
INTRINSIC <function name>
Type conversion: INT, IFIX, HFIX, IDINT, FLOAT, SNGL, REAL, DBLE,
DFLOAT, CMPLX, DCMPLX, ICHAR, CHAR
Lexical relationship: LGE, LGT, LLE, LLT
Character UPPERCASE, UPPERC, LOWERCASE, LOWERC,
manipulation: TRIM, ADJUSTL, ADJUSTR, LEN_TRIM, TRMLEN
Choosing the largest or MAX, MAX0, AMAX1, DMAX1, AMAX0, MAX1, MIN,
smallest value: MIN0, AMIN1, DMIN1, AMIN0, MIN1
Bit manipulation: AND, IAND, COMPL, NOT, EQUIV, OR, IOR, EOR,
IEOR, SHFT, ISHFT, BITS, IBITS, BSET, IBSET, BCLR,
SHFTC, ISHFTC, BTEST, ISOL, TIME, CTIME, DATE,
RANDOM, GAMMA, DGAMMA, LGAMA, ALGAMA,
DLGAMA, ERF, DERF, ERFC, DERFC, VALUE, CHARS,
SKIP
The appearance of a generic function name in an INTRINSIC statement does not cause
that name to lose its generic property.
Examples:
INTRINSIC TANH
INTRINSIC LOG10, EXP
SAVE Statement
A SAVE statement is used to retain the definition status of an entity after the
execution of a RETURN or END statement in a subprogram. Within a function or
subroutine subprogram, an entity specified by a SAVE statement does not become
undefined as a result of the execution of a RETURN or END statement in the
subprogram. However, such an entity in a common block may become redefined in
another program unit.
SAVE %%
,
*% <variable name> %,
0 <array name>
* / <common block name> / ,
A SAVE statement without a list is treated as though it contained the names of all
allowable items in that program unit.
The appearance of a common block name preceded and followed by a slash in a SAVE
statement has the effect of specifying all of the entities in that common block.
If a local entity that is not in a common block and not specified by a SAVE statement is
in a defined state at the time the RETURN or END statement is executed in a
subprogram, that entity is defined with the same value at the next reference of that
subprogram.
Examples:
SAVE
SAVE /CMBLKA/,AX,ZZ,/CMBLKB/
The DATA statement is used to provide initial values for variables, arrays, array
elements, and substrings. A DATA statement is non-executable and may appear in a
program unit anywhere after the specification statements, if any. All initially defined
entities are defined when an executable program begins execution.
3957 6053003 51
DATA Statement
,
DATA <variable list> / <initial value list> /
<variable list>
,
<variable name>
<array element name>
<array name>
<substring name>
<data implied-DO list> %
,
( <array element name> , <DO-variable> = <ae> , <ae> (
<data implied-DO list> %
( )
,<ae> %
<ae>
,
<constant>
<repeat> * <constant name> %
<constant name> %
<repeat>
<nonzero unsigned integer constant>
Names of dummy arguments and functions must not appear in the list of elements to
be defined. The names of entities in a common block may appear in this list only
within a main program or a block data subprogram.
When the compiler option SEPARATE is set, a program unit may use DATA
statements with common block entities only when BOTH of the following conditions
are met:
52 3957 6053003
DATA Statement
If a program unit uses DATA statements with common block elements and binding is
involved, the following cautions should be noted:
1. If a common block is assigned initial values in a given program unit and the
program unit that initializes the common block is replaced by another program
unit, the original data in the common block is lost if CODEFILEINIT was not set
when the common block was first encountered. The program unit that is replacing
the original program unit might or might not itself initialize the common block.
2. If a common block is assigned initial values in one program unit and a DIFFERENT
program unit that also initializes the common block is bound in, the results are
unpredictable. For this reason, it is best to avoid initializing values for the same
common block in more than one program unit.
There is a one-to-one correspondence between the items specified by the variable list
and the constants specified by the initial value list, that is, the first item of variable list
corresponds to the first item of the initial value list, and so forth. The entity is initially
defined by this correspondence.
In the event that the number of items in the constants list is not equal to the number
of items in the variable list, the one-to-one correspondence holds true until the end of
the shorter of the lists. If the constants list contains more items than the variable list,
then the extra constants are ignored. If the variable list is the longer of the two lists,
then the variables are matched up with their respective constants and the remaining
variables for which there are no constants are initialized to a null value. For numeric
types, this null value is a zero, logical variables are initialized to .FALSE., and character
variables that have no corresponding constant are initialized to hex 00 (null) for their
entire length.
Correspondence between the entities in the variable list and those in the initial value
list is restricted to the following:
1. If the variable entity is of type integer, real, or double precision, the corresponding
value constant must be of type integer, real, double precision, hexadecimal,
character, or Hollerith.
2. If the variable entity is of type complex, the corresponding value constant must be
of type integer, real, double precision, complex, hexadecimal, character, or
Hollerith.
3. If the variable entity is of type logical, the corresponding value constant must be
of type logical, hexadecimal, or Hollerith.
4. If the variable entity is of type character, the corresponding value constant must
be of type character, hexadecimal, or Hollerith. If the constant is of type
hexadecimal, it must fill the character variable, array element, or substring exactly.
A non-character entity becomes defined with a hexadecimal value according to the
rules for input as if it were done with Z format.
Strings may be stored in any type of variable, not just those of type CHARACTER. This
storage includes both quoted strings and Hollerith data. This storage is allowed in
DATA statements, as well as in the initial value lists of type declaration statements.
3957 6053003 53
DATA Statement
Items of type INTEGER can hold a maximum of four characters. The value is stored in
the [31:32] bit field. Bit field [47:16] contains zeros, eliminating any possibility of integer
overflow. REAL and LOGICAL values can hold a maximum of six characters, while
COMPLEX and DOUBLE PRECISION items can hold a maximum of twelve characters.
Strings that initialize a variable or array element and that exceed the length of the
element are truncated from the right. Strings that are smaller than their corresponding
DATA elements are left-justified and filled with blanks. For word variables only, when a
long string (greater than one element) initializes an array name, the entire string is
transferred to the array beginning with the starting element until the end of the string,
or the end of the array is encountered (refer to Section 15 for more information). If the
string ends before the entire array is filled, the last initialized element has its value left-
justified and filled on the right with blanks. The remaining elements of the array are
filled with the next values in the data list.
Examples:
INTEGER I,J,K
REAL A,B,C(3),D(2)
DATA I,J,K /"A","ABCD","ABCDEF"/
DATA A,B /"ABCD", "ABCDEF"/
DATA C,D /"ABCDEFGHIJKL", "MNOPQRST", "ABC", "DEF"/
I = 0000C1404040
J = 0000C1C2C3C4
K = 0000C1C2C3C4 (EF Is TRUNCATED)
A = C1C2C3C44040
B = C1C2C3C4C5C6
C(1) = C1C2C3C4C5C6
C(2) = C7C8C9D1D2D3
C(3) = D4D5D6D7D8D9 (ST IS TRUNCATED)
D(1) = C1C2C3404040
D(2) = C4C5C6404040
If necessary, the initial value is converted to the type of the variable entity according
to the rules for input. Table 5-2 describes the conversion performed on a constant in
the variable list when it defined the initial value of a variable entity.
54 3957 6053003
DATA Statement
CHARACTER n n n n n n
HEXADECIM n n n n n n
AL
HOLLERITH n n n n n n
Legend
n No conversion except as previously noted for strings, hexadecimal constants, or
Hollerith
int Truncate to integer if magnitude does not exceed maximum integer size, integer
overflow error given otherwise
real Convert to real number
dble Convert to double precision value
cmplx Convert to real and supply zero imaginary part
i Invalid combination resulting in syntax error
If a single element is defined more than once in a DATA statement, it is assigned the
most recent value associated with it. If two entities are related and both are initially
defined in a DATA statement, then the result is undefined. Subscript expressions for
array elements must be integer constant expressions, except for implied-DO
variables; substring expressions must be integer constant expressions.
Each subscript expression in the item list must be an integer constant expression,
except that the expression may contain implied-DO variables of implied-DO lists that
have the subscript expression within their ranges.
If the length of a character entity in the item list is greater than the length of its
corresponding character constant, the additional right-most characters in the entity are
initially defined with blank characters. If the length is less than the length of its
corresponding character constant, the additional right- most characters in the constant
are ignored. Note that each character constant initially defines exactly one variable,
array element, or substring.
3957 6053003 55
DATA Statement
LOGICAL L1, L2
CHARACTER ACHAR*06, BCHAR*06,CCHAR*02
DIMENSION A(6)
COMPLEX ZCMP
DATA L1,L2 /2 * .TRUE./, ACHAR, BCHAR, CCHAR /3 * 123/
DATA INT, (A(I) ,i=4,6) /3.6, 2*05.2, 2.2/, ZCMP /(2.9,1.1)/
L1=.TRUE.
L2=.TRUE.
ACHAR=123
BCHAR=123
CCHAR=12
INT=3
A(4)=5.2
A(5)=5.2
A(6)=2.2
ZCMP=(2.9,1.1)
56 3957 6053003
Section 6
Assignment Statements
When a character expression evaluates to a string with a length that exceeds that of
the element assigned, the string is truncated from the right. When the length of the
string is less than that of the element, the string is stored left-justified and filled on the
right with blank characters. If the element assigned is of type DOUBLE PRECISION or
COMPLEX and the string is less than or equal to six characters, these characters are
stored right-justified in the first word and the second word is zero. If the number of
characters assigned to a DOUBLE PRECISION or COMPLEX is greater than six and less
than twelve, the right-justification extends across two words. For example, DBLP =
'123456789' results in the DOUBLE PRECISION variable DBLP being assigned
Z000000F1F2F3F4F5F6F7F8F9 (hexadecimal representation assuming EBCDIC
characters).
3957 6053003 61
Assignment Statements
In general, the variable and the arithmetic expression need not be of the same type. If
the types are different, the expression is first evaluated and then converted to the
type of the variable. This conversion proceeds according to the rules indicated in Table
6-1.
Integer INT(exp)
Real REAL(exp)
Double Precision DBLE(exp)
Complex CMPLX(exp)
Character CHARS(exp)
The functions in the "Value Assigned" column of the previous table are generic
functions as described in Section 12.
D = E(3) - 2.5
F(2)= FCN(2,3) + 3.5*I
62 3957 6053003
Assignment Statements
The following are examples of logical assignment statements where L1, L2, and L3 are
logical variables and A, B, and C are real variables:
L1 = L1 .AND. L2
L3 = A .GT. B .OR. B .LT. C
L2 = .TRUE.
Executing the ASSIGN statement assigns a statement label to a variable. The label
must be that of an executable statement or a format statement that appears in the
same program unit as the ASSIGN statement. Executing the ASSIGN statement is the
only way to define a variable with a statement label value. The variable, once defined,
may be referenced in an assigned GO TO statement or as a format identifier in an
input/output statement. Until it has been reassigned with an arithmetic value, an
assigned variable must not be referenced in any other manner. It may be redefined
with a statement label or an arithmetic value at any time.
ASSIGN 10 TO FRMT
WRITE (5,FRMT)I
10 FORMAT (I3)
Character Assignment
The character assignment statement assigns a value to a character variable or
character substring.
3957 6053003 63
Assignment Statements
If the length of the entity defined is greater than the length of the expression, the
entity is assigned the value of the expression and is left- justified. The remainder of
the entity is filled with blank characters. If the length of the variable is less than the
length of the expression, the expression is truncated from the right before it is
assigned to the variable.
The following are examples of character assignment statements for the declaration:
CHARACTER C1(5)*05, C2*02, C3*08
C3 = C1(1) // C2 // X
C1(1)(2:3) = A // C2
C2 = C3(1:2)
CHARACTER *6 C CHARACTER *6 C
REAL X and REAL X
C = X C = CHARS (X)
are equivalent.
Note that the "created string" has the exact bit pattern as the arithmetic/logical item. It
is not a string representing the digits of the item's value. For example,
INTEGER I
CHARACTER *4 C
I= 193 ! I contains 0000000000C1 (in hex)
C = I ! C contains 000000C1 (in hex) that came from Is bits
! 31 through 0. This is ???A (in EBCDIC) where ?
! is the EBCDIC NULL character (00 hex value).
! Note that C does not contain 0193 (in EBCDIC).
In actuality, the compiler does not create a true physical character string for the
expression. The expression is evaluated and the bits from the resulting value are
transferred into the character item (which appears on the left side of the equal sign).
This transfer continues until the character item is filled. Blanks are padded on the end
if the value transferred is not large enough to fill the character item.
64 3957 6053003
Assignment Statements
Examples
REAL X
INTEGER I
DOUBLE NRECISION D
CHARACTER C4*4, C6*6, C10*10, C12*12
X = D1D2D3D4D5D6X ! X now contains D1D2D3D4D5D6 (in hex)
C6 = X ! C6 now contains JKLMNO (in EBCDIC)
C4 = X ! C4 now contains JKLM (in EBCDIC)
I = C1C2C3C4X ! I now contains 0000C1C2C3C4 (in hex)
C4 = I ! C4 now contains ABCD (in EBCDIC)
C6 = I ! C6 now contains ABCD (in EBCDIC)
D = STUVWX123456 ! D now has E2E3E4E5E6E7F1F2F3F4F5F6 (in hex)
C6 = D ! C6 now contains STUVWX (in EBCDIC)
C10 = D ! C10 now contains STUVWX1234 (in EBCDIC)
C12 = D ! C12 now contains STUVWX123456 (in EBCDIC)
3957 6053003 65
Assignment Statements
66 3957 6053003
Section 7
Control Statements
The executable control statements are used to alter the normal flow of program
execution. These statements may transfer control to another part of the program,
terminate or suspend execution, or control iterative processes.
Unconditional GO TO
Assigned GO TO
Computed GO TO
Arithmetic IF
Logical IF
Block IF, ELSE IF, ELSE, END IF
DO
CONTINUE
PAUSE
STOP
END
CALL
RETURN
GO TO Statements
The executable GO TO statements transfer control from one point of an executing
program to another point in the same program unit.
Unconditional GO TO
The format for an unconditional GO TO statement is the following:
3957 6053003 71
Control Statements
Assigned GO TO
The format for an Assigned GO TO statement is as follows:
Executing this statement transfers control to the statement whose label was last
assigned to the variable by an ASSIGN statement in the same program unit as the
assigned GO TO statement. If the parentheses list is present, the statement label
assigned to the variable must be one of the statements in the list.
Examples:
ASSIGN 9 TO IJK
GO TO IJK, (9,1,2)
ASSIGN 2 TO KI
GO TO KI
Computed GO TO
The format for a computed GO TO statement is the following:
,
GO TO ( <label> ) <integer expression>
,
Executing this statement transfers control to a statement whose label appears in the
parentheses list or to the next executable statement following the GO TO statement.
How control is transferred depends on the value of the expression following the list.
The expression is evaluated and is used to select one of the labels in the list. If the
expression has the value n, control passes to the nth label in the list. If there are fewer
than n labels in the list or if n is less than or equal to zero, control passes on to the
next executable statement following the GO TO statement.
GO TO (11,25,3,9,11,17), J+1
72 3957 6053003
Control Statements
At execution time, the value of J+1 is computed. If J+1=4, then control passes to the
statement labeled 9, the fourth label in the list. If J+1 is one or five in this example,
control passes to the statement labeled 11. If J+1 is less than one or greater than six,
control passes to the next executable statement after the GO TO statement.
IF Statements
Arithmetic IF
The arithmetic IF statement is a three-way branch.
The same statement label may appear more than once in the IF statement. Execution
of the arithmetic IF statement causes the arithmetic expression within the
parentheses to be evaluated. Control is transferred to the statement bearing the first,
second, or third label, depending on whether the value of the expression is less than
zero, zero, or greater than zero, respectively.
IF (J*05-B+2) 3,2,3
In this example, control passes to the statement labeled 2 only if the expression
within the parentheses is zero. Otherwise, control passes to the statement labeled 3.
Logical IF
The logical IF statement conditionally executes a statement.
3957 6053003 73
Control Statements
IF (L1) GO TO 97
If L1 is true, then control passes to the statement labeled 97. If L1 is false, then control
passes on to the next statement.
If A is less than or equal to 97, then the arithmetic IF is executed, and control passes
on to statement number 12 or 13, depending on the value of B. If A is greater than 97,
control passes on to the next statement.
Block IF
The block IF statement is used with the END IF statement and optionally the ELSE IF or
ELSE statements to control execution sequence. The block IF may have associated an
ELSE or an ELSE IF statement. Nevertheless, it must have a corresponding END IF
statement.
IF level = X1-X2
where X1 is the number of block IF statements from the beginning of the program unit
up to and including this statement, and X2 is the number of END IF statements in the
program unit up to, but not including, this statement.
Every statement must have an IF level greater than or equal to zero. Each block IF,
ELSE, ELSE IF, and END IF must have an IF level greater than zero.
74 3957 6053003
Control Statements
All the statements that appear following the block IF statement up to, but not
including the next END IF, ELSE, or ELSE IF that has the same IF level as the block IF
are called the IF block. An IF block may be empty. Execution of the block IF statement
causes evaluation of the logical expression contained in the statement. If the value of
the expression is true, normal execution sequence continues to the statements within
the IF block. If the IF block is empty, control is transferred to the next END IF
statement with the same IF level as the block IF statement. When the value of the
expression is false, control is transferred to the next ELSE IF, ELSE, or END IF
statement that has the same IF level as the block IF statement.
Transfer of control into an IF block from outside the IF block is not permitted. If
execution of the last statement in the IF block does not result in a transfer of control,
control is transferred to the next END IF statement that has the same IF level as the
block IF statement that precedes this IF block.
Block IF statements may be nested within IF blocks, ELSE blocks, or ELSE IF blocks.
The entire series of statements from the block IF through the END IF must be
contained within the block.
ELSE IF Statement
This statement is used optionally as the else part associated with a block IF statement.
It must have corresponding block IF and END IF statements and may optionally have
an else part of either an ELSE statement or another ELSE IF statement.
ELSE IF ( <logical expression> ) THEN
All of the statements appearing after the ELSE IF statement up to, but not including,
the next ELSE, ELSE IF, or END IF that has the same IF level as the ELSE IF are called
the ELSE IF block.
Execution of the ELSE IF statement causes evaluation of the logical expression in this
statement. If this value is true, execution continues to the first statement of the ELSE
IF block. If the value is true and the ELSE IF block is empty, control is passed to the
next END IF that has the same IF level as the ELSE IF statement. If the value of the
expression in the ELSE IF statement is false, control is transferred to the next ELSE IF,
ELSE, or END IF that has the same IF level as the ELSE IF statement.
If no statement within the ELSE IF block causes a transfer of control outside of the
ELSE IF block, control is transferred to the next END IF statement that has the same IF
level as the ELSE IF statement that precedes this ELSE IF block.
3957 6053003 75
Control Statements
ELSE Statement
This statement is used in conjunction with the block IF or ELSE IF statements.
All the statements following the ELSE statement up to, but not including the next END
IF statement with the same IF level as the ELSE statement are called an ELSE-block.
An END IF statement of the same IF level as the ELSE statement must appear before
the appearance of an ELSE IF or ELSE statement of the same IF level.
The ELSE statement functions like a CONTINUE statement; however, control may not
be transferred to an ELSE statement or into an ELSE block.
END IF Statement
The END IF statement functions like a CONTINUE statement. For each block IF
statement there must be a corresponding END IF statement in the same program unit.
The corresponding END IF statement is the next END IF statement that has the same
IF level as the block IF statement.
The following examples of the block IF, ELSE IF, ELSE, and END IF statements are in
order of increasing complexity.
J=0
I=0
IF ( L1 ) THEN
I=1
J=2
END IF
After the preceding statements have been executed, if L1 is true, I=1 and J=2. If L1 is
false, I=0, and J=0.
IF ( L2 ) THEN
I=1
ELSE
I=2
END IF
In the preceding example, if L2 is true I is set equal to one. If L2 is false I is set equal
to two.
76 3957 6053003
Control Statements
X=0.0
Y=1.0
Z=5.0
IF (X .EQ. 0.0) THEN
Y=3.3
ELSE IF (Z .GT. 0.0) THEN
Y=2.1
END IF
After the preceding statements have been executed, X=0.0,Y=3.3, and Z=5.0.
DO Statement
The executable DO statement is a control statement that allows a series of
statements to be executed repeatedly while the value of a control variable is varied
between specified limits. The group of statements is referred to as a DO-loop.
4
, <arithmetic expression>
The DO-variable and arithmetic expressions must be of type integer, real, or double
precision.
The execution statement that follows the DO statement within the same program unit
and contains the label <label> is called the terminal statement of the DO-loop. The
three arithmetic expressions are referred to as the initial, terminal, and incremental
arguments, respectively. If the incremental argument is omitted, its value is assumed
to be one.
The DO statement causes repeated execution of the statements in its range. The
range of a DO statement consists of all the executable statements following the DO
statement up to and including the terminal statement specified in the DO statement.
Any number of DO statements may be nested one within another with the following
restriction: if a DO statement occurs in the range of another DO, the range of the
former must be completely contained within the range of the latter. Both may,
however, specify the same statement as the terminal statement in their ranges.
3957 6053003 77
Control Statements
Transfer of control into the range of a DO-loop produces unreliable results. Changing
the value of the DO variable within a DO-loop has unspecified results. A DO-loop is
either inactive or active. A DO-loop is initially inactive and becomes active only upon
execution of the DO statement. Once active it becomes inactive when any of the
following occur:
The iteration count is zero if (M1 > M2 and M3 > 0) or if (M1 < M2 and M3 < 0).
2. Loop Control Processing
This processing determines if further execution of the range should take place.
The iteration count is tested. If the iteration count is greater than zero, the range
of the loop is executed. If the iteration count is zero, the DO-loop becomes
inactive and the range of the DO is not executed. Execution continues with the
first executable statement following the terminal statement of the DO statement.
If some of the DO-loops sharing the terminal statement are active, execution
continues with the incrementation processing.
3. Execution of the Range
The statements within the range of the DO-loop are executed until the terminal
statement is reached. Incrementation processing follows. The DO-variable of the
DO statement may not be assigned a new value while the DO-loop is active.
4. Terminal Statement Execution
Execution of the terminal statement occurs as a result of the normal execution
sequence or as a result of transfer of control. Unless execution of the terminal
statement results in a transfer of control, execution then continues with
incrementation processing.
78 3957 6053003
Control Statements
5. Incrementation Processing
Loop incrementation for the active DO-loop whose DO statement was most
recently executed consists of two steps: The DO-variable is incremented by the
value of the incremental argument and the iteration count is decremented by one.
Following these two steps, execution continues with loop control processing of
the DO-loop whose iteration count was decremented.
It should be noted that because the iteration count test is done before executing the
range of the DO-loop the range of the DO-loop may not be executed at all.
Examples of DO-loops:
N=0
DO 101 I=1,10
J=I
DO 100 K=1,5
L=K
100 N=N+1
101 CONTINUE
N=0
DO 201 I=1,10
J=I
DO 200 K=5,1
L=K
200 N=N+1
201 CONTINUE
In the following example Z is calculated as the sum of the cosines of -5.4, - 5.3, -5.2,
and -5.1:
Z=0
DO 10 X=-5.4,-5.05,.1
10 Z = COS(X) + Z
The following example initiates every other element of the arrays A and B, A(1)
through A(9) and B(1,1) through B(9,9):
IJ=10
DO 5 I = 1, IJ, 2
A(I)= 5.
DO 5 J = 1, IJ, 2
5 B(I,J)= 5.
3957 6053003 79
Control Statements
CONTINUE Statement
The executable CONTINUE statement produces no action. It is frequently used as the
terminal statement of a DO-loop.
Example:
.
.
.
DO 1 I=2,10,2
A(I)=I/M
IF (A(I)) 3,1,1
1 CONTINUE
M=-M
3 CONTINUE
.
.
.
In this example, the CONTINUE statement labeled 1 is used as the final statement of a
DO-loop and the CONTINUE statement labeled 3 is used as a transfer point for an
arithmetic IF statement. The use of the first CONTINUE allows the DO-loop to be
clearly delimited. The second CONTINUE statement allows transfer to an arbitrary
point in the program, the location of which may be changed by merely changing the
location of the CONTINUE statement.
PAUSE Statement
The executable PAUSE statement allows an executing program to be suspended
indefinitely.
The program may be resumed at the first executable statement following the PAUSE
statement by a system input message from the terminal of the form:
Alternately, the task may be discontinued at this point by a system input message of
the form:
If the program is run with CANDE, the ?OK and ?DS control commands may be used
for the system input commands listed previously.
Examples:
PAUSE
PAUSE 2
PAUSE BEFORE PUNCHING
PAUSE "BEFORE PUNCHING"
STOP Statement
The executable STOP statement allows termination of an executing program.
The execution of the STOP statement causes termination of the program. In addition,
the optional digits or character constant following the STOP to be displayed at the
terminal.
Examples:
STOP
STOP 6
STOP "PHASE 1"
END Statement
The END statement indicates the end of a program unit. When it is executed in a
function or subroutine subprogram, it has the effect of a RETURN statement. When it
is executed in a main program, it terminates the execution of the program.
The END statement must not be continued and must be an initial line. No other
statement may have an initial line that appears to be an END. The END statement must
be the last line of every program unit.
Input statements provide a method for transferring data from peripheral hardware
devices (such as disk pack, magnetic tapes, and remote terminals) to internal storage
or from an internal file (type CHARACTER data) to internal storage. This process is
called reading.
Output statements provide the means of transferring data from internal storage to
external media or from internal storage to an internal file. This process is referred to
as writing. Some input/output (I/O) statements allow for editing of the data at the time
of the transfer.
In addition to the statements that transfer data, there are auxiliary I/O statements that
permit the positioning of peripheral devices and allow for the properties of the
external media to be specified or interrogated.
READ
WRITE
PRINT
PUNCH
OPEN
CLOSE
INQUIRE
BACKSPACE
ENDFILE
REWIND
FIND
FILE
CHANGE
3957 6053003 81
Input/Output Statements
FORTRAN77 also allows the BNA (Burroughs Network Architecture) interface, PORT
files, to be used in formatted and list-directed I/O. Using unformatted I/O is not
permitted. The value PORT and all of the additional attributes and values for PORT and
SUBFILE interfacing are now recognized for the KIND attribute. For a detailed
description of PORT files and BNA, see the ClearPath Enterprise Servers
Input/Output Subsystem Programming Reference Manual.
Files
A FORTRAN77 program has access to a file by means of input/output statements.
Records may contain a sequence of values or a sequence of characters. A record that
is transferred with a formatted input/output statement is called a formatted record. It
is composed of a sequence of characters. A record that is transferred unformatted,
without editing specification, is called an unformatted record. An unformatted record
is a sequence of values in their internal machine representation. The values are
transferred from internal storage unchanged.
The N records contained in a file are logically numbered in order from 1 through N;
record 1 immediately follows the initial point of the file, while record N immediately
precedes the endfile mark terminating the file.
There are two kinds of files, external and internal. External files are used to transfer
data to and from peripheral devices. Internal files provide a means of transferring data
from internal storage to internal storage.
82 3957 6053003
Input/Output Statements
At any given time, there is a set of files that are said to exist for a FORTRAN77
program. A file may be present on a system, yet not exist for a FORTRAN77 program
at a particular time. For example, security reasons may prevent a file from existing for
a given program. A file may exist and contain no records; an example of this is a newly
created file into which records have not been written. Creating a file causes a file to
exist that did not previously exist. Deleting a file terminates the existence of the file.
All input/output statements may refer to files that exist. INQUIRE, OPEN, CLOSE,
WRITE, PRINT, ENDFILE, and PUNCH statements may also refer to files that do not
exist.
FORTRAN77 provides two methods of accessing the data records of an external file:
sequential and direct (commonly called random). When a file is accessed sequentially,
the records are processed in sequence from the first record in the file through the
last. The direct access method allows for the access of records of a file in any order.
The records are accessed by means of their record numbers relative to their position
in the file. Note that internal files must be accessed sequentially only.
Units
A unit is a means of referring to a file. All unit numbers explicitly appearing in FILE
statements or in input/output statements (except INQUIRE) are said to exist for a
program. Unit numbers 5, 6, and 7 also always exist for a program regardless of being
referenced explicitly. In order to process an external file it is necessary that a file be
connected to a input/output unit. Unit numbers 5, 6, and 7 and unit numbers appearing
in FILE statements are preconnected.
All input and output statements may refer to units that exist. The INQUIRE and CLOSE
statements may also refer to units that do not exist.
Each unit identifier has a default device type associated with it. If a FORTRAN77
compilation is initiated through the Command and Edit Language (CANDE), units 5 and
6 are assigned a KIND of REMOTE. Otherwise, unit 5 is assigned a KIND of READER
and Unit 6 assigned a KIND of PRINTER. All other units are assigned a KIND of DISK by
default, including unit 7, which has historically been associated with punch card output
devices.
Note: Punch card output devices are no longer supported on ClearPath Enterprise
Servers.
A unit must not be connected to more than one file at the same time, and a file must
not be connected to more than one unit at the same time. However, means are
provided to change the status of a unit and to connect a unit to a different file. After a
unit and a file have been disconnected by the execution of a CLOSE statement, a unit
may be connected again within the same executable program to the same file or a
different file.
3957 6053003 83
Input/Output Statements
Each file is recognized by the system by two names: the internal name and the
external name or the value of the TITLE attribute of the file. (Refer to the ClearPath
Enterprise Servers Input/Output Subsystem Programming Reference Manual for
more information.)
Where the unit identifier is greater than or equal to 0, less than or equal to 99, and
contains no leading zeros.
The internal file names corresponding to the units 6 and 99 are FILE6 and FILE99,
respectively.
The TITLE of a file consists of one to fourteen identifiers separated by slashes (/); each
identifier is one to seventeen characters long. When the TITLE of a program file is
unspecified, a default TITLE is assigned to the file that is identical to the internal file
name.
[UNIT =] u
[FMT=]f
[REC=]r
IOSTAT=i
ERR=s
END=s
SUBFILE=i
URGENT=l
The following are restrictions on the items in the control information list:
84 3957 6053003
Input/Output Statements
4. If the unit specifier specifies an internal file, the list must contain a format
identifier other than an asterisk and must not contain a record specifier or a Subfile
specifier.
5. If the unit specifier was an asterisk, then a format specifier must be present, and
the record specifier must not be present.
6. If the Subfile specifier is present, then a format specifier must be present and
must not be an asterisk.
7. If the urgent specifier is present, then a format specifier must be present and
must not be an asterisk.
8. The urgent specifier is only valid with sequential formatted output statements to a
TCP subport.
The following paragraphs detail information on control list items. Examples may be
found following "READ, WRITE, PRINT, and PUNCH Statements".
Unit Specifier
The unit specifier designates the external unit to be used for the input/output
statement in which it appears.
If the optional characters UNIT= are omitted from the unit specifier, the unit specifier
must be the first item in a list of specifiers of an input/output statement. The unit
identifier can be either an internal file identifier or an external unit identifier. An internal
file identifier is used to refer to an internal file. It can be the name of a character
variable, character array, character array element, or character substring.
An external unit identifier is used to refer to an external file. It may be one of the
following:
1. An integer expression whose value is greater than or equal to zero and less than
or equal to 99. If the expression is not an integer constant, then, upon execution, it
is evaluated and rounded to the nearest integer.
2. (In READ or WRITE statements only) an asterisk, identifying unit 5 or 6, which are
preconnected for formatted sequential read or write, respectively.
In auxiliary input/output statements the asterisk form may not be used.
The external unit identified by a value is the same external unit in all program units of
the executable program, as shown in the following example:
SUBROUTINE A
READ (6) X
.
.
3957 6053003 85
Input/Output Statements
SUBROUTINE B
N=6
REWIND N
The value 6 used in both program units identifies the same external unit.
SUBROUTINE SUB
CHARACTER *14 CHAR
WRITE(CHAR,10) X
10 FORMAT(1X,F13.8)
.
.
Format Specifier
The format specifier designates the format to be used for the I/O statement in which
it appears.
1. The statement label of a FORMAT statement that appears in the same program
unit as the format identifier.
2. An integer variable name that has been assigned the statement label of a FORMAT
statement that appears in the same program unit as the format identifier.
3. An array name.
4. Any character expression, except a character expression involving concatenation
of an operand whose length specification is an asterisk in parentheses unless the
operand is the symbolic name of a constant. Note that a character constant is
permitted.
5. An asterisk, specifying list-directed formatting.
If the optional characters FMT= are omitted from the format specifier, the format
specifier must be the second item in the control information list and the first item
must be the unit specifier without the optional characters UNIT=.
Record Specifier
The record specifier is used to specify the number of the record that is to be read or
written with the I/O statement in which it appears.
86 3957 6053003
Input/Output Statements
If the optional characters REC= are omitted from the record specifier, the unit specifier
must appear without the optional characters UNIT=, and the unit specifier and record
specifier must be combined in the form:
ur
to form one list item, which must be the first item in the control information list.
The record number must have a value greater than or equal to 1 and less than or equal
to the number of records in the file for which the I/O is to be done.
Class designates a general error condition and subclass a refinement of that general
error condition. The value of subclass only has meaning within a particular class. If
a class has no associated subclass (that is, MOD(IOSTAT,1000) .EQ. 0), then there
is no additional information available concerning the nature of the error. Table 8-1
shows valid class values and their associated subclasses.
3. With a negative integer value if an end-of-file condition is encountered and no
error condition is encountered.
If an I/O error or end-of-file condition occurs and no error or end-of- file specifier is
present, the presence of an I/O status specifier prevents termination of the program.
Execution continues with the next executable statement.
3957 6053003 87
Input/Output Statements
1000
I/O Status
00 Unknown error
10 Security error
30 Parity error
50 Bad subfile index
60 Broadcast write error
110 Break on datacomm output
120 I/O timeout
140 Data error
150 Record length error
2000 Open error
00 Unknown error
40 File already open
50 Bad subfile index
60 Open all error
70 Unsupported function
80 Unsupported protocol type
90 Protocol error
100 Lack of resources
110 File does not exist
120 Genealogy mismatch
130 Serial number mismatch
160 Pack not mounted
180 Unreachable host value
200 Host not in host group
210 Unauthorized for application group
220 BNA IPC unavailable
230 Bad attributes for open
240 Unavailable function
250 Unsupported INTMODE
260 Networking not supported
88 3957 6053003
Input/Output Statements
Error Specifier
The error specifier provides the ability to alter the execution sequence when an error
condition occurs during the execution of and I/O statement.
If an I/O statement contains an error specifier and the processor encounters an error
condition during execution of the statement, execution of the I/O statement
terminates; if the I/O statement contains an I/O status specifier, the I/O specifier
becomes defined with a value corresponding to the error condition, and execution
continues with the statement label.
End-Of-File Specifier
The end-of-file specifier provides the ability to alter the execution sequence when an
end-of-file condition is encountered during an I/O statement.
3957 6053003 89
Input/Output Statements
If the conditions occur and the end-of-file specifier is missing, then execution of the
program is terminated unless an IOSTAT specifier is present.
Subfile Specifier
A program can, by specifying a subfile index, perform a read or write to a particular
subfile. FORTRAN77 currently allows subfiles to be specified for formatted I/O only.
The subfile index specifies the subfile to be used for the read or write operation. If the
subfile index is omitted and MAXSUBFILES is equal to one, the I/O is performed on the
only subfile of the file. If a subfile index less than zero or greater than MAXSUBFILES is
specified, or no subfile index is specified and MAXSUBFILES is greater than 1, then the
program is terminated with an error. If a subfile index of zero is specified on a read, a
non-selective read is performed. The non-selective read permits reading of the next
message from any subfile. If a subfile of zero is specified for a write, the message is
broadcast to all open subfiles.
Urgent Specifier
If urgent is specified and its accompanying logical expression evaluates to true, then
the data is sent with urgent notification. The urgent specifier is only valid when
performing sequential formatted output to an external file. Any other usage causes a
syntax error. The urgent specifier is intended for TCP subports only and any other
usage has no effect on the execution of the program.
Input/Output List
The I/O list specifies the data entities to which or from which data is to be transferred.
An I/O list is a list of I/O list items and implied-DO lists. An input list item may be a
variable name, an array element name, an array name, or a character substring name.
An output list item may be a variable name, an array element name, an array name, a
character substring name or an expression. However, a character expression involving
concatenation of an operand whose length specification is an asterisk in parentheses
is not permitted unless the operand is the symbolic name of a constant.
? @ , A
B <expression> B
C <array name>
<io implied DO list>
<ae>
The range of an implied-DO list is the <io list>. Note that the list may contain
implied-DO lists. The iteration count and the values of the DO- variable are established
from <ae> statements exactly as for a DO-loop. In an input statement, the
DO-variable must not appear as an input list item.
Transfer of data to and from list elements occurs in the order in which they are named
in the I/O list, from left to right. Items named in an implied-DO I/O list are referenced
repeatedly until the implied- DO is satisfied. The appearance in an I/O list of an array
element specifies only that array element, while the appearance of an array name
specifies every element declared for the array in that program unit. These array
elements are transferred in the order in which they are stored internally.
The following are examples of I/O lists that may be used for input or output:
A,B(3)
XARRAY, XARRAY (2,4)
(A(J) , B , J , C(J,J) , J = 1,10,2)
(IPLOT , COUNT = 1,60)
(X, (Y(I,J), I=1,10), Z, J=1,2)
XARRAY(3), XARRAY, (XARRAY(EL), EL = 1,20)
RESULT
(A(I), I=1,20) , (J(I), I=1,5)
(((Z(I,J,K), K=1,10), J=1,10),I=1,10),A,G
The following are examples of I/O lists that may be used for output only:
1+COS(N) , X(1+N), G
A .OR. B
A, (J,GX(J), B, J=3,4),10,X
PARTA // PARTZ
?@ , A
B /1\ <unit identifier> B
C <combined expr> , <format identifier>
UNIT = <unit identifier>
C /1\ FMT = <format identifier>
C /1\ REC = <integer expression>
END = <label>
C /1\ ERR = <label>
<combined expression>
<io list>
?@ , A
B <expression> B
C <array name>
<io implied-DO list>
<io implied-DO list>
<unit identifier>
<ae>
A data transfer statement that contains a control information list must include a unit
specifier that identifies an external unit or an internal file.
Data transfer statements that do not contain a control information list specify units 5,
6, and 7 by default, depending on which statement is used. For example, the READ
statement specifies unit 5. The WRITE statement and the PRINT statement specify
unit 6, and the PUNCH statement specifies unit 7.
A data transfer statement that does not contain a format specifier indicates that
unformatted I/O is to be performed. Unformatted output always results in whole
words. A character string with a length that is not an integral number of words is
padded with nulls to a word boundary in the output record. Unformatted I/O may not
be used with any file for which FILETYPE=6 and UNITS=CHARACTERS are specified.
The following are examples of the READ, WRITE, PRINT, and PUNCH statements. In
these examples 10, 95, and 99 are statement labels; 99 is used as the statement label
for error specifiers; 10 is the label on a format statement; and 95 is used as the
statement label for end-of-file specifiers. The 9 appearing in the following examples is
a unit specifier and the 3 is a record specifier.
READ (9,10,END=95)A
READ (ERR=99,UNIT=9,REC=3,FMT=10)A,B
WRITE (9)A,B
WRITE (93,10,ERR=99)A
WRITE (UNIT=9,FMT= (5X,I6,I9))A,B
PRINT 10
PUNCH 10, A, B
READ(*,10,ERR=99)A
The following are two examples of list-directed write statements to the default unit 6.
WRITE(*,*)A,B
WRITE(IOSTAT=RESULT,UNIT=*,FMT=*)A,B
The following are examples of data transfer I/O statements from an internal file (type
character data) to internal storage (READ), and from internal storage (WRITE) to an
internal file.
In the preceding example the first twelve characters and the last twelve characters of
the variable CRD are transferred as four integer values into the four elements of the
array IARY. One record is read.
DIMENSION A(6)
CHARACTER X(6)*7
WRITE(X,FMT=15)A
15 FORMAT(I5)
In the preceding example six internal file records are written. The six elements of
array A are transferred into the six elements of array X. Each of the five character
values is left-justified in each element and the remaining two characters of each
element are blanks.
?@ , A
OPEN ( B /1*\ <unit identifier> B )
UNIT =
C <file attribute specifier>
C /1\ ERR = <label>
C /1\ FILE = <character expression>
C /1\ STATUS = <character expression>
C /1\ ACCESS = <character expression>
/1\ FORM = <character expression>
C /1\ RECL = <integer expression>
C /1\ BLANK = <character expression>
C /1\ IOSTAT = <integer variable name>
<integer array element name>
C /1\ TITLE = <character expression>
C /1\ DISP = <character expression>
C /1\ SUBFILE = <integer expression>
C /1\ OPENTYPE = <character expression>
/1\ MAXRECSIZE = <integer expression>
The list in the OPEN statement must contain a unit specifier and may contain at most
one of each of the specifiers ERR, FILE or TITLE, STATUS or DISP, ACCESS, FORM,
RECL or MAXRECSIZE, BLANK, IOSTAT, SUBFILE, and OPENTYPE. If a file is to be
connected for direct access, the RECL specifier must be used. In addition to the
specifiers explicitly named here, any legal file attribute as defined in the ClearPath
Enterprise Servers I/O Subsystem Programming Reference Manual may appear in the
OPEN statement.
The integer expression for a file attribute allows the attributes of a certain subfile to
become set. If a subfile index of zero is specified, the attribute assignment applies to
all subfiles in the file. If MAXSUBFILES is equal to one, the subfile index may be
omitted and the attribute assignment applied to the only subfile.
Specifier Description
Specifier Description
Specifier Description
If a unit is connected to a file that exists, execution of an OPEN statement for that unit
is permitted. If the FILE specifier is not included in the OPEN statement, the unit
remains connected to the same file.
If the file specified in an OPEN statement does not exist, but is the same as the one to
which the input/output unit is preconnected, then the actions specified by the OPEN
statement are performed.
If the file to be connected to the unit is not the same as the one to which the unit is
connected, the effect is as if a CLOSE statement without a STATUS specifier had been
executed, followed by the OPEN statement.
If the file to be connected to the input/output unit is the same as the one to which the
unit is already connected, only the BLANK specifier may have a value different from
the one currently in effect. The position of the file is unaffected.
Execution of the OPEN statement causes the new specifier values to become
effective. Sequential files are repositioned to the beginning-of-file. If the file is
connected to a unit, execution of an OPEN statement for the same file and a different
unit is not permitted.
If a file is preconnected via a FILE statement and there is no explicit OPEN on that file,
specifiers that do not appear in the FILE statement have the same default values as if
the file had been connected via an OPEN statement.
With the exception of the AVAILABLE value for the OPENTYPE specifier, the SUBFILE
and OPENTYPE specifiers are ignored if used in an OPEN statement for a file with
KIND not equal to PORT.
CLOSE Statement
The CLOSE statement is used to terminate the connection of a file to a unit.
The list in the CLOSE statement must contain a unit specifier and may contain at most
one of each of the other specifiers.
Specifier Description
Execution of a CLOSE statement need not occur in the same program unit as the
execution of an OPEN statement for that input/output unit. Execution of a CLOSE
statement for a unit that is not connected to any file is permitted and is ignored.
After a unit has been disconnected from a file by a CLOSE statement, it may be
connected again within the same FORTRAN77 program, either to the same file or to a
different file, and the file, if it still exists, may be connected again, either to the same
unit or to a different unit. At the end of execution of a FORTRAN77 program, all
existing connections between units and files are closed. The effect is the same as if a
CLOSE statement without a STATUS specifier were executed on each connected unit.
The SUBFILE specifier is ignored if the file used in the CLOSE statement has KIND not
equal to PORT.
Following are examples of the CLOSE statement: CHR is a character variable and IOST
is an integer variable.
CLOSE(UNIT=8,STATUS=KEEP,IOSTAT=IOST)
CLOSE(3,STATUS=DELETE,ERR=100)
CLOSE(UNIT=9,STATUS=CHR)
CHANGE Statement
The CHANGE statement is an auxiliary I/O statement that modifies the attributes of a
file or library. For libraries, the CHANGE statement may be used only before the library
is accessed.
?@ , A
CHANGE ( B /1*\ <unit identifier> B )
UNIT =U
C <file clist>
<file attribute specifier>
<library id> , <library clist>
<file clist>
/1\ IOSTAT= <integer variable>
C /1\ ERR= <statement label>
C /1\ FILE= <character expression>
C /1\ STATUS= <character expression>
/1\ BLANK= <character expression>
<library clist>
/1\ TITLE= <character variable>
C /1\ LIBPARAMETER= <character constant>
/1\ FUNCTIONNAME=
The value of the integer expression for the file attribute specifies the subfile to be
used in the attribute assignment. If MAXSUBFILES is equal to one, the subfile index
may be omitted, and the attribute assignment applied to the only subfile. If a subfile
index of zero is specified, the assignment applies to all subfiles in the file.
Examples:
CHANGE (LIBID,TITLE=ABC)
CHANGE (7,MAXRECSIZE(2)=200)
CHANGE (UNIT=7,BLANK=NULL)
INQUIRE Statement
An INQUIRE statement may be used to determine the properties of a particular file or
a file connected to a particular I/O unit. All value assignments are done according to
the rules for assignment statements.
The INQUIRE statement may be executed before, during, or after a file is connected to
a unit. Current values of properties at the time the statement is executed are
returned.
There are two ways to specify the file to be queried: by FILE or by UNIT. If the user
specifies by FILE, the name or title of the file is used and the UNIT specifier may not
appear. If the user specifies by UNIT, the unit number is used and a FILE specifier may
not appear.
?@ , A
QB /1*\ <unit identifier> B )
C UNIT =
FILE = <character expression>
C <file attribute specifier>
C /1\ ERR = <label>
C /1\ IOSTAT = <integer variable name>
C /1\ NUMBER = <integer array element name>
C /1\ RECL =
C /1\ NEXTREC =
C /1\ EXIST = <logical variable name>
C /1\ OPENED = <logical array element name>
C /1\ NAMED =
C /1\ NAME = <character variable name>
C /1\ ACCESS = <character array element name>
C /1\ SEQUENTIAL =
C /1\ DIRECT =
C /1\ FORM =
C /1\ FORMATTED =
C /1\ UNFORMATTED =
/1\ BLANK =
The FILE specifier has the same format as for the OPEN statement. The named file is
the file whose properties are being examined. It need not exist or be connected to a
unit.
The UNIT specifier has the same format as for the control information list. The UNIT
specified need not exist or be connected to a file. If it exists and is connected to a file,
the inquiry is being made about the properties of that file. (Exception: The EXIST
attribute refers to the unit itself, not to the connected file.) If the unit does not exist,
both EXIST and OPENED return false and other results are undefined.
The integer expression for a file attribute specifies the subfile to be used when
accessing the attribute value. If MAXSUBFILES is equal to one, the subfile index may
be omitted, and the attribute access applied to the only subfile. If a subfile index of
zero is specified for attribute access, an attribute error occurs.
Specifier Description
Specifier Description
When an INQUIRE statement for a file is executed the inquiry specifiers NAMED,
NAME, SEQUENTIAL, DIRECT, FORMATTED, and UNFORMATTED become defined if
the file exists. Note that NUMBER becomes defined only if OPENED is true. Also,
ACCESS, FORM, RECL, NEXTREC, and BLANK become defined only if OPENED is true.
When an INQUIRE statement for a unit is executed, the inquiry specifiers NUMBER,
NAMED, NAME, ACCESS, SEQUENTIAL, DIRECT, FORM, FORMATTED,
UNFORMATTED, RECL, NEXTREC, and BLANK are assigned a value only if EXIST is true
and OPENED is true.
EXIST and OPENED always become defined unless an error condition occurs.
The following are examples of the INQUIRE statement. In the examples CHR1 and
CHR2 are character variables, NO and NXRC are integer variables and L1 and L2 are
logical variables.
BACKSPACE Statement
The executable BACKSPACE statement is an auxiliary I/O statement that allows a file
to be repositioned.
Execution of a BACKSPACE statement causes the file connected to the specified unit
to be positioned before the preceding record. If there is no preceding record, the
position of the file is not changed. Note that if the preceding record is an endfile
record, the file becomes positioned before the endfile record.
The BACKSPACE statement might not reference line printer or remote files.
BACKSPACE 10
BACKSPACE(UNIT = 8, IOSTAT=IORSLT, ERR = 89)
BACKSPACE(9, ERR = 99)
ENDFILE Statement
The executable ENDFILE statement is an auxiliary I/O statement that writes an endfile
record for tapes, or updates the LASTRECORD attribute to the current file position for
disk files.
Executing an ENDFILE statement for a tape file has the following actions: When an
ENDFILE statement follows an output statement, an endfile record is written as the
next record of the file. The file is then positioned after the endfile record. When an
ENDFILE statement follows an input statement, the tape is positioned at the start of
the next file on the tape. When an ENDFILE statement follows a REWIND statement or
another ENDFILE statement designating the same file, the ENDFILE statement is
ignored.
Executing an ENDFILE statement for a disk or pack file sets the LASTRECORD attribute
to the current record. An ENDFILE statement may be executed only if all of the
following are true:
1. The program has write ownership of the file (MYUSE = 'IO' or MYUSE = 'OUTPUT').
2. PROTECTION is not equal to 'PROTECTED'.
3. DUPLICATED and CRUNCHED are .FALSE.
4. No other logical file is currently assigned to the physical file.
No space is allocated or deallocated by use of the ENDFILE statement.
Only those records before the endfile record are considered to have been written;
only those records may be read during subsequent access of the file.
Execution of an ENDFILE statement for a file that is declared by a FILE statement, but
is not yet used (does not exist), creates the file.
ENDFILE (UNIT = 3)
ENDFILE 6
ENDFILE (4, ERR=49, IOSTAT=IORSLT)
REWIND Statement
The executable REWIND statement is an auxiliary I/O statement that allows a file to be
repositioned.
Executing a REWIND statement positions the specified file at its initial point. Note that
if the file is already positioned at its initial point, execution of this statement has no
effect on the position of the file.
Executing a REWIND statement for a file that is connected, but does not exist is
permitted, but has no effect.
REWIND (UNIT = 9)
REWIND 9
REWIND (3, ERR=39, IOSTAT=IORSLT)
FIND Statement
The FIND statement is used to position a direct access file at a specified record.
Executing a FIND statement positions the designated file before the specified record.
FILE Statement
A FILE statement declares a unit and assigns values to certain specifiers and to file
attributes for the unit. The word FILE must appear in columns 1 through 4 of the file
declaration. A minimum of two blanks must follow the word FILE so that the unit
identifier begins in at least column 7.
FILE <unit identifier> ( <file list> )
<file list>
?@ , A
B <file attribute specifier> B
C /1\ FILE = <character expression>
C /1\ STATUS = <character expression>
C /1\ ACCESS = <character expression>
C /1\ FORM = <character expression>
C /1\ RECL = <integer expression>
/1\ BLANK = <character expression>
The file attribute in a file attribute specifier may be any legal file attribute as defined in
the ClearPath Enterprise Servers I/O Subsystem Programming Reference Manual. A
full description of FILE, STATUS, ACCESS, FORM, RECL, and BLANK specifiers can be
found with the OPEN statement. In the FILE statement the expressions used for these
specifiers are restricted to logical constant expressions, character constant
expressions, integer constant expressions, or whatever is the appropriate constant
expression for the specifier.
Specifier Description
FILE statements may be used either at the very beginning of a program or between
program units. They may also appear as the first statements in a BLOCK GLOBALS
subprogram. Except for BLOCK GLOBALS subprograms, file statements may not
appear within any program unit, including the main program. Thus, they must be used:
A given file statement applies to the entire program unless the compiler option
SEPARATE is set. If SEPARATE is true, the file statement applies only to all program
units appearing after it. If a file number corresponding to the unit identifier in a given
file statement has been referenced earlier in the program as a compile time constant
unit identifier, an error message is issued. The error occurs because the first use of
such a file number constitutes an implicit declaration of the file. It is, however, legal to
specify a file unit identifier with a NONCONSTANT expression at a program location
before the file statement that declares that file. In such a case, if SEPARATE is not set,
the unit is associated at run time with the explicitly declared file, regardless of the fact
that the file's declaration comes below its use.
Also note that when a non-constant file unit identifier is used in the program, files 5, 6,
and 7 become implicitly defined if they have not already been used or declared. These
files may not be redefined with a file statement later in the source code.
FORMAT Statement
The form of a FORMAT statement is the following:
<format specification>
[r]ed
ned
[r]fs
where:
The comma used to separate the items of the format specification may be omitted
before or after a slash, before or after a colon edit descriptor, or between a P edit
descriptor and an immediately following F, E, D, or G edit descriptor.
3957 6053003 91
Format Specifications
Format control is initiated at the beginning of a formatted I/O statement. Each action
of format control depends jointly on the next edit descriptor of the current format
specification and the next item in the I/O list, if one exists.
If an input/output list specifies at least one list item, at least one repeatable edit
descriptor must exist in the format specification. Note that an empty format
specification of the form ( ) may be used only if no list items are specified. In this case,
one input record is skipped or one blank line is written. Except for an edit descriptor
preceded by a repeat specification, r ed, or a format specification preceded by a
repeat specification, r(flist), a format specification is interpreted from left to right. A
format specification or edit descriptor preceded by a repeat specification r is
processed as a list of r format specifications or edit descriptors. Note that an omitted
repeat specification is treated in the same manner as a repeat specification whose
value is 1.
Carriage Control
Any record that is to be output to a line printer or remote file must contain a
prescribed carriage control character in its first character position. This character is not
output, but is interpreted as follows:
92 3957 6053003
Format Specifications
All carriage spacing indicated by the carriage control character is performed prior to
output of the line.
Edit Descriptors
Edit descriptors are used to specify the form of a record and to direct the editing
between the characters in a record and the external representation of data.
I Integer Editing
J Integer Editing
F Real/Double Precision, Complex Editing
E Real/Double Precision, Complex Editing
D Real/Double Precision, Complex Editing
G Real/Double Precision, Integer, Logical, Complex Editing
O Octal Editing
L Logical Editing
A Character Editing
Z Hexadecimal Editing
Quote
Apostrophe
Hollerith
X Positional Editing
3957 6053003 93
Format Specifications
P Scale Factor
K Optional Commas
$ Optional $
In the following description, a field is a part of a record that is read on input or written
on output when format control processes an I, J, E, F, D, G, O, L, A, H, apostrophe, or
quote edit descriptor. The field width is the size in characters of the field.
The apostrophe and quote edit descriptors are not allowed on input.
H Editing
The form of the H edit descriptor is the following:
nHh1h2h3...hn
where:
94 3957 6053003
Format Specifications
On output, the H edit descriptor causes character information to be written from the n
characters (including blanks) following the H of the edit descriptor.
Note that if an H edit descriptor occurs within a character constant and includes an
apostrophe, the apostrophe must be represented by two consecutive apostrophes,
which are counted as one character in specifying the number of characters of the H
edit descriptor.
Positional Editing
The T, TL, TR, and X edit descriptors specify the position at which the next character
will be transferred to or from the record. These descriptors do not cause characters to
be transmitted. If characters are transmitted to positions at or after the position
specified by these edit descriptors, positions skipped remain unchanged. On output,
characters already filled may be replaced using positional editing. If a positional edit
descriptor specifies a position beyond the end of the current record, no error occurs;
however, if data transfer is attempted to or from such a position, a record overflow
error occurs.
Tc
TLc
TRc
The Tc edit descriptor indicates that the transmission of the next character to or from
a record is to occur at the cth character position. Note that for printed output the first
print position is used for carriage control; therefore, character position c is actually
print position c-1.
The TLc edit descriptor indicates that the transmission of the next character to or from
the record is to occur at the character position c characters backward from the current
position. However, if the current position is less than or equal to position c, the TLc
edit descriptor indicates that the transmission of the next character to or from the
record is to occur at position 1 of the current record.
3957 6053003 95
Format Specifications
The TRc edit descriptor indicates that the transmission of the next character to or
from the record is to occur at the character position c characters forward from the
current position.
X Editing
The form for the X edit descriptor is as follows:
[n]X
If n is omitted, 1 is implied. The X edit descriptor indicates that the transmission of the
next character to or from a record is to occur at the position n characters forward
from the current position.
Input: ABCDEFGHIJKLMN
Output: HIJKLM DEFGHI GHIJKL
Slash Editing
The slash edit descriptor indicates the end of data transfer on the current record.
On input from a file connected for sequential access, the remaining portion of the
current record is skipped and the file is positioned at the beginning of the next record.
This record becomes the current record. Note that an entire record may be skipped on
input. For a file connected for direct access, the record number is increased by one,
and the file is positioned at the beginning of the record that has that record number.
This record becomes the current record.
On output, if the file is an internal file or a file connected for direct access, the record
is filled with blank characters. On output to a file connected for sequential access, a
new record is created and becomes the last and current record of the file. Note also
that a record of all blank characters may be written on output.
Colon Editing
The colon edit descriptor terminates format control if there are no more items in the
input/output list. It has no effect if there are more items in the list.
96 3957 6053003
Format Specifications
These descriptors affect only I, J, E, F, D, and G editing on output. They have no effect
during the execution of an input statement.
P Editing
The P edit descriptor specifies a scale factor to be used for scaling numbers that are
input and output using F, E, D, and G edit descriptors.
kP
where
The value of the scale factor is zero at the beginning of execution of each I/O
statement. Once encountered, a scale factor applies to all subsequently interpreted F,
E, D, and G edit descriptors until another scale factor is encountered.
3957 6053003 97
Format Specifications
1. On input, with F, E, D, and G editing, the scale factor has no effect if there is an
exponent part in the input field.
2. On input, with E, D, G and F editing, the effect of the scale factor is as follows:
external quantity=internal value*(10**k)
3. On output, with E and D editing, the scale factor does not affect the external
value. It affects the positioning of the decimal point in the output field. The real
constant part of the output value is multiplied by 10**k and the exponent is
reduced by k.
4. On output, with G editing, the scale factor is suspended if F editing is to be used.
If E editing is to be used, the scale factor has the same effect as it does with E
editing.
5. On output F editing the effect of the scale factor is as follows:
external quantity=internal value*(10**k)
The following are examples of the scale factor usage:
BN and BZ Editing
The BN and BZ edit descriptors may be used to specify the interpretation of blanks,
other than leading blanks, in numeric input fields. At the beginning of execution of
each formatted input statement, such blank characters are interpreted as zeros or are
ignored, depending on the value of the BLANK= specifier currently in effect for the
unit. The BN and BZ edit descriptors override the BLANK file attribute. If a BN edit
descriptor is encountered in a format specification, all such blank characters in
succeeding numeric input fields are ignored. The effect of ignoring blanks is to treat
the input field as if blanks had been removed, the remaining portion of the field
right-justified, and the blanks replaced as leading blanks. However, a field of all blanks
has the value zero. If a BZ edit descriptor is encountered in a format specification, all
such blank characters in succeeding numeric input fields are treated as zeros.
98 3957 6053003
Format Specifications
The BN and BZ edit descriptors affect only I, F, E, D, and G editing during execution of
an input statement. They have no effect during execution of an output statement.
Numeric Editing
The I, J, F, E, D, and G edit descriptors are used to specify input/output of integer,
real, double precision, and complex data. The following general rules apply:
1. On input, leading blanks are not significant. The interpretation of blanks, other than
leading blanks, is determined by a combination of any BLANK= specifier and any
BN or BZ blank control that is currently in effect for the unit. Plus signs may be
omitted. A field of all blanks is considered to be zero.
2. On input, with F, E, D, and G editing, a decimal point appearing in the input field
overrides the portion of an edit descriptor that specifies the decimal point location.
3. On output, positive or zero internal values may be prefixed with a plus sign, as
controlled by the S, SP, and SS edit descriptors. The representation of a negative
internal value in the field is prefixed with a minus sign.
4. On output, the representation of numeric data is right-justified in the field. If the
number of characters produced by the editing is smaller than the field width,
leading blanks are inserted in the field.
5. On output, if the number of characters produced exceeds the field width or if an
exponent exceeds its specified length using the Ew.dEe or Gw.dEe edit descriptor,
asterisks are placed in the entire field width.
Complex data, because it consists of a pair of real values, requires two successive F,
E, D, or G edit descriptors. The first of the edit descriptors specifies the real part; the
second specifies the imaginary part. The two edit descriptors may be different. Note
that non-repeatable edit descriptors may appear between the two successive F, E, D,
or G edit descriptors.
I Editing
The I edit descriptor is used for editing integer data.
Iw
Iw.m
where:
3957 6053003 99
Format Specifications
The output field for the Iw edit descriptor consists of zero or more leading blanks
followed by a minus if the value of the internal data is negative, or an optional plus,
followed by the magnitude of the internal value in the form of an unsigned integer
constant without leading zeros. Note that an integer constant always consists of at
least one digit. I format allows floating-point data for output, but not for input. It
rounds a floating-point number before printing.
The output field for the Iw.m edit descriptor is the same as for the Iw edit descriptor,
except that the unsigned integer constant consists of at least m digits and, if
necessary, has leading zeros. The value of m must not exceed the value of w. If m is
zero and the value of the internal data is zero, the output field consists of only blank
characters, regardless of the sign control in effect.
J Editing
The J edit descriptor is specified for editing integer data. The form for the J edit
descriptor is the following:
Jw
where
On input, the J edit descriptor behaves exactly like the Iw format specification.
On output, the Jw format specification writes the value of the corresponding I/O list
element to be printed as an integer constant in the minimum field necessary to
contain the value without exceeding the field width w. The plus sign is not printed for
non-negative quantities. If the value to be printed requires more than w characters, w
asterisks are output. Floating-point values are rounded to an integer value before
being output.
Examples
F Editing
The F edit descriptor is specified for editing integer, real, double precision, and
complex data.
Fw.d
where
On input, the input field should consist of an optional sign, followed by a string of
digits optionally containing a decimal point. If the decimal point is omitted, the
right-most d digits of the string, with leading zeros assumed if necessary, are
interpreted as the fractional part of the value represented. The basic form may be
followed by an exponent of one of the following forms:
On output, the field consists of blanks, if necessary, followed by a minus if the internal
value is negative, or an optional plus, followed by a string of digits that contains a
decimal point and represents the magnitude of the internal value, as modified by the
established scale factor and rounded to d fractional digits. Leading zeros are not
permitted, except for an optional zero immediately to the left of the decimal point if
the magnitude of the value in the output field is less than one. The optional zero must
appear if there would otherwise be no digits in the output field.
Examples
E and D Editing
The E and D edit descriptors are specified for editing integer, real, double precision,
and complex type data.
Ew.d
Ew.dEe
Dw.d
where:
On input, the field should consist of an optional sign followed by a string of digits
optionally containing a decimal point and exponent. If the decimal point is omitted, a
decimal point is implied d places to the left of the E or D denoting the exponent, or if
there is no exponent, d places from the right edge of the input field.
The form of the output field for a scale factor of zero is as follows:
where
where
z is a digit
s is the required sign of the exponent
A plus sign must be used if the exponent value is zero. The forms Ew.d and Dw.d
must not be used if exp > 999.
The scale factor k controls the decimal normalization. If -d < k < 0, the
output field contains exactly |k| leading zeros and d - |k| significant digits
after the decimal point. If 0 < k < d + 2, the output field contains exactly
k significant digits to the left of the decimal point and d - k + 1 significant
digits to the right of the decimal point. Other values of k are not
permitted.
G Editing
The G edit descriptor may be used with list items of type integer, logical, real,
complex, and double precision.
Gw.d
Gw.dEe
where
When the Gw.d edit descriptor is used with a list item of type integer, the data is
edited with an Iw edit descriptor.
When the Gw.d edit descriptor is used with a list item of type logical, the data is
edited with an Lw edit descriptor.
G input editing of real and double precision list items is the same as for F editing of
these list items.
For output, the method of representation depends on the magnitude of the data being
edited. If v is the absolute value of the list item, then for v<.1 or v>10**d, E editing is
used. Otherwise, for k = 0, 1, 2,...d, if 10 **(d-k- 1)<v<10**(d-k), then the format
F(w-n).k,nX is used. In the preceding format n is 4 for Gw.d editing, and n is e+2 for
Gw.dEe. editing.
O Editing
The O edit descriptor is used with I/O list items of any type, except character. On
input, the list item becomes defined with an octal value. On output, the list item is
output as a string of octal digits.
Ow
where
The input field is interpreted as w octal digits. Leading, trailing, and embedded blanks
are interpreted as zeros. A minus sign (-) causes bit 46 of the storage word allocated
to the variable to be complemented. If the list item is less than 16 octal digits long, it is
stored right-justified with zero fill in the storage word. If the list element is double
precision, and the input data is more than 16 digits, the first 16 digits are stored with
zero fill in the second word. If the field width on input is greater than the 16 or 32
digits that can be stored in a single or double precision word respectively, the
right-most 16 or 32 digits are taken from the field.
On output, if the field width specified is greater than 16 (32 for double precision), the
16 (or 32) digits are output right-justified within the field. If the field width is less than
the internal representation, the right-most octal digits are transferred to fill the field
width.
Examples:
L Editing
The L edit descriptor is specified to edit logical type data.
Lw
where
On input, the list item is defined with a logical value. The field should consist of
optional blanks, optionally followed by a decimal point, followed by a T for true or F for
false. The T or F may be followed by additional characters in the field. Note that the
logical constants .TRUE. and .FALSE. are acceptable input forms.
Examples of L editing:
Edit Descriptor Internal Input/Output Field
Value
columns 123
INPUT L1 .TRUE. T
L3 .FALSE. .F
OUTPUT L1 .FALSE. F
L3 .FALSE. F
L2 .TRUE. T
A Editing
The A edit descriptor is used with input/output list items of type character or Hollerith.
On input, the list item becomes defined with character data. On output, the list item
must be defined with character data.
A[w]
where
If the field width is not specified with the edit descriptor, the number of characters in
the field is equal to the length of the character data. Input and output list items for
which a field width is unspecified must be of type character.
Integer data may contain a maximum of four Hollerith characters, logical and real data
may contain a maximum of six characters, and double precision data may contain up
to twelve characters. The Hollerith data is stored left-justified in the word, padded
with blanks on the right if necessary. When Hollerith data is stored in an integer, only
the lower 32 bits are used, with the high order 16 bits filled with zeros.
On input, the A edit descriptor transfers w characters from the input device to the
corresponding list element. Let <len> be the length of the character list item. If the
field width <w> is greater than or equal to <len>, the right- most <len> characters are
read. If <w> is less than <len>, <w> characters are stored left-justified with <len>-
<w> trailing blanks in the list item.
On output, the A edit descriptor transfers <w> characters from the list item to the
output device. Again, let <len> be the length of the list item. If the field width <w> is
greater than <len>, the output field has <w>- <len> blanks followed by <len>
characters. If <w> is less than or equal to <len>, the output field contains the
left-most <w> characters of the list item.
Input: ABCD
Output: 0000C1C2C3C4 ABCD
Z Editing
The Z edit descriptor is used with I/O list items of any type. On input, the list item
becomes defined with a hexadecimal value. On output, the list item is output as a
string of hexadecimal digits.
Zw
where
The input field is interpreted as w hexadecimal digits. Leading, trailing, and embedded
blanks are interpreted as zeros. If the list element is single precision and the input data
is less than 12 hexadecimal digits long, it is stored right-justified with zero fill in the
storage word. If the list element is double precision, and the input data is 12 or fewer
digits, it is stored right-justified with zero fill in the first word, and zeros are stored in
the second word. If the input data is more than 12 digits, the first 12 digits are stored
into the first word and the remaining digits are stored right-justified with zero fill in the
second word. If the field width on input is greater than the 12 or 24 digits that can be
stored in a single or double precision word respectively, the right-most 12 or 24 digits
are taken from the field. A minus sign causes bit 46 to be complemented.
On output, if the field width specified is greater than 12 (24 for double precision) the 12
(or 24) digits are output right-justified with blank fill within the field. If the field width is
less than the internal representation, the right-most hexadecimal digits are transferred
to fill the field width.
Example:
FILE 6(KIND=REMOTE, MYUSE=IO)
READ (6,FMT=(Z6))A
WRITE (6,FMT=(1X,Z10))A
END
Input: CDE4
Output: 0000CDE400
Examples
K Editing
The K edit descriptor causes commas to be inserted between digit triples to the left
of the decimal point.
Examples:
$ Editing
The $ edit descriptor causes the character $ to be inserted immediately to the left of
an edited item.
Examples:
A character format specification must be of the form described previously. Note that
the form begins with a left parenthesis and ends with a right parenthesis. Character
data may follow the right parenthesis that ends the format specification and blank
characters may precede the format specification with no effect on the format
specification.
If the format identifier is an array name, the length of the format specification may
exceed the length of the first element of the array; an array format specification is
considered to be a concatenation of all the elements of the array in the order given by
array element ordering.
If a character array element name is specified as a format identifier, the length of the
format specification must not exceed the length of the array element.
CHARACTER FMT1*20
DATA FMT1/(I2,F10.5,5X,I3)/
WRITE (6,FMT=FMT1)I,X,J
WRITE (6,FMT=(F5.1))Z
WRITE (6,FMT=(//FMT1(2:9)//)) I,X
List-Directed Format
The use of list-directed format (or free format) with an input/output statement allows
I/O to be performed with editing, but without requiring the user to specify a format
specification explicitly.
Each value is either a constant, a null value, or one of the following forms:
r*c
r*
The r*c form is equivalent to r successive appearances of the constant c, and the r*
form is equivalent to r successive null values. Neither of these forms may contain
embedded blanks, except where permitted within the constant c.
When the corresponding input list item is of type real or double precision, the input
form is that of a numeric input field. A numeric input field is a field suitable for F
editing, one which is assumed to have no fractional digits unless a decimal point
appears within the field.
When the corresponding list item is of type complex, the input form consists of a left
parenthesis followed by an ordered pair of numeric input fields separated by a comma
and followed by a right parenthesis. The first numeric input field is the real part of the
complex constant and the second is the imaginary part. Each of the numeric input
fields may be preceded or followed by blanks. The end of a record may occur
between the real part and the comma or between the comma and the imaginary part.
When the corresponding list item is of type logical, the input form must not include
either slashes or commas among the optional characters permitted for L editing.
When the corresponding list item is of type character, the input form consists of a
valid character constant enclosed in quotation marks or apostrophes. The character
constants may be continued from the end of one record to the beginning of the next
record and may be continued on as many records as needed. If the length of the list
item and the length of the constant are not equal, the list item is assigned the value of
the constant as though the constant were assigned the list item in a character
assignment statement.
A slash encountered in the data value list during execution of a list-directed input
statement causes termination of execution of that input statement after assignment
of the previous value. If there are additional items in the input list, they are assigned
null values.
On output, each value is edited into the appropriate format. With the exception of
character constants, the values are separated by two blanks.
New records begin as necessary, but, except for complex constants and character
constants, the end of a record does not occur within a constant, and blanks do not
occur within a constant.
Logical output constants are T for the value true and F for the value false.
Integer output constants are produced with the effect of an I edit descriptor.
Real and double precision constants are produced with the effect of either an F edit
descriptor or an E edit descriptor, depending on the magnitude of the value.
Complex constants are enclosed in parentheses, with a comma separating the real
and imaginary parts. The end of a record may occur between the comma and the
imaginary part only if the entire constant is as long as, or longer than, an entire record.
Each output record begins with a blank character to provide carriage control when the
record is printed.
LOGICAL LG(5)
CHARACTER CHAR1*04, CHAR2*02, CHAR3*03
DOUBLE PRECISION DBLE
COMPLEX CMPLX
READ(5,FMT=*)X,Y,DBLE,LG,CMPLX,CHAR1,INT1,INT2,CHAR2,CHAR3,Z
The following assignments take place as a result of the preceding READ statement
with the indicated data:
X = 5.9
Y = 6.3E10
DBLE = 367.D23
LG(1) = .TRUE.
LG(2) = .TRUE.
LG(4) = .FALSE.
LG(5) = .FALSE.
CMPLX = (1.1,1.1)
CHAR1 = ABC A value of ABC
CHAR2 = AB
CHAR3 = AB
INT1 = 22
INT2 = 22
The following is the output produced by the preceding WRITE statement assuming the
values of the variables were assigned by the preceding list- directed READ statement.
5.9 22 T FABCABC
,
NAMELIST / <namelist name> / <variable name>
! <array name> #
The NAMELIST statement follows any declarations referencing the elements of the
namelist list.
A particular simple variable or array may be associated with more than one namelist
name. For example, if A, B, and C are array names, the NAMELIST statement:
NAMELIST/NMLST1/A,G/NMLST2/A,B,A2/LIST/C,XR,S,T
The preceding statement associates the array A and the simple variable G with the
namelist name NMLST1; associates the arrays A and B, and the simple variable A2 with
the namelist name NMLST2; and associates the array C and the simple variables XR, S,
and T with the namelist name LIST.
Values may be input to internal storage locations from peripheral storage by formatted
READ statements using namelist names as format designators. When such a READ
statement is executed, the referenced file is accessed repeatedly, beginning at its
present position, until an appropriate namelist input record is found or an end-of-file
condition occurs.
Namelist Input
Namelist input records must have the following format:
Data items associated with the namelist name that do not have values assigned to
them in the namelist record retain their present values.
2. For the following form, each constant in the list of values is assigned to an
element of the array. The elements of the array are assigned in the order specified
by the element ordering beginning with the first element.
<array name> = <list of values>
3. For the following form, each constant in the list of values is assigned to an
element of the array. The elements of the array are assigned in the order specified
by the array element ordering beginning with the element specified in the value
assignment. Conversion is applied in the same manner as for arithmetic, logical,
and character assignment statements.
<array element name> = <list of values>
A variable named in the namelist list for a specific namelist name, but whose name
does not appear in a value assignment in the data group for the namelist name, retains
its current value if defined or else remains undefined. Any element of an array named
in the namelist list for a name that is not assigned a value in a value assignment in the
data group for the namelist name retains its current value if defined or else remains
undefined.
Namelist Output
When a WRITE, PRINT, or PUNCH statement specifying namelist formatting is
executed, the output, except for variables or arrays of type character, is written to the
file in a form that can be read by a READ statement specifying the same namelist
name as a format identifier. The values of all of the variables and arrays whose names
appear in the namelist list for the specified namelist are written. The values of integer,
real, double precision, complex, logical, and character variables or arrays are written as
integer, real, double precision, complex, logical, and character constants, respectively.
Fields for the data are made large enough to contain all significant digits.
2. The values of an array are written in the following form, where the list of
constants contains one constant for each element in the array, written in the order
specified by the array element ordering:
<array name> = <list of constants>
&NLIST
A =
25.500000000, 1.0000000000, 100.10000000, L = .TRUE., D =
0.15000000000000000000000D+00011, B = 150.00000000,&END
&NLIST2
A =
25.500000000, 1.0000000000, 100.10000000, CHAR =
EXAMPLE,&END
Every FORTRAN77 program must have one main program. Execution of a program
begins with the first executable statement in this program unit. Compiling a program
that does not contain a main program results in a warning message. The code file
resulting from the compilation of a source without a main program can be used as a
host file into which a main program can be separately compiled, provided that the
option MAKEHOST is SET, or bound, provided that BINDINFO is set. Also, cross
reference files can be created for a program unit that is missing a main program.
A main program is a program unit that does not have a FUNCTION, BLOCK GLOBALS,
SUBROUTINE, or BLOCK DATA statement as its first statement. It may have a
PROGRAM statement as its first statement. A main program may not contain RETURN
or ENTRY statements. The appearance of a SAVE statement in this program unit has
no effect, except to cause any variable and arrays associated with the SAVE
statement to be part of the global environment.
PROGRAM Statement
The PROGRAM statement is used to assign a symbolic name to a main program.
This is an optional statement, but when it is used, it must be the first statement of the
program unit.
The symbolic name assigned to the main program is global to the executable program.
Therefore, care must be taken that the name selected is not the same as that of an
external procedure, block data subprogram, common block, or local name in the main
program.
Functions
Functions are procedures that are usually referenced in expressions and supply a
value to the expression. The value supplied is the value of the function.
Intrinsic functions
Statement functions
External functions
A function reference is used to reference an intrinsic function, statement function, or
external function. Some intrinsic functions and statement functions can also be used
on the left side of an assignment statement instead of as an expression. Refer to
"Assignable Functions" in this section for more information.
The type of the result of a statement function or external function reference is the
same as the type of the function name. The type is specified in the same manner as
for variables and arrays. The type of the result of an intrinsic function is specified in
Table 12-1.
Intrinsic Functions
Intrinsic functions are function subprograms that are known to the compiler and need
not be supplied in the program. These functions are identified by two types of names:
specific names and generic names. An IMPLICIT statement does not change the type
of an intrinsic function. The specific names that identify the intrinsic functions, their
generic names, function definitions, and the type of results are illustrated in Table 12-1.
The order, number, and type of the actual arguments passed to the intrinsics must
agree with the specifications in the table when the specific name is used to reference
a function.
For those intrinsic functions that have more than one argument, integer and real
arguments may be intermixed.
Generic names simplify the use of intrinsic functions. The generic function name may
be used with various types of arguments. If the generic name is used, the type of the
result is the same as the type of the argument. The exceptions to this are those
functions that do type conversion, nearest integer, and absolute value with a complex
argument.
Note that such an appearance does not cause the intrinsic function to be classified as
an external function.
*The type for the data item on which the intrinsic works. Other arguments for this
intrinsic that specify bit positions and/or lengths must be of type real or integer.
3. For n of type double precision, DBLE(n) is n. For n of type integer or real, DBLE(n) is
as much precision of the significant part of n as a double precision datum can
contain. For n of type character, DBLE(n) is the double precision number that is
represented by the bit pattern of the character string (see Section 6 for more
information). For n of type complex, DBLE(n) is as much precision of the significant
part of the real part of n as a double precision datum can contain. For n of type
integer, DFLOAT(n) is the same as DBLE(n).
4. CMPLX may have one or two arguments. If there is one argument, it may be of
type integer, real, character, double precision, or complex. If there are two
arguments, they may be of type integer, real or double precision. For n of type
complex, CMPLX(n) is n. For n of type integer, real, or double precision, CMPLX(n)
is the complex value whose real part is REAL(n) and whose imaginary part is zero.
For n of type character, CMPLX(n) is the complex number that is represented by
the bit pattern of the character string. (See Section 6 for more information.)
CMPLX(n1,n2) is the complex value whose real part is REAL(n1) and whose
imaginary part is REAL(n2). For n, n1, and n2 of type double precision, DCMPLX(n)
and DCMPLX(n1,n2) are the same as CMPLX(n) and CMPLX(n1,n2) respectively.
5. ICHAR provides a means of converting from a character to an integer based on the
position of the character in the collating sequence. The first character in the
collating sequence corresponds to position 0 and the last to position n-1, where n
is the number of characters in the collating sequence. The value of ICHAR(n) is an
integer in the range:0 <= ICHAR(N) <= n-1, where n is an argument of type
character of length 1. The value of n must be in the collating sequence. The
position of that character in the collating sequence is the value of ICHAR. For any
characters c1 and c2 capable of representation in the processor, (c1 .LE. c2) is true
if and only if (ICHAR(c1) .LE. ICHAR(c2)) is true, and (c1 .EQ. c2) is true if and only if
(ICHAR(c1) .EQ. ICHAR(c2)) is true. CHAR(i) returns the character in the ith position
of the processor collating sequence. The value is of type character of length 1. i
must be an integer expression whose value must be in the range 0 <= i <= n-1.
ICHAR(CHAR(i)) = i for 0 <= i <= n-1.
CHAR(ICHAR(c)) = c for any character in the collating sequence.
6. A complex value is expressed as an ordered pair of reals, (Nr,Ni), where Nr is the
real part and Ni is the imaginary part.
7. All angles are expressed in radians.
8. The result of a function of type complex is the principal value.
9. All arguments in an intrinsic function reference must be of the same type, except
for the bit manipulation intrinsics. As a Unisys extension for intrinsics requiring
more than one argument, integer and real arguments may be intermixed.
10. INDEX(n1,n2) returns an integer value indicating the starting position within the
character string n1 of a substring identical to string n2. If n2 occurs more than
once in n1, the starting position of the first occurrence is returned. If n2 does not
occur in n1, the value zero is returned. Note that zero is returned if LEN(n1) <
LEN(n2).
11. The value of the argument of the LEN function need not be defined at the time the
function is referenced.
12. LGE(n1,n2) returns the value true if n1=n2 or if n1 follows n2 in the collating
sequence described in American National Standard Code for Information
Interchange, ANSI X3.4-1977 (ASCII) and otherwise returns the value false.
LGT(n1,n2)) returns the value true if n1 follows n2 in the collating sequence
described in ANSI X3.4-1977 (ASCII) and otherwise returns the value false.
LLE(n1,n2) returns the value true if n1=n2 or if n1 precedes n2 in the collating
sequence described in ANSI X3.4-1977 (ASCII) and otherwise returns the value
false.
LLT(n1,n2) returns the value true if n1 precedes n2 in the collating sequence
described in ANSI X3.4-1977 (ASCII), and otherwise returns the value false.
If the operands for LGE, LGT, LLE, and LLT are of unequal length, the shorter
operand is considered as if it were extended on the right with blanks to the length
of the longer operand.
13. The TIME intrinsic takes one argument and returns a system time value. The
argument can be a character constant or an arithmetic expression of type real or
integer. If a character constant argument is used, the time value is returned as a
real number expressed in units of seconds as follows:
When used with a real or integer argument, the TIME intrinsic returns a system
time value as specified in the table under the following note for CTIME. Note that
the TIME intrinsic returns a system time value at run time.
14. The CTIME intrinsic takes one argument and returns a system time value at
compile time. The compiler actually replaces the CTIME intrinsic reference by the
returned system time value during the compilation of the program. The argument
of this intrinsic must be a constant expression of type real or integer. When
rounded to the nearest integer, the value of the argument determines the
returned system time value as indicated in the following table. Argument values
not listed in the table cause the intrinsic to return an undefined value. Be cautious
when assigning certain system time values to integers (I = CTIME(6), for example),
since conversion to integer could result in an integer overflow fault or cause
corruption of the returned result.
Argument Returned
Result
1 Returns an integer value that is the time of day expressed
in units of sixtieths of a second.
2 Returns an integer value that is the elapsed processor time
of the executing program in units of sixtieths of a second.
Note that for CTIME the executing program is the compiler
and hence, the elapsed processor time for the compilation
is returned.
3 Returns an integer value that is the elapsed I/O time of the
executing program in units of sixtieths of a second.
4 Returns an integer value of a 6-bit clock that increments
every sixtieth of a second.
6 Returns a real number for the date and time that may be
interpreted as follows:
T = CTIME (6)
DATE = ISOL (T,47,16) + 70000
TTIME = ISOL (T,31,32) * 16
Argument Returned
Result
9 Returns the current time as a real value containing six
EBCDIC characters in the format HHMMSS where H
(hours), M (minutes), and S (seconds) represent an EBCDIC
character from '0' through '9'. The CHARS intrinsic can be
used to extract the desired time information. For example:
CHARACTER TIMEX*6, HRS*2, MIN*2, SEC*2
TIMEX = CHARS(CTIME(9))
HRS = TIMEX(1:2) % ASSIGN HOURS
MIN = TIMEX(3:4) % ASSIGN MINUTES
SEC = TIMEX(5:6) % ASSIGN SECONDS
Argument Returned
Result
24 Returns the system type as a real value containing six
EBCDIC characters. The name is left-justified with blank fill.
For example, on an A17 system, a real containing 'A17 ' is
returned.
27 Returns the count of initial presence bit actions for the
calling task.
28 Returns the total time spent processing initial presence bit
actions for this task in units of 2.4 microseconds.
29 Returns the count of other presence bit bit actions for the
calling task.
30 Returns the total time spent processing other presence bit
actions for this task in units of 2.4 microseconds.
31 Returns a real number that contains the running MCP
version information in the following format:
[47:16] current release number
[31:16] current cycle number
[15:16] current patch number
15. DATE(c) returns an EBCDIC character string of length 6 that represents the current
date at run time. The character constant argument c determines which date is
returned as indicated in the following table. M (month), D (day), and Y (year) (for
the date results) and H (hours), M (minutes), and S (seconds) (for the time result)
each represent an EBCDIC character from '0' through '9'.
17. The intrinsic functions AND and IAND return the full word logical product of all
data bits of the first argument with corresponding data bits of the second
argument.
18. The intrinsic functions COMPL and NOT return the full word logical complement of
all data bits of its argument.
19. The intrinsic function EQUIV returns the full word logical equivalence of all data
bits of the first argument with corresponding data bits of the second argument.
The bit pattern returned has 1 for each bit position in which the arguments agree,
and 0 where they are different. When both arguments are of type integer, the
exponent bits [45:07] are then set to 0.
20. The intrinsic functions OR and IOR return the full word logical sum of all data bits
of the first argument with corresponding data bits of the second argument.
21. A reference to the VALUE intrinsic returns a numeric value corresponding to a file
attribute mnemonic. The value intrinsic requires one argument, which is a valid file
attribute mnemonic. For a list of these mnemonics, refer to the ClearPath
Enterprise Servers Input/Output Subsystem Programming Reference Manual.
The compiler replaces the VALUE reference by the numeric value of the
mnemonic.
Examples:
INQUIRE (37, KIND=DEVICE, EXTMODE=XMODE)
22. The CONCAT intrinsic is provided to allow partial word manipulation. This intrinsic
takes five actual arguments. The first two of these arguments must be integer or
real variables. The last three arguments must be non-negative arithmetic
expressions. Thus, a typical CONCAT reference has the form: CONCAT(A, B, I, J,
K). The rounded values of I and J must be less than 48; the rounded value of K
must be less than or equal to 48.
The value returned from the intrinsic reference is equal to the word A with field
[I:K] replaced by field [J:K] from word B. Neither A nor B is changed by the
reference to CONCAT.
The following is an example of a program unit referencing the CONCAT intrinsic.
The value returned when UNITE is referenced is a word construction from P1 and
P2 in such a manner that the left-most 24 bits of P1 and the left-most 24 bits of P2
are placed into the word in that order.
It is more efficient to use the AND and OR intrinsics whenever possible, instead of
the CONCAT intrinsic.
23. Remaindering: A divide-by-zero fault occurs for MOD, AMOD, and DMOD when
the value of the second argument is 0.
24. Transfer of Sign: If the value of the first argument of ISIGN, SIGN, or DSIGN is 0,
the result is 0, which is neither positive nor negative.
25. Square Root: The value of the argument of SQRT and DSQRT must be greater than
or equal to 0. The result of CSQRT and CDSQRT is the principal value with the real
part greater than or equal to 0. When the real part of the result is 0, the imaginary
part is greater than or equal to 0.
26. Logarithms: The value of the argument of ALOG, DLOG, ALOG10, and DLOG10
must be greater than 0. The value of the argument of CLOG and CDLOG must not
be (0.,0.). The range of the imaginary part of the result of CLOG is: -PI< imaginary
part <= PI. The imaginary part of the result is PI only when the real part of the
argument is less than 0 and the imaginary part of the argument is 0.
27. Sine, Cosine, and Tangent: The absolute value of the argument of SIN, DSIN, COS,
DCOS, TAN, and DTAN is not required to be less than 2*PI.
28. Arcsine: The absolute value of the argument of ASIN, ARSIN, DASIN, and DARSIN
must be less than or equal to 1. The range of the result is: -PI/2 <= result <= PI/2.
29. Arccosine: The absolute value of the argument of ACOS, ARCOS, DACOS, and
DARCOS must be less than or equal to 1. The range of the result is: 0 <= result <=
PI.
30. Arctangent: The range of the result for ATAN and DATAN is: -PI/2 <= result <=
PI/2. If the value of the first argument of ATAN2 or DATAN2 is positive, the result
is positive. If the value of the first argument is 0, the result is 0 if the second
argument is positive, and PI if the second argument is negative. If the value of the
first argument is negative, the result is negative. If the value of the second
argument is 0, the absolute value of the result is PI/2. The arguments must not
both have the value 0.
31. The three arguments for ISOL (S, SB, LEN) are:
S: a real, integer, or logical expression representing the source of
the bit string to be isolated.
SB: an integer or real expression in the range 0-47. SB represents the
left-most bit in S that is to be isolated. Bits are numbered left to
right 47-0.
LEN: an integer or real expression indicating the number of bits to be
isolated. LEN must be in the range 0-48.
If there are insufficient bits to the right of SB to satisfy LEN, additional bits are
obtained starting at bit 47 and working toward SB. This has the effect of rotating
the bits in the word S.
For example: ISOL(A,10,12) would return a result consisting of the lowest 11 bits
and the highest bit of A, arranged as follows:
If the bits in A are:
47!...!10!9!8!7!6!5!4!3!2!1!0
I=SKIP( READY, )
returns the value 4 since there are three spaces before the 'R'.
34. The intrinsic functions EOR and IEOR return the exclusive OR of all data bits of the
first argument with corresponding data bits of the second argument.
35. The intrinsic function SHFT(n1,n2) returns the value of the first argument logically
shifted n2 places. If n2 > 0, the shift is to the left. If n2 < 0, the shift is to the right.
Bits shifted out one end are lost and zeros are shifted in the other end. The
second argument must be an integer or real expression.
36. The intrinsic function ISHFT is identical to SHFT, except that the shift is only
performed on the right-most 32 bits of the first argument. That is, the left-most 16
bits are not affected. Within the 32 bits, any bits shifted out one end are lost and
zeros are shifted in the other end.
37. The intrinsic functions SHFTC(n1,n2,n3) and ISHFTC(n1,n2,n3) return the value of the
first argument with its n3 right-most bits circularly shifted n2 places. Other bits in
the word are unaffected. If n2 > 0, the shift is to the left. If n2 < 0, the shift is to
the right. The shift is circular; bits shifted out one end are shifted back in at the
other end. n2 and n3 must be integer or real expressions with 1 <= n3 <= 48.
38. The intrinsic functions BSET and IBSET return the value of the first argument with
its nth bit set where n is the value of the second argument. The second argument
must be an integer or real expression that evaluates to a value between 0 and 47
inclusive.
39. The intrinsic functions BCLR and IBCLR return the value of the first argument with
its nth bit cleared where n is the value of the second argument. The second
argument must be an integer or real expression that evaluates to a value between
0 and 47 inclusive.
40. The intrinsic function BTEST examines the nth bit of the first argument where n is
the value of the second argument. .TRUE. is returned if this bit is on (set to 1) and
.FALSE. is returned if this bit is off. The second argument must be an integer or
real expression that evaluates to a value between 0 and 47 inclusive.
41. The intrinsic functions BITS(n1,n2,n3) and IBITS(n1,n2,n3) return bits n2 through
n2+n3-1 of the first argument n1. The value returned contains these bits right-
justified with zero fill on the left. n2 is the second argument and specifies the
starting bit position. n3 is the third argument and specifies the number of bits to
extract. Unlike ISOL, the bit extraction goes from right to left. n2 and n3 must be
integers or reals with 0 <= n2 <= 47 and 1 <= n3 <= 48. (n2+n3-1) must not be
greater than 47. For example, BITS (X,36,8) returns bits 36 to 43 of X.
The BITS and IBITS functions may also be used on the left side of an assignment
statement if argument n1 is a real, integer, or logical variable or array element.
Refer to "Assignable Functions" in this section.
The range checks on n2 and n3 are done at compile-time and run-time if
necessary. If both n2 and n3 are constant expressions, slightly better code is
generated.
Note: Bit fields for BITS and IBITS are specified differently from usual A
Series conventions. Bits are numbered right to left from 0 to 47 as usual, but the
bit extraction goes from right to left (instead of the familiar left to right). That
is, a bit field contains the bits from the starting bit up to bit position (start +
length -1). For example, BITS (X,20,8) specifies bits 20 through 27.
To choose between IBITS and ISOL functions, which both perform bit field
isolation, consider that IBITS is specified in MIL-STD-1753 and is therefore more
likely to be found in other FORTRAN implementations, but ISOL generates better
code on ClearPath Enterprise Servers for non-constant bit fields.
42. The intrinsic functions UPPERCASE and UPPERC return a string identical to the
argument, except that all lowercase characters have been replaced by the
corresponding uppercase characters.
43. The intrinsic functions LOWERCASE and LOWERC return a string identical to the
argument, except that all uppercase characters have been replaced by
corresponding lowercase characters.
44. The intrinsic functions LEN_TRIM and TRMLEN return the length of the argument
string with the trailing blanks removed. If the argument contains only blank
characters, zero is returned.
45. The intrinsic function TRIM returns a string identical to the argument, except that
all trailing blanks have been removed. If the argument contains only blank
characters, an error is reported.
46. The intrinsic function ADJUSTL returns a string identical to the argument, except
that all leading blanks have been deleted and replaced with the same number of
trailing blanks.
47. The intrinsic function ADJUSTR returns a string identical to the argument, except
that all trailing blanks have been deleted and replaced with the same number of
leading blanks.
Statement Functions
A statement function is a procedure that is defined in a single statement similar to an
assignment statement. The statement function may be referenced only within the
program unit in which it is defined.
The relationship between the function name and the expression must conform to the
assignment rules for arithmetic, logical, and character assignment statements. Note
that the type of the expression may be different from the type of the statement
function.
The name of a statement function is a local name and must not be the same as the
name of any other entity in the program unit, except the name of a common block.
A statement function definition must appear after the specification statements and
before the first executable statement of a program unit. This is a non- executable
statement.
The type of value returned when a statement function is referenced depends upon
the type associated with the function name. A default type is associated with this
name in the same manner as for a variable. This default type may be changed by the
appearance of the function name in a TYPE statement or by the implicit typing of the
name in an IMPLICIT statement in the same program unit.
The statement function dummy argument list serves only to indicate order, number of
dimensions, and type of arguments for the statement function. The variable and array
names that appear as dummy arguments have a scope of only that statement. A given
symbolic name may appear only once in any statement function dummy argument list.
An external function reference in the expression that defines the statement function
may not redefine dummy arguments.
The expression for defining the statement function may contain constants, symbolic
names of constants, variables or array element references, or function references. If a
statement function is referenced in the definition, it must appear in preceding lines of
the program unit.
If a statement function dummy argument name is the same as the name of another
entity, the appearance of that name in the expression of a statement function
statement is a reference to the statement function dummy argument. A dummy
argument that appears in a FUNCTION or SUBROUTINE statement may be referenced
in the expression of the statement function statement within the subprogram. A
dummy argument that appears in an ENTRY statement that precedes a statement
function statement may be referenced in the expression of the statement function
within the subprogram.
LOGICAL COMP
REAL ARRAY (4,5)
COMP(A) = A.LT.7.5 .OR. A.GT.10.6
ZTOTAL(A,B,C) = A + 2*B + 3*C
YFUNC(X) = X/3.6 + TOT
ZFUNC(X) = YFUNC(X) + X**02
ARYFUN (X, ARRAY, I) = ZFUNC(X) + ARRAY(1,I)
Assignable Functions
Assignable Intrinsic Functions
The BITS (also known as IBITS) and ISOL intrinsic functions may be used on the left
side of an assignment statement if the first parameter is a variable or array element.
The expression on the the right side of the assignment statement must be of type
real, integer, or logical.
Examples:
DIMENSION C(5)
A = BITS (B,0,3) % OK
BITS (B,0,3) = A % OK
BITS (B+1,0,3) = A % SYNTAX ERROR
BITS (C(A+1),D,E) = 5 % OK
BITS (SIN(A),D,E) = 5 % SYNTAX ERROR
The effect of an assignment to the ISOL or BITS function is that the expression on the
right side of the assignment is put into a bit field of the first argument. The bit field is
specified by the second and third arguments and is the same as described currently
for ISOL and BITS. Unlike when the functions are used as expressions, only the field
specified is affected (there is no zero fill); the other bits of the first argument are not
changed. Only the lowest bits of the expression are on the right side of the
assignment are used. In other words, "BITS (A,B,C) = <expr>" is the same as "BITS
(A,B,C) = BITS (<expr>,0,C)".
"BITS (A,B,C) = D" performs the same function as the intrinsic subroutine call "CALL
MVBITS (D,0,C,A,B)"; "ISOL (A,B,C) = D" performs the same function as the intrinsic
subroutine call "CALL MVBITS (D,0,C,A,B-C+1)". BITS and ISOL are more efficient than
MVBITS, but MVBITS is more versatile (MVBITS allows the specification of the source
field).
1. The statement function is not analyzed for the <expression> syntax at the time of
the declaration. If a syntax error exists, it is reported at each reference to the
<function name>.
2. Either or both the declaration or reference of the statement function may or may
not conform to ANSI requirements.
3. The types of the <variable names> used as dummy arguments are not significant.
There is no type checking at declaration time.
4. The <variable names> are purely dummy arguments; they do not have to be
variables at all, they can be any legal <symbolic name>. Conversely, the use of a
name as a dummy argument does not affect the use of the name outside of the
statement function.
5. A reference to a defined statement function results in a text substitution using
actual arguments (if any). One consequence of this is that the same statement
function may referenced with many different types of arguments and still evaluate
to a correct <expression>.
6. A statement function reference may be used on the left side of an assignment
statement as long as the reference results in an assignable entity (variable, array
element, assignable intrinsic function, or other assignable statement function).
This is a more relaxed requirement than for non-defined statement functions.
7. When used as an expression, the type returned by a defined statement function
reference is the type of the name of the defined statement function. A type
conversion is performed as necessary between the type of the expression
resulting from text substitution and the type of the defined statement function
name as per normal FORTRAN77 typing rules.
DBL (A) = B
INTGR (ARY,3) = 1.2
B = DBL (A)
B = INTGR (ARY,3)
External Functions
An external function is a procedure that is specified external to the program unit that
references external functions it. It is specified in a function subprogram.
<type>
The name of an external function is a global name and must not be the same as any
other global name or any local name, except a variable name, in the function
subprogram.
The name of the function subprogram must appear as a variable name in the
subprogram. During every execution of the external function, this variable must
become defined, and once defined, may be referenced or become redefined. The
value of this variable when a RETURN or END statement is executed in the
subprogram is the value of the function. If this variable is a character variable with a
length specification of an asterisk in parentheses, (*), it must not appear as an operand
for concatenation, except in a character assignment statement. In addition to returning
the value of the function, an external function may define dummy arguments to return
values.
In a function subprogram, the name of a dummy argument is local to the program unit
and must not appear in an EQUIVALENCE, PARAMETER, SAVE, INTRINSIC, DATA, or
COMMON statement, except as a common block name. A character dummy
argument, whose length specification is an asterisk in parentheses, (*), must not
appear as an operand for concatenation, except in a character assignment statement.
The actual arguments in an external function reference must agree in order, number,
and type with the corresponding dummy arguments in the referenced function. The
use of a subroutine name as an actual argument is an exception to the rule requiring
agreement of type.
The actual arguments in the reference of an external function may be an array name,
an intrinsic function name, an external procedure name, a dummy procedure name, or
any expression, except a character expression involving concatenation of an operand
whose length specification is an asterisk in parentheses, (*), unless the operand is the
symbolic name of a constant.
Note that if there are no dummy arguments in the function statement, the function
must be referenced with an empty actual argument list.
The following are sample function statements and sample references to these
functions:
FUNCTION ZTEMPP(I,X,Y)
DIMENSION Y(10)
...
RETURN
END
DIMENSION A(10),B1(5)
...
...
B1(I*03) = ZTEMPP(J,C1,A)/FRT + OL(6+TOL)
...
END
LOGICAL LFIND
...
...
IF (LFIND()) GO TO 95
....
CHARACTER RANGER,CHR1,CHR2,CHR3
...
...
IF (RANGER(CHR1,CHR2).LT.CHR3) GO TO 35
...
CHARACTER CCONVT,CHAR1*02,CHAR2*06,CHAR3*08
...
CHAR3 = CCONVT(CHAR1)//CHAR2
...
...
Subroutines
A subroutine, if it is not an intrinsic, is a procedure that is specified external to the
program unit that references it. It is specified in a subroutine subprogram.
SUBROUTINE Statement
The SUBROUTINE statement indicates the beginning of a subroutine subprogram and
may specify the dummy arguments used in that subprogram. The maximum allowable
arguments for any single subprogram is 255.
SUBROUTINE <subroutine name> <sub arg list>
| |
( )
| |
| , |
| | | |
<variable name>
| |
/ <variable name> /
| |
<array name>
| |
/ <array name> /
| |
<procedure name>
| |
/ <procedure name> /
The name of a subroutine is a global name and must not be the same as any other
global name or any local name in the program unit.
SUBROUTINE SUBA
SUBROUTINE MULTMT(ARRAY1,ARRAY2)
SUBROUTINE MAXI(A,B,C,*,D,E)
SUBROUTINE GFOR(Z,FUNC)
SUBROUTINE PHASEA()
Intrinsic Subroutines
Intrinsic subroutines are subroutines that are known to the compiler and need not be
supplied in the program. These subroutines may not be passed as actual arguments to
subprograms. Table 12-2 describes intrinsic subroutines.
MOVE treats DEST and SRC as pointers into character strings and attempts to
transfer LEN characters from SRC to DEST without regard to word boundaries or
values. The exception to this rule is that words containing label information may
not be moved. For example, the ASSIGN statement "ASSIGN 10 TO I" makes it
impossible to move the word I.
Example:
REAL A(14,10)
CHARACTER NAME(10)*60, DATE(10)*10
INTEGER AGE(10)
REAL SALARY(10)
READ (1) A
DO 10 I = 1,10
CALL MOVE ( NAME(I), A(1,I), 60 )
AGE(I) = A(11,I)
CALL MOVE ( DATE(I), A(12,I), 10 )
SALARY(I) = A(14,I)
10 CONTINUE
2. The statement CALL FILL (DEST, SRC, LEN) causes the value of SRC to be placed at
successive locations beginning at DEST until the character count LEN has been
exhausted.
FILL attempts to fill the area pointed to by DEST with copies of SRC until LEN is
satisfied. If DEST points into a COMMON area, the area from DEST to the end of
COMMON is FILLed for up to LEN character positions.
Example:
CHARACTER*12 A
REAL B(5)
REAL X/ABCDE/
A=############
CALL FILL (A,X,8)
PRINT *,A
DO 10 K=5,12
CALL FILL (B(1),5,K)
PRINT *,B
10 CONTINUE
END
3. The intrinsic subroutines ASCII and EBCDIC both take three arguments: DEST, SRC,
and LEN. ASCII causes the EBCDIC characters in SRC to be translated into ASCII
characters in DEST for LEN characters. Conversely, EBCDIC causes the ASCII
characters in SRC to be translated into EBCDIC characters in DEST for LEN
characters.
ASCII and EBCDIC treat DEST and SRC as pointers into a character string and
attempt to translate LEN characters from SRC to DEST without regard to word
boundaries or value. If SRC and DEST character addresses are within eight
characters of each other, the results are undefined.
4. The intrinsic subroutine DVCHK allows the program to handle divide-by-zero faults.
If at least one call to the intrinsic DVCHK appears anywhere in the program and a
divide-by-zero fault occurs during the execution of the program, a zero is returned
as the result and the execution of the program continues.
When the DVCHK intrinsic is executed, a value is returned to its argument
indicating whether or not a divide-by-zero fault has occurred since the last call on
DVCHK or, in the case of the first call, since the beginning of the program. A one is
returned when a divide-by-zero has occurred. Otherwise, a two is returned.
The DVCHK intrinsic takes one argument that must be a variable or array element
of type real or integer. DVCHK may not be passed as an actual argument to a
subprogram. DVCHK may not be used in conjunction with binding.
5. The intrinsic subroutine OVERFL allows the program to handle exponent overflow
and exponent underflow faults. If at least one call to the intrinsic OVERFL appears
anywhere in the program and an exponent overflow or exponent underflow fault
occurs during the execution of the program, a result is returned and program
execution continues from that point. When exponent overflow occurs, the largest
possible real or double precision value is returned as the result. When exponent
underflow occurs, zero is returned.
When the OVERFL intrinsic is executed, a value is returned to its argument
indicating whether an exponent overflow or exponent underflow fault has
occurred since the last call of OVERFL or, in the case of the first call, since the
beginning of the program. A one is returned when exponent overflow has
occurred; a two is returned when neither exponent overflow nor exponent
underflow has occurred; and a three is returned when exponent underflow has
occurred.
The OVERFL intrinsic takes one argument that must be a variable or array element
of type real or integer. OVERFL may not be passed as an actual argument to a
subprogram. OVERFL may not be used in conjunction with binding.
6. The intrinsic MVBITS takes five arguments: SRC, SB, LEN, DEST, and DB. MVBITS
transfers a bit field from a "source" to a bit field of a "destination".
7. Execution of the intrinsic subroutine EXIT causes termination of the program. CALL
EXIT performs a similar function to that of the STOP statement, except that no
message is displayed.
The intrinsic subroutine EXIT takes no arguments and cannot be passed as an
actual argument to a subprogram.
8. The FREEZE intrinsic changes the running program into a library stack. The
character constant argument must be either 'TEMPORARY' or 'PERMANENT'. See
Section 18 for more information on creating libraries.
9. The intrinsic subroutine TRANS translates the characters in the source into the
destination under the control of a translate table for the specified length. Each
source character is used as an index into the translate table. The character found
at that position in the table is moved to the destination string. The TRANS routine
takes four arguments:
10. The intrinsic subroutines FSORT and FMERGE perform a sort or merge,
respectively. A sort accepts records from the input, arranges them in order, and
returns them to the output. A merge accepts sorted records from multiple inputs
and merges them in order to a single output. These subroutines take four kinds of
arguments:
The INFO argument is a character string that describes the operation of the sort or
merge. It contains a number of clauses, each of which describes an attribute of
the process. If an attribute has multiple parts, those parts are contained in
parentheses. The clauses are separated by blanks or commas. Examination of the
string is terminated at the end of the string or when a period occurs. The following
clauses describe the operation of the sort:
RSZ=rlth record length in bytes
The following example creates a set of test records, sorts them in ascending
order, and merges them with an existing file, eliminating any records with
duplicate keys. The comparison routine ensures that test records with duplicate
keys appear after existing records.
FILE 1(FILE=SORT/EXAMPLE/INPUT; ,STATUS=OLD,MAXRECSIZE=6)
FILE 2(FILE=SORT/EXAMPLE/TEST. ,STATUS=NEW,MAXRECSIZE=6)
FILE 3(FILE=SORT/EXAMPLE/OUTPUT. ,STATUS=NEW,MAXRECSIZE=6)
COUNT = 0
RANDOMARG = TIME( 11 )
OPEN( 3 )
CALL FMERGE(RSZ=36 KEY=1/6 . COMP,
* 1, 2, OUTPROC )
CLOSE( 3 )
STOP
END
RESULT = 3
ELSE IF( RECB(13:18) .EQ. *TEST* ) THEN
RESULT = 1
ELSE
RESULT = 2
END IF
END IF
RETURN
END
For more information on how the Sort operates, see the ClearPath Enterprise
Servers System Software Utilities Operations Reference Manual.
11. Sorting may be done on the basis of an alternate collating sequence. Normally,
characters are sorted on the basis of the EBCDIC character sequence. Every
character is assigned a position in the sequence. An alternate collating sequence
allows a different ordering of the characters. For example, EBCDIC specifies that
lower case letters precede upper case letters. An alternate collating sequence can
be written to make them equal. There are two routines for handling alternate
collating sequences: COLLSEQ and FSSEQ. COLLSEQ creates a sequence and
FSSEQ establishes a sequence for use by the Sort. The TRANS routine may also
be used with an alternate collating sequence. For sorting, TRANS is most often
used in user-defined compare routines that use the alternate collating sequence
order, but must provide other code.
The COLLSEQ subroutine creates an alternate sequence. It takes two arguments:
DESC: A CHARACTER array or subscripted array reference, a
CHARACTER variable, a CHARACTER substring, or a
CHARACTER constant. This character string describes the
order of characters in the alternate collating sequence.
TABLE: An array defined as REAL with 64 elements. This array contains
the alternate collating sequence in the form of a translate
table.
The DESC string lists the characters of the new sequence in order. In other words,
the first character specified becomes first in the sequence, the next character
becomes the second, and so on. A character is specified in a character string or by
a number (0-255) that specifies its position in the original collating sequence.
Multiple characters may be specified in the character string or by a range of
numbers (for example, 0-128). Characters that have equal positions in the
sequence are indicated by "&". The last character in the DESC string must be a
period. The ASCII sequence may be specified by using 'ASCII . '.
The FSSEQ routine establishes an alternate collating sequence for use with FSORT
and FMERGE. Once executed, all following sorts and merges use the alternate
collating sequence to compare character keys. If FSSEQ is executed with no
arguments, then the original (EBCDIC) sequence is reestablished.
The following program uses a collating sequence where digits appear before
letters, comma and period are equal, and lower case letters appear immediately
after their upper case counterparts:
CHARACTERS*256 INP
REAL TABLE(64)
INP = 0-74 "." & "," 76-106 108-128
* // "0123456789"
* // "AaBbCcDdEeFfGgHhIiJjKkLlMm
* // NnOoPpQqRrSsTtUuVvWwXxYyZz" .
CALL COLLSEQ( INP, TABLE )
CALL FSSEQ( TABLE )
CLOSE( 6 )
CALL FSORT( RSZ=72 KEY=1/36//S, 5, 6 )
STOP
END
12. The intrinsic subroutine TRANSTBL builds a translate table for use with the TRANS
intrinsic subroutine. The TRANSTBLE subroutine takes two parameters:
The DESC string consists of a series of clauses that describe the translation. Each
clause lists which source characters are to be translated to which destination
characters. The table is built by applying each clause in order. Characters not
specified are translated to 0. The source and destination are separated by the
word TO. Each source or destination may either be a character string (surrounded
by quotes), a number between 0 and 255 (corresponding to its position in the
collating sequence), a sequence of characters specified by two characters or
numbers separated by a hyphen, or a pre-defined table (EBCDIC, ASCII, or HEX).
The number of characters in the destination must either be equal to the number in
the source or 1.
The following program translates lower case characters to upper case characters
and unprintable characters found before the space to the period character.
CHARACTER*256 INP
CHARACTER*20 TEST,RSLT
REAL TABLE(64)
20 STOP
END
CALL Statement
A subroutine is referenced by a CALL statement.
CALL <subroutine name> <call arg list>
| |
( )
| |
| , |
| | | |
<expression>
| |
<array name>
| |
<procedure name>
| |
* <label>
| |
&
Execution of a CALL statement results in the evaluation of actual arguments that are
expressions, the association of actual arguments with the corresponding dummy
arguments, and the transfer of control into the subroutine subprogram that is
referenced. Return of control from the referenced subroutine completes execution of
the CALL statement.
The actual arguments in a subroutine reference must agree in order, number, and type
with the list of arguments in the referenced subroutine. The use of a subroutine name
or an alternate return specifier as an actual argument is an exception to the rule
requiring agreement of type.
Each actual argument in a CALL statement must be an array name, an intrinsic function
name, an external procedure name, a dummy procedure name, an alternate return
specifier, or an expression. A character expression involving concatenation of an
operand whose length specification is an asterisk in parentheses, (*), is not allowed,
unless the operand is the symbolic name of a constant.
An alternate return specifier has the form *<label> (or &<label>) where the label is a
statement label of an executable statement that appears in the same program unit as
the CALL statement.
CALL SUBA()
CALL MULTMT(ARRAYA,ARRAYB)
CALL MAXI(U,V,W,*30,X,Y)
CALL GFOR(2*C(3)/4.1,FACTOR)
CALL PHASEA
ENTRY Statement
An ENTRY statement permits a procedure reference to begin with a particular
executable statement within the function or subroutine subprogram in which the
ENTRY statement appears. One or more ENTRY statements may appear within a
function subprogram after the FUNCTION statement, or within a subroutine
subprogram after the SUBROUTINE statement. An ENTRY statement must not appear
between a block IF statement and its corresponding END IF statement, or between a
DO statement and the terminal statement of its DO-loop.
ENTRY <function name> <func arg list>
| |
<subroutine name> <sub arg list>
The dummy argument list in an ENTRY statement is independent of any other dummy
argument lists in the program unit. If the same names appear in more than one
dummy argument list in a subprogram, they need not occupy the same positions in
those lists. An ENTRY statement may contain more or fewer dummy arguments than
the FUNCTION or SUBROUTINE statement. Entry into a procedure at any point results
in initialization of only those dummy arguments included in the dummy argument list
of the statement in which entry occurs. Use of dummy arguments not included in the
dummy argument list where the procedure was entered is prohibited.
If the entry name within a function subprogram is to have a non-default type, it must
be referenced in a type or IMPLICIT statement both in the calling program unit and in
the function subprogram body.
Within a function subprogram all variables whose names are also the names of entries
are associated with each other and with the variable, if any, whose name is also the
name of the function subprogram. Therefore, any such variable that becomes defined
causes all associated variables of the same type to become defined and all associated
variables of different types to become undefined. Such variables are not required to
be of the same type unless the type is character, but the variable whose name is used
to reference the function must be in a defined state when the RETURN or END
statement is executed. An associated variable of a different type must not become
defined during the execution of the function reference.
If an entry name in a function subprogram is of type character, each entry name and
the name of the function subprogram must be of type character and have the same
length specification. In a function subprogram, a variable name that is the same as an
entry name must not appear in any executable statement that precedes that entry
name in an ENTRY statement.
SUBROUTINE SUBA(A,B)
A=A/2.0
ENTRY XSUBA(B,A)
A=A**B
B=A
RETURN
END
CALL SUBA(G,H)
CALL XSUBA(G,H)
It should be noted that when using a specific entry point to a subroutine or function
subprogram, any assignment statements in the program previous to the entry point
will not be recognized.
For example:
G = 5
H = 6
CALL SUBA (G, H)
CALL XSUBA (G, H)
END
SUBROUTINE SUBA (A, B)
INTEGER C
C = 4
A = A / 2.0
PRINT *, A, B, C
ENTRY XSUBA (B, A)
A = A * B
B = A
PRINT *, A, B, C
RETURN
END
2.5 6.0 4
2*15.0 4
2*225.0 0
When XSUBA is called, c is 0 since the assignment statement located previous to the
entry point is ignored.
Note: Only the dummy arguments that are associated with the entry point through
which the subprogram is entered may be used.
RETURN Statement
The executable RETURN statement may appear only in a function or subroutine
subprogram. It causes control to be returned to the referencing program unit.
Execution of a RETURN statement (or END statement) causes all entities within a
subprogram to become undefined, except for entities in common, entities specified
by SAVE statements, or entities that have been initially defined and have not been
redefined.
Alternate Return
Note: In addition to the asterisk, the ampersand (&) is used to represent an
alternate return for a subroutine call. The ampersand is accepted regardless of the
state of the CONVERT option.
An alternate return specifier is of the form *s, where s is the statement label of an
executable statement that appears in the same program unit as the CALL statement.
The following program excerpt illustrates a calling program unit able to handle
alternate returns from the called subprogram.
CALL SUBA(I,*33,B,*20,J)
15 Z=A1 + N
20 Z=Z + A2
33 Z=Z + A1
First, suppose that when the IF statement in the subroutine is executed, I is greater
than zero. Then there is a transfer of control to the statement labeled 7, which is a
standard return. The subroutine returns to the calling program unit at the CALL
statement, then execution continues to the statement labeled 15.
Second, suppose that I is less than zero. When the IF statement in the subroutine is
executed, there is a transfer of control to the statement labeled 5. This is an alternate
return to the first label in the actual argument list. It returns to the statement labeled
33 in the calling program unit.
A dummy argument that is a variable may be associated with an actual argument that
is a variable, array element, substring, constant, symbolic name of a constant, function
reference, or expression. If the actual argument is a variable, array element, or
substring, then the associated dummy argument may be defined or redefined within
the subprogram and the actual argument takes on the value of the dummy argument.
If the actual argument is a constant, symbolic name of a constant, function reference,
expression involving operators, or expression enclosed in parentheses, then
redefining the associated dummy argument within the referenced procedure has no
effect on the value of the actual argument. Actual arguments consisting of
expressions are evaluated just before the association of dummy arguments to actual
arguments.
If the dummy argument is a variable and the actual argument is the name of an array,
the actual argument is treated as a subscripted array name and references the first
element of that array. For example, if subroutine SUB has a single dummy argument
which is a variable, and A is an array, then CALL SUB(A) is equivalent to CALL
SUB(A(1)).
When the compiler control option CALLBYREFERENCE is not set and a variable or array
element appears as an actual argument (for example, the corresponding dummy
argument is a variable), it is called by name. That is, if the value of the dummy
argument changes, the final value of the dummy argument is assigned to the
corresponding actual argument when execution of the subprogram is completed. The
only exception is a character variable dummy argument. A change in the value of a
character variable dummy argument is recorded as a change in the value of the
corresponding actual argument at the time of the change rather than at the end of the
subprogram execution.
When considering the length of a character type array, the overall character length of
the array should be considered, rather than the number of elements in the array. The
length of an element in the dummy argument array may be different from the length
of an array element in the actual array. The character array should be thought of as a
string of characters.
A dummy argument that is a dummy procedure may be associated only with an actual
argument that is an intrinsic function, external function, subroutine, or another dummy
procedure.
The variables and arrays in a common block may be defined and referenced in all
subprograms that contain a declaration of that common block. Because association is
by storage rather than by name, the names of the variables and arrays may be
different in the different subprograms.
Example:
PROGRAM MAIN
EXTERNAL PASS
CALL SUB (PASS)
END
SUBROUTINE SUB (P)
CALL P (X1,X2,...,XN)
END
With a subroutine SUB, if the call to P has an argument list that exceeds 46 words, the
compiler issues an error message.
Block data subprograms are used to provide initial values for variables and array
elements in common blocks. A block data subprogram is a non- executable program
unit that has a BLOCK DATA statement as its first statement. There may be more than
one block data subprogram in an executable program.
The optional name is a global name and must not be the same as any local name in the
subprogram, the name of an external procedure, main program, common block, or
other block data subprogram in the same executable program.
The BLOCK DATA statement must appear only as the first statement of a block data
subprogram. The only other statements that may appear in a block data subprogram
are IMPLICIT, PARAMETER, DIMENSION, COMMON, SAVE, EQUIVALENCE, DATA,
END, and TYPE statements. Comment lines are also permitted.
If an entity in a common block is initially defined, all entities having storage units in the
common block storage sequence need not be specified.
The same named common block may be specified in more than one block data
subprogram in the same executable program. Within each block data subprogram, the
items listed for the common block are considered to start at the beginning of the
common block. If a given location in the common block is initialized in more than one
block data subprogram, results are unpredictable.
More than one common block may have entities initially defined in a single block data
subprogram.
BLOCK DATA
IMPLICIT LOGICAL (L)
COMMON L1, LCTL, /BLKA/A(3)
DATA L1, LCTL, A/2*.TRUE.,3*03.2/
Debug statements assist in isolating programming errors. The debugging aids for
FORTRAN77 are implemented by means of statements and compiler control options.
All statements start with the word DEBUG and conform to the usual FORTRAN77
statement formulation rules. The ability to inhibit code generation for a statement at
compilation time, as well as output at execution time, is provided.
The code (and output) from all debugging statements may be deleted permanently at
compilation time by setting the OMITDEBUG compiler control option. In that way the
statements can become a permanent part of a symbolic program, included while the
program is being developed and excluded while the program is in production form.
FORTRAN77 also provides for inhibiting output at execution time. All output from
debugging statements is inhibited unless DEBUG is specified for the task attribute
OPTION. The default of the task attribute OPTION is DEBUG reset. It can be set for
each execution of a program at compilation time by the CANDE statement:
COMPILE X; OPTION=DEBUG
RUN X; OPTION=DEBUG
RUN X; OPTION=(DEBUG);
In addition to the debug facilities described here, the interactive FORTRAN77 Test and
Debug System (TADS) constitutes an important debugging aid. Refer to the ClearPath
Enterprise Servers FORTRAN77 Test and Debug Programming Reference Manual
for more information.
! " , $
% %
&' /1\ LABELS ( <label list> ) '&1
% %
2 /1\ FREQ ( <control condition> ) 1
% %
7 /1*\ VARS ( <variable list> ) ;
<unit identifier>
' <positive integer expression> '1
% %
2 <variable name> 1
% %
7 * ;
<label list>
! " , $
% %
& <label> &1
<control condition>
! " , $
% %
&' /1\ <frequency condition> '&1
% %
7 /1\ <bounds condition> ;
<frequncy condition>
<bounds condition>
<variable list>
! " , $
% %
&' <variable name> '&1
% %
7 <array name> ;
The <unit identifier> specifies where the output is to go. It may be either a unit
number, a variable name, or an asterisk (*). An asterisk causes output to be sent to the
default output unit 6.
If LABELS is specified, then values are dumped when control passes to any of the
designated labels (otherwise, values are dumped at every label). A label can appear in
only one DEBUG DUMP statement per program unit.
FREQ provides the ability to limit the number of times dumping takes place. When
<frequency condition> is used, dump action occurs every <frequency condition>th
time control passes any label where the dump action is to take place. The <bounds
condition> causes a dump when the <integer variable> is within the specified bounds.
If both a <bounds condition> and a <frequency condition> are requested, the <bounds
condition> is subject to the <frequency condition>. FREQ can be used to specify that
dump action should take place every fth time through a loop, or when a DO- LOOP
index is within a certain range.
VARS is the list of items to be displayed and it must be included. Each item is either a
variable or an array name. The same variable or array name may appear in more than
one DEBUG DUMP statement list.
There can be more than one DEBUG DUMP statement per program unit. A DEBUG
DUMP statement may not appear in a program unit that is declared to be in a library, a
BLOCK GLOBALS or BLOCK DATA program unit.
Output:
<programdump option>
The PRESENTARRAY and PRESENTARRAYS option causes only those arrays in the
present state (at the time the program dump is taken) to be dumped.
Note: If the ARRAY or ARRAYS program dump option is set along with the
PRESENTARRAY or PRESENTARRAYS program dump option, all arrays will be
dumped.
The <programdump option>s TODISK and TOPRINTER are used to specify the
destination of the dump.
When TODISK has been specified, a disk file containing the dump is created in a
format acceptable to DUMPANALYZER. The listing produced currently by
PROGRAMDUMP is suppressed, unless TOPRINTER is also specified.
The portion of the task name included in the dump file title is limited to eight nodes.
If TOPRINTER is also set, after the disk file has been produced, a regular program
dump to printer is then taken. Since the dump to disk has some effects in which the
contents of memory could be changed the two dumps may not be identical.
All other program dump option settings (for example, ARRAYS, LIBRARIES) still affect
the contents of the disk dump, except BASE. The base of stack and the PIB are always
dumped for any stack dumped.
On a non-ASD system, these options are ignored and the current printer dump is
produced.
There can be more than one DEBUG PROGRAMDUMP statement per program unit. A
DEBUG PROGRAMDUMP statement may not appear in a program unit that is declared
to be in a library, a BLOCK GLOBALS or BLOCK DATA program unit, or a logical IF
statement.
<unit identifier>
<variable list>
! " , $
% %
&' <variable name> '&1
% %
2 <array element name> 1
% %
7 <array name> ;
The <unit identifier> specifies where output is to go. It may be either a unit number,
an identifier, or an asterisk (*). An asterisk causes output to be sent to the default
output unit 6.
If the list contains an array identifier without subscripts, then every element of that
array is monitored. If the list contains actual array elements, then only those elements
of the array are monitored.
There can be more than one DEBUG MONITOR statement per program unit; the
effects are cumulative. An item can be specified for monitoring in only one DEBUG
MONITOR statement per program unit. An item that is equivalent to an item that is
being monitored is not monitored unless it is specified in a DEBUG MONITOR
statement. A DEBUG MONITOR statement cannot appear in a program unit that is
declared to be in a library, a BLOCK GLOBALS or BLOCK DATA program unit.
Examples
FILE 1(KIND=REMOTE)
BLOCK DATA
COMMON /COM/ ELMT1, ELMT2
END
PROGRAM MAIN
COMMON /COM/ A, B
DEBUG MONITOR(1) VARS(ELMT1)
A=1
ELMT1=2
CALL SUB
END
SUBROUTINE SUB
COMMON /COM/ A, B
DEBUG MONITOR(1) VARS(A)
A=3
ELMT1=4
END
In the preceding example, the first element in common is monitored in SUB only. Each
program unit in which monitoring of a common element is to take place must contain
a DEBUG MONITOR statement specifying the element as it appeared in the COMMON
statement in that program unit.
FILE 1(KIND=REMOTE)
PROGRAM MAIN
DIMENSION A(5)
DEBUG MONITOR(1) VARS(A(I))
I=3
A(1)=3
A(2)=4
A(3)=5
I=5
A(4)=6
A(5)=7
END
In the preceding example, the assignments of A(3) and A(5) are monitored. Since a
simple variable is used as an individual subscript in the DEBUG MONITOR statement,
the location in A whose index is equal to the current value of I is monitored.
There can be more than one DEBUG <statement> statement per program unit. A
DEBUG <statement> statement cannot appear in a program unit that is declared to be
in a library, a BLOCK GLOBALS or a BLOCK DATA program unit, or a logical IF
statement.
Example
PROGRAM MAIN
L=1
DEBUG CALL DEBUG(L)
END
SUBROUTINE DEBUG(M)
. . .
END
The preceding example illustrates one use of the DEBUG <statement> statement.
Generation of the CALL on the subroutine DEBUG can be inhibited at compilation by
using the OMITDEBUG compiler control option. The actual call on the subroutine
DEBUG is dynamic at execution time. The subroutine DEBUG could cause side effects,
depending on whether or not it is actually executed. Note that the use of the word
DEBUG as a subroutine name is not significant.
There can be more than one DEBUG START statement per program unit. A DEBUG
START statement cannot appear in a program unit that is declared to be in a library, a
BLOCK GLOBALS or BLOCK DATA program unit, or a logical IF statement.
There can be more than one DEBUG STOP statement per program unit. A DEBUG
STOP statement cannot appear in a program unit that is declared to be in a library, a
BLOCK GLOBALS or BLOCK DATA program unit, or a logical IF statement.
Example
PROGRAM MAIN 1
DEBUG PROGRAMDUMP (ARRAYS) 2
A=1 3
DEBUG START 4
CALL SUB1 5
DEBUG PROGRAMDUMP (ARRAYS) 6
DEBUG STOP 7
CALL SUB2 8
DEBUG PROGRAMDUMP (ARRAYS) 9
END 10
SUBROUTINE SUB1 11
B=1 12
DEBUG PROGRAMDUMP 13
CALL SUB2 14
END 15
SUBROUTINE SUB2 16
C=1 17
DEBUG PROGRAMDUMP 18
END 19
The preceding example (with line numbers to the right for reference) illustrates the
use of DEBUG START and DEBUG STOP statements. Output from the DEBUG
PROGRAMDUMP statement on line 2 is dependent on the status of the DEBUG task
attribute. If the program is executed with DEBUG specified for the task attribute
OPTION, a program dump is produced.
Once the DEBUG START statement on line 4 is executed, the program continues as if
DEBUG were specified for the task attribute OPTION. When SUB1 is called, the DEBUG
PROGRAMDUMP statement on line 13 produces a program dump. When SUB1 calls
SUB2, the DEBUG PROGRAMDUMP statement on line 18 also produces a program
dump.
Note that DEBUG START and DEBUG STOP can be used to produce debugging
information based on the logical flow of an executing program.
Each FORTRAN77 data item is allocated one or more units of storage depending upon
the type of value the item represents. The unit of storage is the data word, 48 bits of
which are accessible to the user.
Simple Variables
Arrays
Equivalent Data Items
Elements of Common Storage
The method of storage allocation for each of these features is discussed in this
section. The notation [m:n] is used to describe data word fields. The 48 accessible bits
of a data word are considered numbered, with the left-most bit being bit 47 and the
right-most bit being bit 0. In the notation [m:n], m denotes the number of the left-most
bit of the field being described, and n denotes the number of bits in the field. For
example, the field shown (bit 28 through 24) would be described by [28:5]:
47 43 39 35 31 27 23 19 15 11 7 3
46 42 38 34 30 30 26 22 18 14 10 6
45 41 37 33 29 25 21 17 13 9 5 1
44 40 36 32 28 24 20 16 12 8 4 0
Variable
Each variable requires one, two, or more words of storage depending upon the type
of variable. The variable types are:
Integer variables
Real variables
Double precision variables
Complex variables
Logical variables
Character variables
Each of these variable types has a unique internal storage configuration.
Integer Variables
An integer variable requires one word of storage. The data word corresponding to an
integer variable is partitioned as follows:
Field Contents
[47:1] Undefined
[46:1] Sign bit
[45:7] Must contains all zeros
[38:39] Magnitude of data item
Integer values are represented internally in signed-magnitude notation. The sign of the
value is denoted by bit 46 of the data word involved. This bit is 0 for positive values
and 1 for negative values. The magnitude of the value is stored right-justified in bits 38
through 0 preceded by zeros.
For example, the internal representation of the integer 10 described using hexadecimal
constant notation is as follows:
Z00000000000A
Z40000000000A
Real Variables
A real variable requires one word of storage. The data word corresponding to a real
variable is partitioned as follows:
Field Contents
[47:1] Undefined
[46:1] Mantissa sign bit
[45:1] Exponent sign bit
[44:6] Magnitude of data item exponent
[38:39] Magnitude of data item mantissa
Real (floating point) values are represented internally in signed magnitude mantissa
and exponent notation. The sign of the mantissa is denoted by bit 46 while the sign of
the exponent is denoted by bit 45 of the data word. 0 denotes a positive value and 1 a
negative value for these bits. The magnitude of the exponent is contained in bits 44
through 39; hence, the exponent may not exceed a magnitude of 2**06 - 1 = 63. The
magnitude of the mantissa is contained in bits 38 through 0. This field is identical to
the magnitude field of a data word contained in an integer value. Thus, an integer data
word may be considered a real data word with an exponent field containing all zeros.
(mantissa) *08**(exponent)
The magnitude of the mantissa is usually stored left-justified within its word field.
Therefore, the internal representation of the real value 0.5 (or .5E0) in hexadecimal
constant notation is Z26C000000000. The exponent in this example is -13 and the
mantissa is 4*08**32.
Field Contents
First Word
[47:1] Undefined
[46:1] Mantissa sign bit
[45:1] Exponent sign bit
[44:6] Least significant part of magnitude of exponent
[38:39] Most significant part of magnitude of mantissa
Field Contents
Second Word
[47:9] Most significant part of magnitude of exponent
[38:39] Least significant part of magnitude of mantissa
Double precision values are represented internally in signed magnitude mantissa and
exponent notation with a most significant part and a least significant part. The sign of
the mantissa is contained in bit 46 of the first data word while the sign of the
exponent is contained in bit 45 of the first word. 0 denotes a positive value and 1 a
negative value for these bits. The magnitude of the exponent is contained in a total of
15 bits. The first nine of these 15 bits (the most significant part of the magnitude of the
exponent) are contained in bits 47 through 39 of the second data word. The remaining
six of these 15 bits (the least significant part of the magnitude of the exponent) are
contained in bits 44 through 39 of the first data word.
The magnitude of the mantissa is contained in a total of 78 bits. The first 39 bits (the
most significant part of the magnitude of the mantissa) are contained in bits 38
through 0 of the first data word. The remaining 39 bits (the least significant part of the
magnitude of the mantissa) are contained in bits 38 through 0 of the second word.
The value represented by a double precision data-word pair may be obtained by the
formula:
The magnitude of the mantissa is usually stored left-justified within the total 78 bit
field.
Z261000000000 Z0000000000000
The contents of the first of these two data words are identical to the contents of a
data word representing the real value 1E0. When a value that does not exceed the
limits of a real variable is assigned to a double precision data word pair, then that data
word pair can be represented in a form where the second data word is all zeros and
the first data word is equal to the real representation of the value.
Complex Variables
A complex variable requires two adjacent words of storage. The first data word
contains the real part of the variable, and the second data word contains the imaginary
part of the variable.
Each of these two data words conforms to the format of an integer or real variable. If
the complex variable is assigned the value of a complex constant whose real and/or
imaginary part is an integer constant, then the first and/or second data word of the
complex constant is partitioned as an integer data word. A real constant in the
complex constant similarly controls the structure of the corresponding complex data
word.
C = (1,0.5E0)
Z000000000001 Z26C000000000
The first data word (the real part of C) contains a representation of the integer
constant 1. The second data word (the imaginary part of C) contains a representation
of the real constant 0.5E0. If the assignment statement were:
C = (1,1)
Z000000000001 Z000000000001
Logical Variables
A logical variable requires one word of storage. The data word corresponding to a
logical variable is partitioned as follows:
Field Contents
[47:47] Unused
[0:1] Value bit
Even though logical operators reference all 48 bits, the left-most 47 accessible bits of
the data word have no effect on the value, while the value represented by that
variable is contained in bit 0 of the data word. When bit 0 is 1, the value of the variable
is .TRUE. and when bit 0 is 0, the value of the variable is .FALSE..
000000000000000000000000000000000000000000000001
000000000000000000000000000000000000000000000000
The value for .NOT. .TRUE. is the complement of .TRUE. where all ones are changed
to zeros, and all zeros are changed to ones; therefore, .NOT. .TRUE. is stored as:
111111111111111111111111111111111111111111111110
The value for .NOT. .FALSE. is achieved in the same way; .NOT. .FALSE. is stored as:
111111111111111111111111111111111111111111111111
Character Variables
Character variables are stored as strings of EBCDIC characters. Character variables
that are not in a COMMON statement are collected and stored together in character
pools. These character pools are stored internally as EBCDIC arrays.
Arrays
FORTRAN77 arrays are provided to allow the user to organize program storage
locations into a convenient structure. Internally, an array is stored as a group of one or
more contiguous storage units. A FORTRAN77 array of any number of declared
dimensions is represented internally by a one-dimensioned array of storage locations.
Each element of an array has storage requirements and partitioning identical to that of
a variable of the same type as the array. Thus, each element of a real array requires
one data word partitioned like a real variable and each element of a complex or double
precision array requires two data words partitioned like a complex or double precision
variable, and each element of a character array requires the number of characters
specified in the length specification for the array. If the length is not specified the
length is one character.
Double precision and complex arrays use two words per element instead of one. The
standard array limit is 2**20-1 on MCP/AS processors or 2**28-1 on MCP/AS
(Extended) processors, but the double precision and complex arrays each have a
reduced limit of 2**19-1 on MCP/AS processors or 2**27-1 on MCP/AS (Extended)
processors to avoid exceeding the standard limit.
Each integer, real, and logical array is allocated as many data words as there are
elements in the array. Each double precision and complex array is allocated twice as
many internal data words as there are elements in the array. Each character array is
allocated as a string of EBCDIC characters. The total number of characters in the array
is equal to the number of elements in the array times the length of the array elements.
Each character array is stored in its own character pool, which is stored internally as
an EBCDIC array.
The elements of an array are ordered into a sequence. The subscript of an array
element has a subscript value that determines which element of the sequence is
identified by the array element. The first element has a subscript value of 1. The ANSI
standard does not permit REAL subscripts. The value of the REAL expression is
truncated to generate an index into the array.
A(L1:U1,L2:U2,L3:U3,...,Ln:Un)
A(S1,S2,S3,...Sn)
would be
1+(S1-L1)
+ D1*(S2-L2)
+ D1*D2*(S3-L3)
+ ...
+ D1*D2*...*D(n-1)*(Sn-Ln)
where:
The offset of an array element within the sequence is its position in the sequence
relative to the first element. The offset of an array element is equal to its subscript
value minus 1. The offset of the first element of an array is 0.
Example:
For an array declared:
DIMENSION A(0:5,1:4)
= 1 + (3-0) + 6*(2-1)
= 1 + 3 + 6
= 10
The ordering of the array elements produced by the subscript value is identical to that
obtained by listing all of the array elements by varying the first subscript expression
most rapidly, the second subscript expression next most rapidly, and so on.
Example:
For the array A declared by the declarer:
DIMENSION A(0:2,1:2,-2:-1)
A(0,1,-2)
A(1,1,-2)
A(2,1,-2)
A(0,2,-2)
A(1,2,-2)
A(2,2,-2)
A(0,1,-1)
A(1,1,-1)
A(2,1,-1)
A(0,2,-1)
A(1,2,-1)
A(2,2,-1)
Element A(0,1,-2) corresponds to the first element of the internal array. This order is
the order in which array elements are considered when a multidimensional array is
used in an EQUIVALENCE statement or when the name of a multidimensional array
appears in an I/O list, DATA statement, argument list, COMMON statement, as a
format designator, or as an internal file identifier.
The EQUIVALENCE statement causes the integer variable A, the integer array element
AR(2), and the real variable B2 all to be assigned to the same data word. The first
element of AR is not affected by this statement. A change in the value of any one of
the three equivalent items produces a simultaneous equivalent change in the value of
the other two items.
The EQUIVALENCE statement also causes the integer variable AL and the logical
variable L to be assigned to the same data word. As the variable L changes value, AL
changes value. For example, the assignment statement:
L = .TRUE.
also places the integer value 1 into variable AL. As the variable AL changes value, L
changes value accordingly. As AL assumes even integer values, L assumes the value
.FALSE., and as AL assumes odd integer values, L assumes the value .TRUE..
DOUBLE PRECISION D
REAL A(2)
EQUIVALENCE (A,D,B)
The EQUIVALENCE statement causes the real array A, the double precision variable D,
and the real variable B to be assigned to identical data words. As A and D both require
two data words, the first and second elements of A become equivalent to the first and
second words, respectively, of the storage unit assigned to D. The variable B,
requiring only one data word, is assigned to the same word as A(1) and the first word
of D.
Array Handling
The EQUIVALENCE statement may be used to assign a group of contiguous storage
locations to a number of program arrays. There are two types of possible array
references in an EQUIVALENCE statement: an array name and a subscripted array
name with the same number of subscript expressions as the array has dimensions.
Assume that the following statements are the first statements of a program unit:
The first list in this EQUIVALENCE statement causes the real array A and the double
precision array DE to share four storage words. The first two elements of A become
equivalent to the two words of the first element of DE, and the last two elements of A
become equivalent to the two words of the second element of DE. The initial value list
in the type statement declaring DE causes the double precision value 1D0 to be placed
in DE(1) and DE(2) and in the word pairs A(1),A(2) and A(3),A(4).
The second list in the EQUIVALENCE statement causes the real arrays B and C to
share 100 storage words. Each element in the 100 element array C, beginning with C(1),
is assigned to the same storage unit as a unique element of B. The elements of the
two-dimensional array B are stored internally in the manner described in the
discussion of arrays in this section. The internal storage units assigned to C occur in
the same order as the elements of that array. Hence, each C(I) is equivalent to the ith
internal element of B and it follows that if the following two PRINT statements occur
in this program unit, identical output is produced:
The following DATA statement initializes the elements E(1,2), E(2,2), F(28), F(29), D(3),
and D(4) with the value 6:
010203040506070809101112
A
B
The size of each block of common storage is either as large as the maximum size
indicated by a COMMON statement referencing that block in any program unit or as
large as the maximum length to which the block is extended by an EQUIVALENCE
statement.
Assume that the following statements are the first statements of a program unit:
SUBROUTINE MSG
DOUBLE PRECISION D
LOGICAL FLAG(6)
COMMON WORD1, WORD2,D,FLAG,TEXT(20)
COUNT = 1
The COMMON statement provides the maximum size of the blank common block in
the executable program containing program unit MSG. The total size of this common
block is then 30 words. In the MSG subprogram these are the words assigned to the
real variables WORD1 and WORD2, the word pair assigned to the double precision
variable D, the six words assigned to the logical array FLAG, and the twenty words
assigned to the real array TEXT. These data words are contained within the common
block in the order listed.
The blank common block just described could be referenced, for example, by a
common statement within another program unit:
SUBROUTINE DUMP
COMMON T(10)
PRINT 1,T
1 FORMAT(X,Z12)
RETURN
END
In this case, the elements of real array T correspond to the first 10 data words
contained in the common block. The last 20 data words of the common block are not
accessed in the DUMP subprogram.
Additionally, the EQUIVALENCE statement may interact with the COMMON statement
to extend the length of a common block beyond the maximum size specified for the
block by COMMON statements.
FUNCTION SUM(N)
COMMON /GR1/IT(3,3)
.
.
.
RETURN
END
The common block referenced by these two program units is named GR1 and consists
of 11 data words. The function SUM accesses the first nine words of this block
through the two-dimensional integer array IT. The function TEST accesses the first
nine words of the block through the integer array K. In addition, the next two locations
of GR1 are referenced as the logical array elements X(5) and X(6) since X is equivalent
to K starting at the element K(6).
Array K and array IT both refer to the same area of common storage. Use of array K
allows these locations to be referenced using only one subscript expression.
Equivalencing portions of the X and K arrays allows some elements of GR1 to be
handled as both integer and logical type items.
The common block could not have been extended backwards by the EQUIVALENCE
statement. The following combination of statements is invalid:
LOGICAL X(6)
COMMON /GR1/K(9)
EQUIVALENCE (X(3),K)
The total sum of all variables and arrays in a COMMON block cannot exceed 2**20-1
words on MCP/AS processors or 2**28-1 words on MCP/AS (Extended) processors.
Compiler Files
Input Files
The primary compiler input file has the internal name CARD; the secondary input file
has the internal name SOURCE. The presence of the primary file CARD is required for
each compilation; the presence of the secondary file SOURCE is optional. The file
SOURCE is used as input when the MERGE compiler option is set in the primary file or
during a SEPCOMP. To change their file attributes, both the CARD file and the SOURCE
file may be label-equated by means of FILE system control cards.
Compiler control images and certain comments may be passed to the compiler
through a file having the internal name INITIALCCI. It is only used if resident on the
system; no warning is issued if an INITIALCCI file does not exist. A user's INITIALCCI
file, if present, is used; otherwise, a public file, if present, is used (this file, if set up by
the system administrator, should be read-only). For more information on the use and
contents of this file, refer to Section 17.
Additional files may be input to this compiler through use of the INCLUDE compiler
control statement.
In certain cases, the compiler requires information from other files other than source
text input files. The input files HOST and XREFFILE are discussed with SEPCOMP in
Section 17. (HOST may also be necessary during autobinding.)
Output Files
Output files produced by this compiler include the object code file, an optional
updated symbolic file, a listing, and an error message file.
When it is compiled through WFL, the object code file has the internal name CODE and
is saved after the compilation only if LIBRARY is specified. Also the TITLE of the saved
code file is identical to the program name appearing on the COMPILE card unless the
file has been label equated.
The updated symbolic file is generated only if the compiler option NEW is set. This file
contains the compilation source input or a selected portion of this input as specified
by the states of the NEW and INCLNEW compiler options and may be used for
succeeding compilation. This output file has the internal name NEWSOURCE, as well
as the default TITLE NEWSOURCE if the file is not label equated.
The listing is a file that is created when the compiler option LIST is set. The LIST option
is set by default unless the compilation is initiated through CANDE. The file has the
internal name LINE and bears the following information:
1. Compiler version.
2. Date and time of compilation.
3. Code file title.
4. Source and compiler control statements input to the compiler.
5. Code segmentation information.
6. Mark field of the source.
7. Error messages and error count.
8. Warning messages.
9. A listing of the code generated (optional).
10. A list of stack addresses of data items used in the program (optional).
11. Number of input card images scanned.
12. Elapsed compilation time.
13. Processing time required for compilation.
14. Estimated size of program working stack when the program is executed.
15. Estimated size of program files and related storage.
16. Estimated core storage requirement.
17. Total number of words of object code generated.
18. Number of words of array storage required for execution of the program.
19. Number of segments in generated program.
20. Number of disk segments required for code file.
The output error message file with the internal name and TITLE of ERRORS is created
when the ERRORS compiler option is set. This file is normally used for compilations
initiated through CANDE or IPS, in which case ERRORLIST is set by default and the
ERRORS compiler file is assigned to (or listed at) the remote device involved. When a
syntax error is detected, the offending card image is written to this file, and an error
message is written on the following line of text.
If file equates for ERRORS are present, they are used. Otherwise, if file equates for
ERRORFILE are present, they are used. When file equates for both are present, the
ones for ERRORS are used.
The files XREFDECFILE and XREFREFFILE are created if the compiler control option
XREFFILES is set. These cross reference information files are assigned the TITLEs
XREFFILES/<code file name>/DECs and XREFFILES/<code file name>/REFS,
respectively.
The immediate cross reference information file NEWXREFFILE is also created by the
compiler if XREFFILES (or XREF) is set. If MAKEHOST is set, the file is saved and the
information in it is used in future sepcomps. During a sepcomp, the file XREFFILE
should be label equated to the title of the old NEWXREFFILE.
Input Decks
The following discussion applies to FORTRAN77 compilations that are initiated through
WFL.
If the deck is to contain source input, the system control card images are followed by
a FORTRAN77 or COMPILER, EBCDIC, DATA, or ASCII system control card image,
depending on the form of the source input (EBCDIC and DATA are synonymous), and
this card image is followed by the source input and compiler control cards. If the deck
is to contain input data, then the source card images are followed by the data decks
consisting of an EBCDIC, DATA, or BINARY system control card images, bearing the
TITLE of the data file, followed by the card images bearing the data. If this data is
coded in BINARY format, then the data is terminated by a binary end (BEND) card.
Compile and Go
Compile for Library and Go
The form of the COMPILE system control card image for a compile for syntax is the
following:
The form of the COMPILE system control card image for a compile for library is as
follows:
The code file resulting from a compile for library may be executed by means of a RUN
or EXECUTE system control card. For execution, the only required card images are:
Compile and Go
Compile and go indicates that the object code file resulting from a successful
compilation is to be immediately executed and then discarded.
The form of the COMPILE system control card image for a compile and go follows:
The form of the COMPILE system control card image for a compile for library and go
follows:
If the INCLUDE option is used in the TASKSTRING, it must be the only option in the
string. The included files must consist of valid compiler control images. The options
passed to the compiler through the TASKSTRING are processed after the options read
from the INITIALCCI file, if present, but before any records are processed from the
actual program.
To pass the compiler control options to the compiler using the TASKSTRING task
attribute, append the following to the COMPILE system control card image:
A compiler control option (CCO), formerly referred to as a dollar option, may be used
to affect the way in which the FORTRAN77 compiler compiles and generates code,
input, and output. CCOs are input on a compiler control image (CCI), formerly referred
to as a dollar card.
$
<target option>
<option phrase>
<inclusion option>
<option phrase>
SET <Boolean option>
POP <immediate option>
RESET <value option>
<Boolean option>
SET = <option expression>
<Boolean option>
<list option>
<listdollar option>
<listincl option>
<listinitialcci option>
<long option>
<longlimit option>
<makehost option>
<map option>
<merge option>
<new option>
<newseqerr option>
<omit option>
<omitdebug option>
<onlyansiintrinsics option>
<optimize option>
<own option>
<ownarrays option>
<separate>
<sepcomp option>
<seq option>
<seqerr option>
<statistics option>
<summary option>
<tads option>
<trace option>
<user option>
<v_globaltemps>
<v_report>
<variabletoarray>
<void option>
<warnfatal option>
<warnsupr option>
<xref option>
<xreffiles option>
<inclusion option>
<immediate option>
<value option>
<errorlimit option>
<idlen option>
<sharing option>
<strings option>
<option expression>
The keywords SET, RESET, and POP affect the state of standard options and user
options. Each standard and user option has an associated "stack" in which up to 24
previous values of the option are saved. The management of the current value and the
stack of previous values for the option are described as follows:
Certain <Boolean options> are initially reset and become set by appearing on a CCI,
even if they are preceded by POP or RESET. Once these options become set, they
remain set throughout the compilation. In addition, these options must precede the
first source image. The <Boolean options> with the previously described properties
are MAKEHOST, SEPCOMP, FULLSEPCOMP, CODEFILEINIT and CONVERT. SEPCOMP
and FULLSEPCOMP are mutually exclusive once one is set; that is, once one becomes
set, the other can never become set.
A CCI that consists of only a dollar sign has no effect unless merging, also referred to
as patching, is taking place. (See CCOs MERGE or SEPCOMP for a description of this
process).
A CCI may be commented by using "%" or "!". Anything that follows "%" or "!" is ignored
by the compiler.
Two features are available to pass the compiler an initial set of compiler control
options: The INITIALCCI file and the TASKSTRING task attribute (Refer to Section 16 for
more information on the TASKSTRING attribute.)
Only valid compiler control images may appear in the INITIALCCI file. Dollar signs may
be used in columns 1, 2, or both. The placement of the dollar signs in the INITIALCCI
file, however, has no effect on the new source or listing. A "%" or "!" may appear
anywhere in the file as a comment indicator. Anything that follows the "%" or the "!" on
a line is ignored by the compiler. The following options may not be passed to the
compiler through the INITIALCCI file:
The INITIALCCI file may be referenced by several different compilers. Therefore, in this
file, and only in this file, any compiler control image that begins with a string followed
by a ":" is treated as a comment, unless the string is "FORTRAN77", "BATCH", or
"INTERACTIVE". The following examples illustrate this feature:
String Result
$FORTRAN77: SET LIST FREE Tells the compiler that this image
should be processed by FORTRAN77.
$BATCH: SET LIST FREE Tells the compiler that this image
should be processed if the compile
was initiated through batch mode.
$INTERACTIVE: RESET LIST SET FREE Tells the compiler that this image
should be processed if the compile
was initiated through CANDE.
$JUNK: SET LIST The FORTRAN77 compiler will not
process this image. The image does
not appear in the listing if one is
requested.
The effect of a given CCO in the INITIALCCI file or TASKSTRING is exactly that of the
same CCO placed at the beginning of a program, with the following exceptions:
1. Any option referring to sequence numbers or the new source (CHECK, SEQ, NEW,
NEWSEQERR, INCLNEW) applies only to the program lines. Sequence numbers are
not checked in the INITIALCCI file, the TASKSTRING, or the TASKSTRING included
files. Information from these three sources is not placed in the new source, if one
is requested.
2. Any option referring to the listing generated by the compiler (LIST, DOUBLE,
LISTDOLLAR) applies only to the program lines. A separate option has been
provided to control the listing of the INITIALCCI file: LISTINITIALCCI. The
TASKSTRING always appears in the heading of the listing, if one is requested.
The remainder of this section lists alphabetically the FORTRAN77 compile control
options.
A_SERIES (Set)
A_SERIES is a predefined Boolean option and its state cannot be changed. It is
intended for use by Unisys only.
ANSI (Reset)
When the ANSI option is set, an attempt is made to issue a warning for all
compile-time use of features that are an extension to the ANSI standard. Note that the
use of run-time extensions to the ANSI standard are NOT flagged.
ASCII (Reset)
ASCII is a Boolean option. Setting this option causes all character and Hollerith data to
be interpreted as ASCII characters. Any files declared when ASCII is set are capable of
handling ASCII data. Formatted, list directed, and unformatted I/O also handle the ASCII
characters correctly. Note that namelist I/O is not supported for ASCII data.
The ASCII option may be set or reset on a line-by-line basis; however, care must be
used when changing the setting of the ASCII option. It is the user's responsibility to
ensure than any mixing of ASCII and EBCDIC data is coordinated properly. Files can
handle ASCII data only if the ASCII option is set when the file is declared, implicitly or
explicitly. An explicit file declaration is a file declared via the FILE statement. Implicit
file declarations occur when the compiler encounters a new unit number for the first
time. Unit numbers can appear in I/O statements, auxiliary I/O statements (OPEN,
CLOSE, and so forth), IMPORT statements, or EXPORT statements. If the file is not
declared under the ASCII option, or the program changes the INTMODE of the file, the
results of any I/O operations with ASCII data are undefined. If the file is declared under
the ASCII option, the results of any I/O operations with EBCDIC data are undefined.
Note that the setting of the ASCII option does not affect files that are imported
because the importing program does not determine the attributes of an imported file.
Library subprograms and files must be coordinated for use with ASCII data.
AUTOBIND (Reset)
The AUTOBIND compiler option allows the processes of compiling and program
binding to be combined into one job. During compilation, any line that begins with a
dollar sign ($) and contains as its first word BIND, DONTBIND, EXTERNAL, HOST,
PURGE, STOP, or USE is processed as an instruction to be passed to the Binder. Also,
a Binder control image may be specified via the BINDER compiler option. The
AUTOBIND option may appear only before the first input source statement in the
program.
Setting the AUTOBIND option causes the BINDINFO option to be set automatically.
The programmer may additionally set SEPARATE or LIBRARY. If SEPARATE or
LIBRARY is set, all program units, including any main program, are treated as separate
subprograms, and the host program must come from outside the source file. In such a
case, the host may be specified either via a Binder HOST statement or via file
equation. If neither SEPARATE nor LIBRARY is set, the object code of the source
program acts as the host for any binding that is performed. Specifying a host does not
override the use of this object code as the host.
Two types of control information may be passed to the Binder when using the
autobinding feature: Binder control option images and Binder input statements. Binder
option images are specified by "$ BINDER" followed by the list of options and option
actions. Except for the word BINDER following the dollar sign, the line is written
exactly as if it were a Binder control image input directly to the Binder.
Binder input statements are passed to the Binder by placing a dollar sign before them.
Except for the dollar sign, the input statement is written exactly as if it were input
directly to the Binder. Thus, a semicolon should be included at the end of the
statement.
Note that STATISTICS, TADS, MAKEHOST, SEPCOMP, and FULLSEPCOMP may not be
set when AUTOBIND is set. If any of these options is already set at the time
AUTOBIND is set, the previously set option is turned off and a warning is issued.
Example 1
Suppose the following source file SEPSUBS is compiled:
$ SET LIBRARY
SUBROUTINE SUB1
PRINT *, ENTERED SUB1
END
SUBROUTINE SUB2
PRINT *, ENTERED SUB2
END
$ SET AUTOBIND
$ BIND = FROM OBJECT/SEPSUBS;
PROGRAM MAIN
CALL SUB1
CALL SUB2
CALL SUB3
END
SUBROUTINE SUB3
PRINT *, ENTERED SUB3
END
ENTERED SUB1
ENTERED SUB2
ENTERED SUB3
Example 2
First the following program in file BINDIT is compiled:
$ SET BINDINFO
PROGRAM BINDIT
REAL RESULT, FUN
EXTERNAL FUN
RESULT = FUN (1.5)
PRINT *, RESULT = , RESULT
END
Then the following program is compiled with AUTOBIND and SEPARATE set:
When the preceding source is compiled and run, the following output occurs:
RESULT = 3.0
Also, because SET LIST is specified to the Binder, a Binder listing is generated.
BINDINFO (Reset)
Setting BINDINFO causes the compiled code file to be suitable for use by the Binder.
If the code file is a Binder host file, subprograms written in ALGOL, COBOL, FORTRAN,
or FORTRAN77 itself may be bound into this host, adding to or replacing program units
from the FORTRAN77 host code. The options SEPARATE and LIBRARY set BINDINFO
automatically and produce FORTRAN77 subprograms that may be bound into
FORTRAN77, ALGOL, COBOL, or FORTRAN hosts. A bound-in subprogram serving as a
FORTRAN77 main program must consist of either a true FORTRAN77 main program or
a subroutine (untyped procedure) that has no arguments. See the ClearPath
Enterprise Servers BINDER Programming Reference Manual for more information.
The default value of the BINDINFO option will change to TRUE in a future release.
The BINDINFO option may appear only before the first source input statement in the
program, and its value as then established is retained across any future sepcomps.
BINDINFO may not be set if either STATISTICS or TADS has been set previously. If
BINDINFO is set and the program later sets STATISTICS or TADS, BINDINFO is
automatically reset and a warning is issued. No file compiled with STATISTICS or TADS
set may be used as a Binder host.
When BINDINFO is set, syntax errors for inconsistent subprogram references are
issued even if the references occur in different program units and the subprogram in
question is not actually declared.
Example:
100 $ SET BINDINFO
110
120 SUBROUTINE ONE (D)
130 DOUBLE PRECISION D
140 CALL TWO (D)
150 END
160
170 PROGRAM MAIN
180 LOGICAL L
190 CALL TWO (L)
200 END
CALLBYREFERENCE (Reset)
When CALLBYREFERENCE is not set and a variable or array element appears as an
actual argument (for example, the corresponding dummy argument is a variable), the
argument is passed by value-result. That is, if the value of the dummy argument
changes, the final value of the dummy argument is assigned to the corresponding
actual argument when execution of the subprogram is completed. The only
exceptions are character variable dummy arguments. A change in the value of a
character variable dummy argument is recorded as a change in the value of the
corresponding actual argument at the time of the change rather than at the end of the
subprogram's execution.
If a dummy argument is a type integer variable, the value it assumes when the
subprogram is entered is normally made an integer. This does not apply to call by
reference integer arguments. A call by reference integer dummy argument assumes
the value of the actual argument, even if the actual argument is real.
CHECK (Reset)
The CHECK option causes the compiler source input files and updated source file
NEWSOURCE to be checked for sequence number errors. A sequence error condition
exists when a sequence number on a source card image is less than or equal to the
sequence number on the preceding card image. A warning message is placed on the
output listing when such an error is found. When the CHECK, SEQERR, and
NEWSEQERR options are reset, the compiler performs no sequence checking.
CHECKSUBSTRINGS (Reset)
When the CHECKSUBSTRINGS option is set, the compiler generates code to check
bounds on substrings.
CODE (Reset)
The CODE option causes the output listing to contain the object code generated by
the compiler.
CODEFILEINIT (Reset)
The CODEFILEINIT option is initially reset and becomes set by appearing on a compiler
control image, even if it is preceded by a POP or RESET. Once it becomes set, it
remains set throughout the compilation and remains set in any separate compilations
that may occur later. In addition, the option may appear only on a compiler control
record that precedes the first source input statement.
When this option is specified, the initialization of data areas (arrays, COMMON
storage, and characters) is done only when the data is first referenced and is initialized
from the codefile, provided the size of the data area does not exceed 2**20-1 words at
the time of its initialization. If the size of the data area does exceed 2**20-1 words at
the time of its initialization, then that data area will be initialized at stack building time
and not from the code file. Although this option may cause small programs to run
slower, it is beneficial for large programs that may have many items initialized.
Specifying the option cuts down on the startup time and only those data areas that are
actually used are initialized. Side effects of setting this option are that the compile
time for the program is slightly longer, and the codefile could be much larger.
Not specifying this option causes all the items to be initialized at stack building time.
This method is best for programs that have few initializations and that use most of the
data areas that have been initialized.
Note that the value of CODEFILEINIT in any separate compilation retains the value of
CODEFILEINIT when MAKEHOST is set. Any reference to CODEFILEINIT in a separate
compilation is ignored.
CONVERT (Reset)
The CONVERT option aids in the conversion from old FORTRAN to FORTRAN77. The
CONVERT option must appear before the first FORTRAN source statement, and
cannot be reset. Under this option, certain rules of old FORTRAN hold for FORTRAN77
compilations.
The following is a description of the features that are available in FORTRAN77 under
the CONVERT option.
DO Loops
If CONVERT is specified, but F77DO is not, all DO loops are guaranteed to execute at
least once. For example:
REAL A(5)
DO 100 I=5,1
A(I)=-1.5
100 CONTINUE
WRITE (6,900) A
900 FORMAT (1X,5(1X,F4.1))
Conversion Restrictions
The CONVERT option does not cover all cases where there are differences between
old FORTRAN and FORTRAN77. The following is a list of things that must be changed
before an old FORTRAN program will compile in FORTRAN77.
1. In FORTRAN77 the DATA statement and statement functions must appear after
the specification statements. Statement functions have the additional restriction
that they must come before the first executable statement.
2. Multiple statements per line separated by a semicolon must be put on individual
lines.
3. There must be fewer than 100 continuation lines.
4. The syntax of the PRINT statement has changed. The slash (/) must be replaced by
an asterisk (*); that is, PRINT *, X.
5. In FORTRAN77 an array must be addressed within the declared bounds of the
array.
6. The ZIP statement is not allowed in FORTRAN77. This function can be
accomplished through the use of a LIBRARY routine.
7. A user procedure that has the same name as an intrinsic is not recognized as an
external procedure unless it appears in an EXTERNAL statement in the program
unit that references it.
$COPYBEGIN <s>
$COPYEND <s>
DBLTOSNGL (Reset)
When the DBLTOSNGL option is SET, all DOUBLE PRECISION quantities are treated as
single precision, and all variables declared as type DOUBLE PRECISION are treated as
type REAL. In addition, any referenced intrinsic function that takes DOUBLE PRECISION
arguments or returns DOUBLE PRECISION values is substituted by the compiler with
its corresponding REAL function (for example, SQRT is substituted for DSQRT).
DEBUG (Reset)
The DEBUG option is intended for Unisys use only.
DEFINEDSTMTFUN (Reset)
While the DEFINEDSTMTFUN option is set, statement functions are interpreted as text
substitution instructions. Refer to "Statement Functions" in Section 12 for more
information.
DELETE (Reset)
The DELETE option limits source input. When DELETE is set, only input from file CARD
is compiled; input from the secondary file SOURCE, including compiler control images,
is ignored until DELETE is reset. The ignored input is neither listed nor included in the
updated symbolic file regardless of the states of LIST and NEW. The old FORTRAN
option, VOIDT, is accepted as a synonym for DELETE regardless of the state of the
CONVERT option.
DOUBLE (Reset)
The DOUBLE option alters the format of the compilation listing. When DOUBLE is set,
the listing is DOUBLE spaced; when DOUBLE is reset, the listing is single spaced. The
old FORTRAN option, SINGLE, is accepted as a synonym for the RESET DOUBLE
option.
DOUBLEARRAYS (Reset)
The DOUBLEARRAYS option is used to permit passing arguments of DOUBLE
PRECISION and COMPLEX array data types between FORTRAN77 and other languages.
When a SUBROUTINE, FUNCTION, ENTRY, or IMPORTFROM statement is processed,
the compiler examines the state of DOUBLEARRAYS. If it is set, the compiler attempts
to pass any double precision or complex array arguments to the subroutine or
function as double data descriptors.
In order for a FORTRAN77 program to use an imported library entry point that has
double precision or complex array formal arguments, and is written in another
language, DOUBLEARRAYS must be set when the IMPORTFROM, FUNCTION, or
SUBROUTINE statement for that entry point is compiled. If DOUBLEARRAYS is set and
the library is written in FORTRAN77, then the library must have DOUBLEARRAYS set
when the entry point is compiled.
DOUBLEARRAYS Ignored
A double precision or complex array argument may be passed as a single data
descriptor, even if DOUBLEARRAYS is set, under certain circumstances, described in
the following list. Subprogram refers to the subroutine or function for which
DOUBLEARRAYS is requested (for example, DOUBLEARRAYS is set when the
SUBROUTINE, FUNCTION, ENTRY, or IMPORTFROM statement is processed). Double
precision array is used to refer to either a double precision or complex array.
ALGOL procedure:
$ SET SEPARATE
PROCEDURE ONE(A, B, C, D);
DOUBLE ARRAY A[*]; DOUBLE B;
COMPLEX ARRAY C[*]; COMPLEX D;
BEGIN
...
END;
FORTRAN77 host:
$ SET BINDINFO DOUBLEARRAYS
SUBROUTINE ONE(A, B, C, D)
DOUBLE PRECISION A(2), B
COMPLEX C(2), D
...
END
FORTRAN library:
BLOCK GLOBALS
EXPORT ONE
END
SUBROUTINE ONE(D, C)
DOUBLE PRECISION D(2)
COMPLEX C(2)
END
CALL FREEZE(TEMPORARY)
END
FORTRAN77 program:
$ SET DOUBLEARRAYS
BLOCK GLOBALS
LIBRARY L
IMPORT FROM L (ONE)
END
PROGRAM MAIN
DOUBLE PRECISION D(2)
COMPLEX C(2)
COMMON /COM/ R1, R2, D, R3, R4, C
CALL ONE(D, C)
END
$ SET MAKEHOST
BLOCK GLOBALS
LIBRARY L1, L2
$ SET DOUBLEARRAYS
IMPORT FROM L1 (ONE)
$ RESET DOUBLEARRAYS
IMPORT FROM L2 (THREE)
END
SUBROUTINE TWO
COMPLEX C(2)
CALL ONE(C)
CALL THREE(C)
END
PROGRAM MAIN
COMPLEX C(4)
COMMON /COM/ R1, C % C HAS AN ODD OFFSET
CALL ONE(C)
END
Restrictions
1. Recall that passing a subroutine or function as an actual argument results in any
double precision or complex arrays being passed as single data descriptors.
During a separate compilation deleting any uses of the subroutine or function as
an actual argument does not cause double precision and complex arrays to be
passed as double data descriptors. The declaration and all references to the
subprogram would have to be deleted, and the declaration added on a subsequent
separate compilation, in order to get the double precision and complex array
arguments to be passed as double data descriptors. As with other options,
DOUBLEARRAYS has to be set when compiling a program unit during a separate
compilation in order for it to take effect.
2. If a FORTRAN77 host is to pass double precision or complex arrays to bound-in
subprograms written in other languages, the subprogram must be replacement
bound. The program unit that is going to be replaced by binding must be explicitly
declared with DOUBLEARRAYS set. No references to the program unit should
force any of the double precision or complex array arguments to be passed as
single data descriptors.
ERRORLIMIT [=] n
A limit of 0 indicates that there is no limit on the number of errors allowed. The
ERRORLIMIT CCO is in effect only when it appears on a CCI that precedes the first
source input statement. The old FORTRAN option, LIMIT, is accepted as a synonym for
ERRORLIMIT regardless of the state of the CONVERT option.
Either ERRORS or ERRORFILE can be used when label-equating the error file. ERRORS
is the default INTNAME and TITLE of the file; any file equation of ERRORS takes
precedence over file equation of ERRORFILE. However, if ERRORFILE, but not
ERRORS, is file equated, the file has the INTNAME and default TITLE "ERRORFILE". If
ERRORS (or ERRORFILE) is assigned KIND=DISK, the PROTECTION=SAVE should also
be specified. The old FORTRAN option, ERRLIST, is accepted as a synonym for
ERRORLIST.
EXPRESSIONTOARRAY (Reset)
Within a subprogram, when the first reference is made to a subroutine or function, the
compiler examines the state of EXPRESSIONTOARRAY. If it is set, then for each
reference to that subroutine or function within the subprogram, the compiler treats
any actual arguments that are expressions as single dimension arrays of length one,
where the element in the array has the value of the expression. An expression that is
treated as an array may be passed to a formal argument that is either an array or a
variable without producing a syntax error.
An exception to the rule that the actual argument is treated as an array of length 1
occurs with Hollerith constants. If the actual argument is a Hollerith constant
containing more than four characters, it is treated as an array that is long enough to
accommodate the specified length of the string. For example, the Hollerith constant
8H1234ABCD may be passed to a formal integer array dimensioned two words long.
Using the IMPORT statement may create instances where it cannot be determined
whether a particular formal argument is an array or a variable. If it cannot be
determined from the references, it is assumed to be an array.
Referring to a subprogram that is not explicitly declared may create instances where it
cannot be determined whether a particular formal argument is an array or a variable. If
it cannot be determined from the references, it is assumed to be an array.
Examples
The following example demonstrates VARIABLETOARRAY and
EXPRESSIONTOARRAY. Setting VARIABLETOARRAY allows V to appear as an actual
argument to ONE. Setting EXPRESSIONTOARRAY allows "TEST" to appear as an actual
argument to ONE, and 0 to appear as an actual argument to TWO.
SUBROUTINE TWO(A)
DIMENSION A(1)
...
END
PROGRAM MAIN
CALL ONE(V, "TEST")
CALL TWO(0)
END
$ SET SEPARATE
SUBROUTINE ONE(C)
COMPLEX C(1)
...
END
The previous FORTRAN subroutine may be bound into the following FORTRAN77
program. VARIABLETOARRAY causes CV to be treated as an array, and
DOUBLEARRAYS results in a double data descriptor being passed. Note that
replacement binding must be used with a subroutine or function that requires
DOUBLEARRAYS.
PROGRAM MAIN
COMPLEX CV
COMMON R1, R2, C
...
CALL ONE(CV)
END
$ SET EXPRESSIONTOARRAY
BLOCK GLOBALS
LIBRARY L
IMPORT FROM L(ONE, TWO)
END
PROGRAM MAIN
CALL ONE(0)
END
$ SET EXPRESSIONTOARRAY
PROGRAM MAIN
...
CALL ONE (14HTHIS IS A TEST)
END
SUBROUTINE S2(I)
INTEGER I(2)
...
END
PROGRAM MAIN
CALL S1(8H12345678)
$ RESET HOLLERITHTOCHARACTER
CALL S2(8H12345678)
END
Miscellaneous Notes
1. Program execution time increases when VARIABLETOARRAY or
EXPRESSIONTOARRAY is used. The options should be used only if needed.
2. A variable that appears in a DEBUG MONITOR statement may be treated as an
array as the result of using VARIABLETOARRAY. In such a case, changes that are
the result of the variable appearing as an actual argument are not monitored.
1. Continuation card images must contain a minus sign (-) or asterisk (*) as the first
non-blank character in the first six columns.
2. Comments must have a "C" in column one and a minus sign or asterisk in column
2.
3. For statements with labels, the label must appear in the first five columns.
4. Each free-form statement may contain 66 characters at most, including blanks and
not including sequence numbers. Any characters beyond the 66th character, but
before column 73, are flagged with a warning and ignored.
5. Continuation card images are shifted to the right until the continuation character "*"
or "-" is in column 6. If this shift causes a card image to extend past column 72, and
if there are blanks between the continuation character and the source, the source
is shifted to the left until either the card image no longer extends past column 72
or until the source begins in column 7.
6. Columns 73 through 80 of the source card image are reserved for the sequence
numbers, as in the case of formatted source input.
7. Compiler control images must have a dollar sign ($) in column 1 or a blank in
column 1 with a dollar sign in column 2.
8. FILE statements must have the string FILEbb in columns 1-6 where b represents a
blank.
FREENEW (Reset)
When FREENEW and NEW options are set, the updated symbolic output file
NEWSOURCE is created in a form that can be compiled with FREE set.
FREESOURCE (Reset)
The FREESOURCE option permits the source file SOURCE to be free format. The old
FORTRAN option, FREETAPE, is accepted as a synonym for FREESOURCE regardless
of the state of the CONVERT option.
FREEZEANDGO (Reset)
The FREEZEANDGO option allows a FORTRAN77 program to run both as a normal
program and as a library. When FREEZEANDGO is set the program is frozen as a
permanent library with all entry points available before the main program is executed.
After freezing, the main program is executed normally. If there are still users of the
entry points when the main program finishes, the library becomes a temporary library
and thaws when there are no more users.
As an example, a FORTRAN77 program may export files and common blocks, so that if
the program calls a library, the library may have access to them. The library may use
the files and common blocks, but they actually belong to the program. This means that
the files may be label-equated at run-time and print files are associated with the
program task.
Entry points must be explicitly exported and no call on the FREEZE intrinsic may
appear.
FULLSEPCOMP (Reset)
The only difference between this option and SEPCOMP is that the entire SOURCE file
is read during SEPCOMP. All CCIs found are processed; however, as with SEPCOMP,
only selected procedures are recompiled. Adding this option allows the user to obtain
a complete SOURCE file and listing while doing a SEPCOMP. See the SEPCOMP option
for more information.
HEAP (Reset)
The HEAP option is used to control the allocation of the SAVE or OWN arrays and
variables. Any SAVE or OWN item that is declared or first seen on a record when the
proper option is set is put into a heap. The net result is that only one D2 stack cell is
required for all these variables and arrays, and a user with a large program with many
OWN and/or SAVE items does not exceed the D2 addressing limit of 4096.
The initial state of all the arguments is set. The default value for the HEAP option is
reset. When HEAP is reset, no heaping of items is done, regardless of the state of any
arguments. If HEAP appears without an argument list, the state of the arguments is
unchanged.
If ARRAYS is set, the SAVE and OWN arrays and character variables are put into the
heap. If VARIABLES is specified, the SAVE and OWN variables are put into the heap. If
TEMPORARIES is set, all the temporary arrays are heaped. If ALL is specified, all the
SAVE variables and arrays and temporary arrays are heaped.
HOLLERITHTOCHARACTER (Reset)
HOLLERITHTOCHARACTER is a Boolean option. When a CALL statement is processed,
the compiler examines the state of HOLLERITHTOCHARACTER. If it is set, the
compiler treats any Hollerith constants that appear in the CALL statement as character
constants.
Examples
The following example demonstrates the use of a Hollerith constant as an actual
argument along with the option HOLLERITHTOCHARACTER. In the reference to TWO,
the compiler treats the Hollerith as a character string.
SUBROUTINE ONE(I)
INTEGER I
...
END
SUBROUTINE TWO(C)
CHARACTER *14 C
...
END
PROGRAM MAIN
...
CALL ONE(4H1234)
$ SET HOLLERITHTOCHARACTER
CALL TWO(14HTHIS IS A TEST)
END
SUBROUTINE ONE(I)
INTEGER I(4)
...
END
$ SET EXPRESSIONTOARRAY
PROGRAM MAIN
...
CALL ONE(14HTHIS IS A TEST)
END
IDLEN (31)
The IDLEN option allows the user to specify the maximum length of identifiers. The
proper format of the IDLEN option is the following:
IDLEN [=] n
IMPLICITNONE (Reset)
The IMPLICITNONE compiler control option can be set or reset at any time; however,
the most recently specified value of IMPLICITNONE takes effect only when the first
statement of the next program unit is encountered. If IMPLICITNONE is set, all
variables, arrays, symbolic names of constants, and functions (except intrinsic
functions) must have their types explicitly declared. Setting the IMPLICITNONE option
once at the beginning of a program has the same effect as including an IMPLICIT
NONE statement within every program unit in that program.
INCLNEW (Reset)
The INCLNEW option controls the contents of the updated symbolic file NEWSOURCE.
When INCLNEW and NEW options are set, any source text that is input to the
compiler via the INCLUDE option, is output to file NEWSOURCE. If INCLNEW is reset,
then the INCLUDEd text is not written to the NEWSOURCE file. If the state of the NEW
option is reset, the INCLNEW option is ignored.
where
In the format for the INCLUDE image, m indicates the sequence number of the first
record to be included from the file referenced by this INCLUDE statement. If m is an
asterisk rather than a sequence number, then inclusion begins with either the first
record of the file or the record following the last record included from this file by a
previous INCLUDE statement at the same level as the present INCLUDE statement. If
item m is missing, inclusion begins at the same point indicated by an asterisk. Item n
denotes a one-to-eight digit unsigned integer constant that is the sequence number of
the last record to be included from the file. If this item is missing, records are included
from the file until the end of the include file is encountered.
The item s indicates that a string may be specified as the including delimiter instead of
a range of sequence numbers. The compiler starts searching at the beginning of the
included file for a COPYBEGIN card with a matching string. The compiler includes all of
the records following the matching COPYBEGIN card until a matching COPYEND card
is found, at which time the compiler stops including records from the included file.
The remainder of the included file is never seen by the compiler. Only 17 characters
from the string specified in the INCLUDE statement are used in the search; if the first
17 characters match the first 17 characters on a COPYBEGIN card, the compiler begins
the include. (Refer to "COPYBEGIN and COPYEND" in this section for a description of
these cards.)
The item f denotes the file from which the include records are to be drawn. If this item
is missing from the INCLUDE statement, then the file to be used is the file designated
to be the last INCLUDE statement at that level. An error condition exists if an INCLUDE
statement appears that does not specify a file, and no previous INCLUDE statement at
the same level has specified a file. Thus, the first INCLUDE image at any of the five
possible levels of text nesting must contain either a file TITLE or an internal file name.
A compiler control image bearing an INCLUDE option may contain no other compiler
control options. A warning message is issued for any INCLUDE option that does not
result in the inclusion of records. For example, if an include file is empty or if the
specified range, sequence numbers, or string is not found in the include file, the
compiler does not include any records.
The first example instructs the compiler to accept as input all records from the library
file with internal file name FILE8 that have sequence numbers between and including
00001000 and 09000000. The TITLE and other attributes of the FILE8 file may be
specified on a FILE system control card.
The second example instructs the compiler to accept as input a portion of the file
accessed by the last INCLUDE statement in this deck at this level. The records to be
included consist of all records following the last record accessed by the last INCLUDE
statement at this level. If this example is in the same deck as the first example and no
other INCLUDE statements intervene, the file with internal name FILE8 is accessed and
the first record with the next sequence number after 09000000 is included.
The third example instructs the compiler to accept as input a portion of the file with
the TITLE of SOURCE/XYZ. All records between the last record included from that file
at this level and the record with the sequence number immediately higher than
00000900 are included.
The fourth example instructs the compiler to accept as input a portion of the file with
the internal name INCLFILE. All records in the file between the last record included
from that file at this level and the end of the file are included.
The fifth example instructs the compiler to begin searching INCLFILE from the first
record of the file, for a COPYBEGIN card with "DELIM" as the string. If the compiler
does not find one, it begins including records from the INCLFILE until a COPYEND card
with "DELIM" as the string is found. If the matching COPYEND card is never found, the
remainder of the file is included.
IVDEP (Reset)
The option IVDEP indicates to the compiler that any dependency that is found in the
following DO loop should be ignored. The setting applies only to the first DO
statement encountered when IVDEP is set. Note that the setting of IVDEP at a DO
statement applies to the entire loop, including all loops nested within the DO
statement. IVDEP has no effect unless vectorization is invoked.
LIBRARY (Reset)
LIBRARY is similar to SEPARATE in that it causes all program units to be separately
compiled; however, when LIBRARY is set, all the program units go into a single code
file. The title of the resulting code file is the default title or the title specified in the
COMPILE command.
If the LIBRARY option is set, the SEPARATE option is set by the compiler. When a
compilation is initiated through CANDE and SEPARATE is set, the LIBRARY option is
set by the compiler.
The state of the LIBRARY option cannot be changed after the first source statement is
processed.
The default value of the LINEINFO option will change to TRUE in a future release.
The following is a description of the LINE file records that are produced by setting the
LIST option. Columns that are unspecified are blank.
LISTDOLLAR (Reset)
The LISTDOLLAR option causes all compiler control statements to be included in the
listing if the LIST option is set.
LISTINCL (Set)
The LISTINCL option controls the generation of the LINE compiler file within INCLUDE
files. If LIST is set, resetting LISTINCL suppresses the output of included records to
the LINE file. If LIST is reset, the state of the LISTINCL option has no effect. LISTINCL
may be set and reset as desired within the source input.
LISTINITIALCCI (Reset)
The LISTINITIALCCI option causes the contents of the INITIALCCI file to appear in the
heading of the compiler listing, if generated. This option may appear in the INITIALCCI
file or on any compiler control image before the first input source statement of the
program.
LONG (Reset)
The LONG option alters array storage handling. Normally, arrays requiring more than
1024 words of storage are segmented into 256-word pages for overlay purposes.
Arrays or COMMON blocks that are declared after the LONG option is SET are not
segmented regardless of their storage requirements, unless their length in word units
exceeds either 4096, or the value of n provided in the LONGLIMIT compiler control
option.
LONGLIMIT (4096)
The LONGLIMIT control option is shown as
LONGLIMIT [=] n
where n is an unsigned integer constant and 256 <= n <= 65536. When choosing a
value for n, it should be considered that access to an element of a LONG array is more
efficient than access to an element of a segmented array. However, a large value for n
may result in the need for the allocation of an equally large portion of memory at a
given instant.
The value of n may be altered by successive value assignments to LONGLIMIT, but the
LONGLIMIT compiler option may only appear before the first FORTRAN statement.
The default value for n is 4096.
Arrays declared internally by the compiler are also affected by the use of the
LONGLIMIT and LONG compiler control options. Temporary arrays are declared LONG
regardless of the state of the LONG option, but only if their length does not exceed
the current LONGLIMIT at the time that they are declared. COMMON blocks and
EQUIVALENCE statements comprising arrays are also declared LONG, if and only if
they contain an array that is declared while the LONG option is SET and if the length of
the COMMON or EQUIVALENCE arrays does not exceed the current LONGLIMIT at the
time they are declared.
MAKEHOST (Reset)
The MAKEHOST option instructs the compiler to collect and save certain information
during the current compilation in order to facilitate a separate compilation at a later
time. Refer to the SEPCOMP option for more information.
MAP (Reset)
The MAP option increases the amount of compilation information contained on the
listing. When MAP is set, the listing contains the address couples of items named in
the program being compiled. The displacement portion of the address couple is in
hexadecimal notation. LIST must be set to produce the listing. The old FORTRAN
option, STACK, is accepted as a synonym for MAP regardless of the state of the
CONVERT option.
MERGE (Reset)
MERGE
( <source filename> )
The MERGE option allows the compiler to accept source input from more than one
file. When the MERGE option is set, the compiler accepts source input from the file
CARD. The primary input (from file CARD) is merged with the secondary input (from
file SOURCE) on the basis of sequence numbers to produce the total source input to
the compiler. If matching sequence numbers occur on records from these two files,
the primary input record overrides the secondary input record. When a primary control
card image containing only a dollar sign is encountered, the secondary record with the
same sequence number is ignored. When MERGE is reset, only primary input is
accepted by the compiler.
NEW (Reset)
NEW
( <NEWSOURCE filename> )
The NEW option causes the updated symbolic output file NEWSOURCE to be
generated. When the NEW option is set, the source input from the CARD and, if
MERGE is set, SOURCE files are placed in the file NEWSOURCE. Text inserted into the
source input by the INCLUDE option is placed in the NEWSOURCE file only if the
INCLNEW option is also set. All CCIs in the source input whose dollar sign appears in
column 2 or that have a dollar sign ($) in both columns 1 and 2 are placed on the
NEWSOURCE file when NEW is set.
The NEW option may be set and reset as desired throughout the source input.
The NEWSOURCE file is created despite the occurrence of syntax errors in the source
input.
If the NEW option and the FREE or FREESOURCE options are set concurrently, the
compiler appropriately edits the output of the NEWSOURCE file to ensure that the
updated symbolic is acceptable as either free- or fixed-form input.
NEWSEQERR (Reset)
The NEWSEQERR option allows sequence number error checking to be performed on
the updated symbolic output file as the file is generated. When the NEW and
NEWSEQERR options are set, the updated symbolic file NEWSOURCE is generated
and the sequence numbers on the card images in this file are checked for errors. A
sequence error condition exists when a sequence number on a record is less than or
equal to the sequence number on the preceding record. When such a sequence error
is detected, an error is reported, and the NEWSOURCE file is not saved.
OMIT (Reset)
When the OMIT option is set, records from both CARD and SOURCE files are ignored
by the compiler. They are, however, listed and included in an updated symbolic file.
On a listing the omitted statements are flagged by the word OMIT. See also the VOID
option.
OMITDEBUG (Reset)
When the OMITDEBUG option is set, code generation for DEBUG statements is
inhibited. When code generation is inhibited, specifying DEBUG for the task attribute
OPTION has no effect. With this option, the DEBUG statements may become a
permanent part of a symbolic program: included while the program is being checked
out, and excluded while the program is in production form.
ONLYANSIINTRINSICS (Reset)
All ClearPath Enterprise Server extensions to the list of ANSI standard FORTRAN77
intrinsics are recognized when ONLYANSIINTRINSICS option is reset. If this option is
set, any reference to a ClearPath Enterprise Server intrinsic is treated as an EXTERNAL
SUBROUTINE or FUNCTION reference. In other words, it is treated as though the
intrinsic name appeared in an EXTERNAL statement in that subprogram. The following
intrinsics are affected:
The ONLYANSIINTRINSICS option may be altered at any time; however, only its status
(set or reset) at the time the first statement of a program unit is encountered is
applicable within that program unit.
This option may be used both as an aid in insuring that a program conforms to the
ANSI standard and as a method of using a non-ANSI intrinsic name as a subprogram
name. The latter method is easier than including an EXTERNAL statement in every
program unit that references the subprogram, provided that the non-ANSI intrinsics
are not used.
OPTIMIZE (Reset)
The OPTIMIZE option is used to control optimization. The format is as follows:
ALL
LOOPS
DIVIDE
SEGMENT
EXPRORDER
VECTOR
BLAS
NOALIAS
When OPTIMIZE is set, the optimizations performed depend upon the state of the
arguments. When OPTIMIZE is reset, no optimization is done regardless of the state of
any arguments. The initial state of all arguments is set. The default state for the
OPTIMIZE option itself is reset. If OPTIMIZE appears without an argument list, only the
OPTIMIZE option itself is affected; the state of all of the arguments is unchanged. If an
argument list appears, only those arguments specified are affected. The state of an
argument named in an argument list is set, unless reset has been specified.
Example:
$SET OPTIMIZE ( LOOPS RESET DIVIDE )
OPTIMIZE is SET, LOOPS is SET, DIVIDE is RESET, and the state of all other arguments
remains unchanged.
Setting the argument ALL causes all of the arguments to be set. Resetting the
argument ALL causes all of the arguments to be reset.
When the argument LOOPS is set, the compiler examines DO loops and attempts to
perform various optimizations on the loops. Optimization is attempted if both the
OPTIMIZE option and the LOOPS argument are set at the time the DO statement is
seen. Resetting either OPTIMIZE or LOOPS within a loop does not affect the
optimization of that loop, only of subsequent loops.
Simple variables contained in COMMON or those that are SAVE when HEAP is SET
require indexing code to obtain their value or to store a new value into them. The
optimizer replaces occurrences of these simple variable with a true machine simple
variable, that is a stack cell, within the loop. The true machine simple variable is
initialized with the value of the user's simple variable prior to the loop and if it is
changed within the loop, the resulting value is stored into the user's simple variable
after execution of the loop has been completed. If a variable that is explicitly
equivalenced is changed within the loop, then that variable is not subject to this
optimization.
A use of a variable that does not conform to the ANSI standard may cause
unpredictable results, for example the variable has aliases through passing the same
actual argument to two formal arguments of the same subprogram.
are optimized.
If, as in the preceding examples, no statements remain in the loop when the
assignment is optimized, the loop variable is set to its final value and no other loop
code is necessary. Note that a check for a zero trip count is always performed.
DO loops that do not conform to the ANSI standard either are not optimized or
produce unpredictable results. Optimization of loops containing calls on user- supplied
subroutines or functions may be limited because all arguments and all items in
COMMON or equivalenced to COMMON are considered loop variant. DO loops that
contain GO TOs, IFs, or I/O statements are not considered for optimization.
If it can be determined at compile time that a short DO loop will execute no more than
three times, the loop can be unrolled for quicker execution if the following conditions
apply:
DIVIDE can also effect vectorization. For more information on vectorization, refer to
Section 19.
When LOOPS is set, the user might get unexpected results with affected loops when
running TADS.
The SEGMENT argument is used to control code file segmentation. When SEGMENT is
set, the compiler groups together code from adjacent subroutines into a code
segment. When the end of a code segment is reached, a new segment is started. If
the location of the break causes much branching between code segments, a
performance degradation may be noticed. This may be corrected by resetting
SEGMENT before the beginning of the subroutine or function in which the segment
break occurs. Resetting SEGMENT causes a new code segment to be started at the
beginning of each new procedure or until SEGMENT is set. Grouping code into fewer
code segments results in fewer initial presence bit interrupts, improving performance.
SEGMENT may be set or reset at any time, but it does not take effect until the
beginning of the next procedure.
The EXPORDER argument is used to control the order in which expressions are
evaluated at run time. When either OPTIMIZE or EXPORDER is reset, expressions are
strictly evaluated from left to right. When both OPTIMIZE and EXPORDER are set, an
attempt is made to minimize the number of stack cells required to evaluate the
expression. For example, the expression
B + C *D
C * D + B
Note that use of this option with expressions that do not conform to the ANSI
standard can cause unpredictable results, that is if the expression contains a function
reference that alters the value of another entity in the expression.
The VECTOR argument is used to request the vectorization of DO loops. Note that
vectorization is only done if OPTIMIZE is set, the VECTOR argument is set at the time
the DO statement is encountered, the EXPORDER argument is set for the statement
to be vectorized, and all systems indicated by the TARGET option, or its default value,
support these features.
The NOALIAS argument is used to request that potential aliasing of formal arguments,
items in common, and equivalenced items is to be ignored by the compiler when
vectorizing.
OWN (Reset)
The OWN option affects variables and arrays that are not formal arguments and are
declared or first appear when the OWN option is set. These variables and arrays retain
their values between subroutine calls, just as if they had been included in a SAVE
statement.
OWNARRAYS (Reset)
When the OWNARRAYS option is set, all arrays and character variables (and only
arrays and character variables, unless the OWN option is also set) are treated as if
they had been declared with OWN set. If array reinitialization is not required, a
program can be run faster with OWNARRAYS set. Setting the compiler option
OWNARRAYS causes temporary arrays that are created by the compiler to be moved
to the static global environment. This saves presence bit action when used repeatedly
by a subprogram.
SEPARATE (Reset)
Setting SEPARATE indicates to the compiler that all program units are to be compiled
separately. SEPARATE produces separate code files for each program, subroutine,
function, or block data subprogram, unless LIBRARY is set. These code files may be
bound to a host file via the program BINDER. Refer to the ClearPath Enterprise
Servers BINDER Programming Reference Manual for more information.
The state of the SEPARATE option cannot be changed after the first source statement
is processed. Also, it is not possible to SEPCOMP a program for which SEPARATE has
been set. If MAKEHOST, SEPCOMP, or FULLSEPCOMP is used together with
SEPARATE, a warning is issued stating that the sepcomping option is not permitted
and has been ignored.
A syntax error is issued if SEPARATE is set and a global (COMMON) variable or array
or an OWN variable or array appears as an element of a NAMELIST list in a
subprogram.
When SEPARATE is set, a program unit may use DATA statements with common
block entities only when both of the following conditions are met:
SEPCOMP (Reset)
The purpose of the separate compilation facility (the use of which is referred to as
"sepcomping") is to save time when recompiling programs. Sepcomping allows any file
statement or program unit (referred to as environments) to be deleted, changed, or
added during a successive compilation. Only those affected environments are
recompiled and linked. Three CCOs are provided for sepcomping: MAKEHOST,
SEPCOMP, and FULLSEPCOMP.
MAKEHOST
MAKEHOST
Sepcomping can be done only to a program that has been compiled with MAKEHOST
set. MAKEHOST instructs the compiler to collect and save certain information during
the current compilation in order to facilitate a separate compilation at a later time.
When the MAKEHOST compiler control option is SET, the information that the
compiler saves in order to perform subsequent separate compilations reflects the
structure of the NEWSOURCE file when the option NEW is SET and the CARD file (or
patched SOURCE file when performing a separate compilation) when NEW is RESET.
A user can compile a program with INCLUDE options, set NEW, and perform a
separate compilation against the NEWSOURCE that is produced. MAKEHOST may be
set only before the first FORTRAN77 source image of a full compile. It cannot be set
or reset after the initial setting and cannot be equated to another option. The file for
which MAKEHOST is being requested must be a sequenced file. The default state for
MAKEHOST is set when sepcomping is taking place; otherwise, MAKEHOST is reset.
SEPCOMP
SEPCOMP
( <HOST filename> )
This option informs the compiler that a separate compilation is requested. It must
appear before any FORTRAN77 source images in the primary (CARD) file. SEPCOMP
cannot be set or reset after the initial setting or be equated to another option. When
SEPCOMP is requested, the compiler automatically sets the MAKEHOST option,
thereby allowing repeated sepcomping. The default state for SEPCOMP is reset.
FULLSEPCOMP
FULLSEPCOMP
( <HOST filename> )
The only difference between this option and SEPCOMP is that the entire secondary
(SOURCE) file is read during sepcomp. All CCIs are processed. However, as with
SEPCOMP only selected portions of the program are recompiled. This option may be
used to obtain a complete NEWSOURCE file and listing during sepcomp. SEPCOMP
causes only those portions of the secondary input file that are being recompiled to be
read. If FULLSEPCOMP is used and the LIST option is set, any input that is read, but not
compiled, is marked by the letter "O" in column 114 in the program listing.
User Interface
A request for a separate compilation causes the compiler to distinguish between a
primary input file (CARD) and a secondary input file (SOURCE). The SOURCE input file
is the file originally compiled with MAKEHOST set. The CARD input file is currently
being compiled and has SEPCOMP or FULLSEPCOMP set. During sepcomp, the
primary input file contains patch input images to be applied against the secondary
input file.
The compiler views the secondary input file as being composed of environments. The
information that the compiler retains about each environment is the span of sequence
numbers it encompasses. Based on the sequence number of the input from the
primary input file, the compiler can determine within which environment, if any, the
input record resides. It can then continue compiling from the point where the
environment begins in the secondary input file, merging the input from the primary
input file. Input from the primary input file that does not open any environment causes
the compiler to read and compile the input in the primary input file until an
environment opens up. This latter case is the mechanism by which new environments
program units are added.
Compiler Files
CARD
The CARD file, as in a normal compilation, is the primary input file. During sepcomp, it
contains the FORTRAN77 symbolic images that are applied against the SOURCE file to
create a new executable program. The CARD file may be label-equated to the
compiler file CARD, or the default file named CARD may be used. Note that, just as
with MERGE, a CARD file can be created for use with SEPCOMP by making a patch
against the SOURCE file through SYSTEM/EDITOR.
SOURCE
The SOURCE file is the FORTRAN77 symbolic file that corresponds to the HOST file.
This file may be label-equated to the compiler file SOURCE, or the default file named
SOURCE may be used. During SEPCOMP, the SOURCE file provides the compiler with
the FORTRAN77 symbolic against which the patches specified in the CARD file are
applied; it is the user's responsibility to ensure that the SOURCE and CARD files are
compatible.
HOST
The HOST file is the code file associated with the FORTRAN77 symbolic file (SOURCE).
It may be label-equated, optionally specified immediately following SEPCOMP or
FULLSEPCOMP on the CCI, or the default compiler file HOST may be used. Specifying
with the option takes precedence over the label- equation form. The HOST file is used
to provide environment information concerning the SOURCE file, as well as the source
of all object code that is not recompiled during sepcomp. It is, therefore, extremely
important that the user guarantee the compatibility of the SOURCE and HOST files.
NEWSOURCE
If the NEW option is set, the compiler file NEWSOURCE is generated. For the
SEPCOMP option, this file contains the merged (CARD and SOURCE) input that was
recompiled or added during the current separate compilation. Note that this file does
not necessarily include all of the original symbol, but only those environments that
were recompiled or added. To get a complete file, FULLSEPCOMP should be used.
NEWXREFFILE
If XREF or XREFFILES is set along with MAKEHOST, the compiler file NEWXREFFILE is
generated. This file contains necessary information to keep cross reference
information current and is used in the next separate compilation to obtain an
up-to-date cross reference listing or cross reference files.
XREFFILE
If XREF or XREFFILES is set during a separate compilation, and the file XREFFILE is
present, the compiler checks to ensure that the HOST file and the XREFFILE file
correspond to one another. If they do not, a warning message is produced: all cross
reference information produced, as well as the contents of NEWXREFFILE, reflect only
those environments that are recompiled. If the files do correspond, complete cross
reference information is produced and maintained in NEWXREFFILE, which may be
used as XREFFILE in a subsequent sepcomp.
Sepcomping Examples
The following examples help demonstrate the use of the separate compilation facility.
In each case the first program is compiled with MAKEHOST set allowing for
subsequent sepcomping.
The contents of the CARD file for the FULLSEPCOMP are as follows:
The SOURCE file is label equated to the program that was originally compiled.
The HOST file is label equated to the object file from the program that was
originally compiled.
The NEW option is set, producing a NEWSOURCE file. A listing of that file follows
this CARD file.
The FREESOURCE option is set.
The CARD file from the MAKEHOST is now the SOURCE file to which FREESOURCE
applies. Since it is in free format, FREESOURCE must be used.
The following is a listing of the NEWSOURCE file from the FULLSEPCOMP. This file
may be used as the SOURCE file in a subsequent separate compilation; the object file
produced would be its corresponding HOST file.
The following example helps demonstrate the use of the INCLUDE CCO and
sepcomping. The original program compiled with MAKEHOST set contains three
INCLUDEs. Since NEW is set for the entire compile, the information that the compiler
gathers in order to perform a subsequent separate compilation is based on the
structure of the NEWSOURCE file.
The following listing of the NEWSOURCE file is the SOURCE file for sepcomping. It is
the file that is compatible with the HOST file produced from the MAKEHOST compile.
Notice that it contains two INCLUDEs and the actual records from INCLUDE/3.
INCLNEW was set when INCLUDE/3 was read, but reset when INCLUDE/1 and
INCLUDE/2 were read.
1000 BLOCKGLOBALS
2000 LIBRARY L
3000 END
4000
5000 BLOCKDATA
6000 IMPLICIT CHARACTER (C)
7000 COMMON /R/ A, B, D(10), E, F
8000 COMMON /C/ C1, C2, C3(10)
9000 DATA D /10*1/
10000 DATA C3 /10*"X"/
11000 END
The following is a listing of the CARD file for the SEPCOMP. Note, as a result of
sepcomping ONE, TWO, THREE, and MAIN are recompiled.
0 $ SEPCOMP
3000 $ INCLUDE "INCLUDE/2/NEW."
5600 CALL ONE (A)
2. The type of a function can change during a separate compilation, as well as the
kind of elements in a common block (character versus noncharacter).
3. A program can become a library or vice versa during a separate compilation.
4. The type and number of arguments to a function or subroutine can change during
a separate compilation.
5. A program unit header can be moved to a location at a lesser sequence number
even if its declaration is not deleted on a previous separate compilation.
6. When doing a separate compilation, the HOST file is copied to the CODE file. If
there are syntax errors, the copying is superfluous. The copying of the HOST file is
delayed until it is known that the compile is free of errors. This delay saves
processor time in separate compilations in which there are syntax errors.
7. LINEINFO information is kept current during separate compilations.
8. It is not necessary to touch an environment in order to delete it. Any environments
in the SOURCE file that are not modified, but fall in a range where the DELETE CCO
is set, are deleted.
Example:
10 PROGRAM MAIN from SOURCE file
20 CALL ONE from SOURCE file
30 END from SOURCE file
40 $ SET DELETE from CARD file
50 SUBROUTINE ONE from SOURCE file
60 RETURN from SOURCE file
70 END from SOURCE file
80 $ POP DELETE from CARD file
90 SUBROUTINE ONE from CARD file
100 RETURN from CARD file
110 END from CARD file
In this example, the first declaration of subroutine ONE is deleted by the $DELETE
records.
9. It is no longer necessary for a program to contain a PROGRAM unit (main
program). The PROGRAM unit can be added during a separate compilation.
10. A program unit, which at one time had statistics gathered for it, can cease to have
statistics gathered. This is done by deleting the program unit through a sepcomp,
or by sepcomping in compiler control options.
11. Cross reference information is kept current during a separate compilation. When
the option MAKEHOST is set, and either the option XREF or XREFFILES is set, the
file XREFFILE is produced by the compilation. This file contains the necessary
information to keep cross reference information current during a subsequent
separate compilation. During a sepcomp, the file should be known as XREFFILE.
Restrictions
1. The size of the common block is never reduced. If the overall size of a common
block is reduced during a separate compilation, the array allocated for the
common block is not.
2. One side effect caused by CODEFILEINIT in separate compilations is that
COMMON storage always retains the values from previous compilations. To zero
out a once-initialized area, specifically zero it out in the separate compilation patch.
3. A unit that exists for a program continues to exist for the program even if the FILE
declaration for the unit and all references to the unit have been deleted during a
separate compilation.
4. A FILE declaration for a unit cannot be relocated to a lesser sequence number
unless the FILE declaration was deleted on a previous separate compilation.
5. All symbolic file images must contain sequence field information consisting solely
of numeric data that is ascending and unique. Input from an INCLUDE file must
also be ascending and unique when the options NEW and INCLNEW are both set.
6. CCOs must be set explicitly. While sepcomping, a compiler control image must be
read for the CCOs that it contains in order to have an effect. The following are
exceptions:
a. The value of the SHARING option is retained for subsequent separate
compilations.
b. The value of the statistics output unit and time value for the STATISTICS
option are retained for subsequent separate compilations.
c. The value associated with LONGLIMIT is retained for subsequent separate
compilations. If while sepcomping the LONGLIMIT changes, all arrays at D2 are
made either segmented or long, based on the new value.
d. The value of CODEFILEINIT from the original MAKEHOST is retained. Any
reference to CODEFILEINIT in a separate compilation is ignored.
e. The value of BINDINFO from the original MAKEHOST is retained.
7. Some potential problems arise with the use of CCOs. No restrictions have been
placed on their usage; however, under certain circumstances they do not behave
the same as during a full compile. If these options are used across unit file
boundaries, they could cause the appearance of the NEWSOURCE to differ from
the actual information that the compiler saves for future sepcomping. For
example, with FULLSEPCOMP and SEQ, procedures could be resequenced in the
NEWSOURCE that were not actually recompiled. The information retained in the
CODE file about the sequence numbers for these procedures would be
inconsistent with the NEWSOURCE. As long as CCOs are in effect only within the
boundaries of a compiled environment, they behave correctly. DELETE is an
exception as noted in the other features section.
8. It is not possible to set MAKEHOST, SEPCOMP, or FULLSEPCOMP for a program
that has SEPARATE or LIBRARY set. A warning is issued stating that the option
may not be used.
While compiling subroutine TWO, the compiler found that all of the global references
made were consistent within that program unit. ONE was treated as a subroutine that
took one argument, a variable of type real. After the last program unit is compiled, the
compiler checks that the view which each program unit has of a global is consistent
with the actual declaration for that global. The error message indicates that an
inconsistency was discovered. Messages that are produced as the result of an
inconsistency between a global reference and a declaration consist of two parts. The
first part indicates the name of the global declaration and the sequence number on
which it occurs (ONE AT 100), as well as the program unit that contains the
inconsistent reference or references (TWO AT 150). The next part of the message
describes the nature of the inconsistency.
Even though the reference to THREE at 120 is inconsistent with the reference to
THREE at 210, no message is produced. An error is produced only when the
inconsistency is within a program unit, when an actual declaration exists, or when
BINDINFO is set. If a declaration for THREE was added during a separate compilation,
any remaining inconsistency would generate a syntax error.
Sample Compiles
The following examples demonstrate separate compilations through WFL and CANDE.
In the first two examples, the HOST, SOURCE, and CARD files are being label-equated
to the desired files. The first example is a WFL job deck and the second example is a
CANDE compile (CANDE continuation character = %). The third example, which is also
a CANDE compile, uses the default file names.
SEQ (Reset)
SEQ `
<sequence base option>
`
+ <sequence increment option>
/8\ <digit>
/8\ <digit>
When the SEQ option is set (the option, SEQUENCE, is accepted as a synonym for
SEQ), new sequence numbers are assigned to the records placed in the listing and the
NEWSOURCE file. This option has effect only when LIST or NEW are set. The new
sequence numbers are determined by the current values of the <sequence base
option> and the <sequence increment option>.
When this option is reset, the sequence numbers that appear on the output records
are identical to the sequence numbers on the corresponding records in the input file.
The <sequence base option> contains the sequence number that is to be assigned to
the next source language record when the SEQ option is set. After each record is
sequenced, the value of the <sequence base option> is increased by the value of the
<sequence increment option> or by the default increment of 1000.
The value of the <sequence increment option> is used to increment the <sequence
base option> or the default base of 1000 when records are being sequenced because
the SEQ option is set.
SEQERR (Reset)
The SEQERR option, when set, performs sequence number error checking on the
source input files. A sequence error condition exists when a sequence number is less
than or equal to the sequence number on the preceding card image. When such a
sequence error is found, an error is reported.
SHARING (DONTCARE)
SHARING = PRIVATE
SHAREDBYALL
DONTCARE
SHAREDBYRUNUNIT
The SHARING option is used in a library to specify how user programs share the
library. If sharing is PRIVATE, a separate instance of the library is started for each
program that declares the library. If sharing is SHAREDBYALL, all simultaneous users
share the same instance of the library. If sharing is DONTCARE, sharing is determined
by the MCP. If sharing is SHAREDBYRUNUNIT, then there is one instance of the library
for each stack from which the library is invoked. During a separate compilation, the
value from the previous compile is used unless the value is explicitly changed.
STATISTICS (Reset)
The STATISTICS option format is as follows:
When the program is terminated for any reason (including both normal and abnormal
EOT), the statistics are output to the diagnostic file for the task, unless UNIT=<U> is
specified. UNIT = <U> is the external unit specifier that determines the destination for
output. However, when the diagnostic file is a printer file and the print limit is
exceeded, no statistics are printed.
The external unit specifier may be changed at any time; however, all output is directed
to the unit in effect when the first executable statement of the last compiled program
unit is encountered. If the job is terminated abnormally and the external unit is a
remote file, some of the statistics output may be lost.
In the following example, statistics output would be directed to unit 6 and the time
value is IO. Both timings and frequencies are gathered for MAIN; however, only
frequencies are measured for SUB2. No statistics are gathered for SUB1.
$SET STATISTICS
PROGRAM MAIN
...
END
SUBROUTINE SUB1
$RESET STATISTICS(UNIT=6 RESET TIME ET)
...
END
SUBROUTINE SUB2
$SET STATISTICS (IO)
...
END
If MAKEHOST is set, the statistics output unit and the time value used are retained for
subsequent separate compilations. The separate compilation may respecify the output
unit or time value to be used.
SUMMARY (Reset)
The SUMMARY option generates a minimal compilation listing. When the SUMMARY
option is set and the LIST option is reset, the listing contains only compilation
"heading" and "trailer" information such as the number of images scanned, number of
errors, compilation times, and so on. This trailer information is also generated when
LIST is set.
TADS (Reset)
TADS `
` ( /1\ FREQUENCY )
/1\ REMOTE = <n>
The TADS option is used to compile a program for use with the Test And Debug
System (TADS). This option must occur before the first line of source. It cannot be
used in conjunction with the MAKEHOST, SEPCOMP, FULLSEPCOMP, SEPARATE,
LIBRARY, AUTOBIND, or BINDINFO options. If TADS is set when the program sets
SEPARATE, LIBRARY, AUTOBIND, or a sepcomping option, the TADS option is reset by
the compiler.
The FREQUENCY option allows TADS to determine the frequency and coverage
statistics, as detailed in the ClearPath Enterprise Servers FORTRAN77 Test and
Debug (TADS) System Programming Reference Manual. The REMOTE <n> option
attaches an external remote file, numbered <n> for TADS output. Only one such file
may be specified, and <n> must have a value between 0 and 99 inclusive. If <n> is not
in this range, the compiler reports an error.
TADS has priority over other forms of debugging aids including $SET STATISTICS,
$SET TRACE, and DEBUG. If any of these is encountered after TADS is requested, they
are ignored and a warning message is printed informing the user that only TADS
information is being collected. If TADS is requested after STATISTICS or TRACE, TADS
is turned on and STATISTICS and TRACE are turned off (with the same warning
message). The one exception to this rule is that the warning message is printed only
for the first DEBUG statement. All others are ignored, but no message is given. For
more information about TADS, see the ClearPath Enterprise Servers FORTRAN77
Test and Debug (TADS) System Programming Reference Manual.
`
,
( <secondary identifier> )
<primary identifier>
<secondary identifier>
<target identifier>
The generated code file is optimized for the machines represented by the <primary
identifier>, subject to the compatibility constraints of the machines represented by the
<secondary identifiers>; for example, the code file is optimized for the <primary
identifier>, but no operator is generated that is not supported by all of the <secondary
identifiers>.
If the <target identifier> is a machine, then the target receives the characteristics for
that machine. If the <target identifier> is a LEVEL, then the target receives the most
common characteristics of the machines in that LEVEL.
THIS is a synonym for the <target identifier> of the machine on which the code file is
being compiled.
ALL indicates that the code file must be able to run on all currently supported
machines. Note that the code generated when TARGET=ALL changes as older
machines are dropped and/or new ones are added.
LEVEL0 is presently a synonym for ALL. B7000 is a synonym for the <target identifier>
B7900. LEVEL1 and LEVEL2 encompass the following <target identifiers>: MICROA,
A1, A2, A3, A4, A5, A6, A9, A10, A12, A15, and A17. LEVEL4 encompasses the A16
<target identifier>. Unless you specify a secondary <target identifier> other than A16
or LEVEL4, code files compiled with a primary <target identifier> of either A16 or
LEVEL4 may not run on machines other than the A16.
The TARGET option must be specified prior to the first declaration or statement in the
program. It must be the first option on the card image on which it appears.
The default value for this option is installation defined. Refer to the ClearPath
Enterprise Servers System Command Programming Reference Manual for more
information on the COMPILERTARGET command.
TRACE (Reset)
The TRACE option format is as follows:
`
( )
/1\ UNIT <u> SET
/1\ COMPARE = RESET
DUMP
IO
ALL
CALL
AUXIO
ASSIGN
BRANCH
CONTINUE
The TRACE option may be used to obtain a trace of a program flow in which sequence
numbers and labels of specified statements are output in execution order. This option
is examined before the first executable statement in a program unit is processed. To
obtain any output from the TRACE option, the option must be SET and a unit and some
other arguments must be specified. This option may be altered at any time; however,
only its status (Set or Reset) at the time when the first executable statement of a
given program unit is encountered is applicable within that program unit.
If the COMPARE argument is used, then instead of producing a program flow, the
TRACE option provides the ability to compare the current trace with a previous
program trace in order to detect deviations. Program dumps may be requested should
a mismatch occur.
In the railroad diagram for TRACE, <U> is an external unit specifier. If COMPARE=<U>
does not appear, output from the trace is directed to the unit designated by
UNIT=<U>. If COMPARE=<U> appears, trace comparison occurs and trace output
does not take place; instead, a record is read from the unit designated by
COMPARE=<U> and compared to what would have been the record output from the
correct trace. If the records are the same, then no action is taken. If they are not
identical, a message is output to the unit designated by UNIT=<U>.
The argument DUMP determines the action taken if COMPARE is selected and a
mismatch occurs. The remaining arguments determine which statements should be
selected for the current trace. All arguments are RESET by default. Any of the
arguments may be SET or RESET. Once SET or RESET is specified, it remains in effect
until another SET or RESET is encountered. The arguments have the following effect
when set:
V_GLOBALTEMPS (Set)
The V_GLOBALTEMPS option is used to control the placement of temporary arrays
created by the compiler when vectorization is being performed. It has no effect unless
vectorization is invoked.
When V_GLOBALTEMPS is set, all temporary arrays created by the compiler when
vectorization is being performed are global to the program and are shared among all
routines requiring them. When the option is reset, all temporary arrays are local to the
routine in which they are used. Typically, it is desirable to place them at D2, which is
default. However, for the case of code that is intended to be re-entrant (it is contained
in a library that is shared or it is a routine that will be processed off from an ALGOL
host to which it is bound) or if there is a need to conserve D2 stack space, it may be
desirable or even necessary to place temporary arrays at D3. Note that when the
temporaries are located at D3 (V_GLOBALTEMPS is reset), the actual location is
affected by the compiler control options HEAP, OWN, and OWNARRAYS.
V_REPORT
When the V_REPORT option and the LIST option are set for a source line, a report is
printed of the results of attempting to vectorize the statement on that line and data
dependencies, effecting vectorization, to other lines for which V_REPORT and LIST are
both set. All such reports for a subprogram are grouped together in a single
"vectorization report" printed after the last source line for a subprogram. A
vectorization report for a subprogram is only printed if at least one source line is
printed with a nonblank entry in column 30 (the vectorization result flag) and
V_REPORT is set for that line. For more information on vectorization reports, see
Section 19.
VARIABLETOARRAY (Reset)
Within a subprogram, when the first reference is made to a subroutine or function, the
compiler examines the state of VARIABLETOARRAY. If it is set, then for each
reference to that subroutine or function within the subprogram, the compiler treats
any actual arguments that are variables as single dimension arrays of length one,
where the element in the array has the value of the variable. A variable that is treated
as an array may be passed to a formal argument that is either an array or a variable
without producing a syntax error. For more information and examples, see the
description of the EXPRESSIONTOARRAY option in this section.
VOID (Reset)
The VOID option limits source input. When VOID is set, all input from files CARD and
SOURCE, except CCIs in the CARD file, is ignored by the compiler. The ignored input is
neither listed nor included in the updated symbolic file, regardless of the states of LIST
and NEW. The VOID option may be reset only by a CCI in the CARD file.
WARNFATAL (Reset)
When the WARNFATAL option is set, errors that otherwise would have generated
warning messages are considered syntax errors. The old FORTRAN option, NOWARN,
is accepted as a synonym for the WARNFATAL option.
WARNSUPR (Reset)
The WARNSUPR option, when set, suppresses warning messages. The old FORTRAN
option, SUPRS, is accepted as a synonym for WARNSUPR, regardless of the state of
the CONVERT option.
XREF (Reset)
The XREF option outputs a cross reference of all identifiers used in a compiled
program. The LIST option need not be set to generate a cross reference listing. The
identifiers are arranged according to the EBCDIC collating sequence with lists of
sequence numbers of records on which the identifier appears. XREF may not be set or
reset after the first source statement in the program.
The XREF option may not be used when the SEPARATE option is set. If an attempt is
made to set both SEPARATE and XREF, a warning is issued and the XREF option is
ignored.
XREFFILES (Reset)
The XREFFILES option causes the appropriate files to be created and saved for
INTERACTIVEXREF. Refer to the ClearPath Enterprise Servers System Software
Operations Guide for more detailed INTERACTIVEXREF information. These files have
the following titles:
<code file name> is the name of the code file the compiler is generating. XREFFILES
may not be set or reset after the first source statement in the program.
The XREFFILES option may not be used when the SEPARATE option is set. If an
attempt is made to set both SEPARATE and XREFFILES, a warning is issued and the
XREFFILES option is ignored.
If SYSTEM/EDITOR is used with a source file after cross reference files have been
generated for that file, the XREFFILES may be loaded by specifying LOAD X<code file
name>. Note that if the work file has been compiled through CANDE without including
a source or object file name in the COMPILE command, the <code file name> is of the
form CANDE/CODE<number>. A file directory search under CANDE or
XREFFILES/CANDE shows the name that was used.
A library is a program that provides a set of "entry points," in the form of subprograms,
files, or common blocks, that may be referenced by other programs called "user
programs." Libraries may be created with or referenced by FORTRAN77 programs.
1. Extension of the SAVE data space that is available to a program. (Each library has
its own D2 stack cells available.)
2. Extension of the code space available to a program. (Each library has its own D1
space.)
3. Interlanguage connectivity. (For example, FORTRAN77 user programs can
reference ALGOL libraries, and ALGOL user programs can reference FORTRAN77
libraries.)
4. Simplification of program design, debugging, and maintenance. (Consolidating
logically related program units into a library makes programming easier and
program structure more visible.)
In any given program, FILE statements may either immediately precede a program unit
or appear as the first statements in a BLOCK GLOBALS subprogram. See Section 8 for
the format of the FILE statement.
Creating Libraries
There are three constructs in FORTRAN77 used in creating libraries: the EXPORT
statement, the CALL FREEZE statement, and the compiler control option SHARING.
EXPORT Statement
The non-executable EXPORT statement is used to specify which subroutines,
functions, common blocks, and files are to be provided as entry points to the library
upon execution of the CALL FREEZE statement. EXPORT statements are used only in a
BLOCK GLOBALS subprogram.
,
EXPORT ( <subroutine name> )
<function name> # = <string> &
<common block designator>
# <unit identifier> &
The subroutine or function name, common block designator, or file unit identifier is
known as an entry point designator. A common block designator must include slashes,
for example, /BLK/. A unit identifier must be an integer constant between 0 and 99
inclusive. The <string>, which must be bounded on the left and right by single or
double quotes, indicates the name by which the entry point is to be known to users of
the library. If a <string> is not specified, the exported item is known to users by the
name of its entry point designator.
Exported files need not be declared or referenced elsewhere in the library program,
since their appearance in the EXPORT statement is treated as an implicit declaration.
However, exported common blocks should appear in either a COMMON statement or
an IMPORT statement. If an exported common block is not declared elsewhere in the
program, a warning message is issued.
If 'TEMPORARY' is specified, the library stack remains available only as long as at least
one user is referencing it. A temporary library that is no longer in use unfreezes and
resumes running as a regular program. If 'PERMANENT' is specified, the library stack
continues to exist even if no users are referencing it.
SHARING Option
The SHARING compiler control option specifies the way in which programs may use a
given library simultaneously. The valid forms of the option are SHARING = PRIVATE,
SHARING = SHAREDBYALL, SHARING = DONTCARE, and SHARING =
SHAREDBYRUNUNIT. The default value for SHARING is DONTCARE.
If the value of SHARING is PRIVATE, then every user program uses a separate
instantiation (copy) of the library program. Any changes made to global items in the
library by the program unit invoking the library apply only to that particular user
program. This type of sharing is suitable for any application that, by its nature, services
only one user.
For libraries that are SHAREDBYALL, all simultaneous users share the same
instantiation of the library. Any changes made to global items in the library or by a
program unit that has invoked the library apply to all users of that library. This type of
sharing is suitable for applications that control access to a device or data base, or
applications that provide a collection of functions, such as a math function library.
$ SHARING = DONTCARE
BLOCK GLOBALS
EXPORT (SINE = SIN, COSIN)
END
REAL FUNCTION SINE (X)
REAL X
REAL Y
Y = X
C* PERFORM SINE CALCULATION...
. . . . .
SINE = Y
END
REAL FUNCTION COSIN (X)
REAL X
REAL Y
Y = X
C* PERFORM COSINE CALCULATION...
. . . . .
COSIN = Y
END
C* MAIN PROGRAM
CALL FREEZE (TEMPORARY)
END
Referencing Libraries
On the first executable reference to an entry point of a library, the user program is
suspended. The MCP automatically initiates the library program (if it has not already
been initiated) and sets up a linkage between the library and the user program. The
library program runs normally until it executes a freeze statement, which makes the
entry points available.
User programs access library entry points by using a LIBRARY statement together
with either of two constructs: the IN LIBRARY declaration or the IMPORT statement.
IN LIBRARY is used only with subroutines and functions; IMPORT is used with files
and common blocks as well as subprograms.
Library Attributes
Libraries, like files, have attributes that can be set by a user program. The library
attributes TITLE, INTNAME, LIBPARAMETER, LIBACCESS, and FUNCTIONNAME take
the values of EBCDIC strings. These attributes have the following meanings:
Examples:
LIBRARY LIB (LIBACCESS=BYTITLE,TITLE=OBJECT/F77/LIB)
LIBRARY LIB2 (LIBACCESS=BYFUNCTION,FUNCTIONNAME=F77LIB)
CHANGE (LIB2, FUNCTIONNAME=CHAR8)
(here, CHAR8 is declared CHARACTER*8 and is assigned
MYNEWLIB)
(Installation command)
SL PLOTSUPPORT = *PLOTLIBRARY ON APPL
In file F77/BYINITIATOR/EXAMPLE:
BLOCK GLOBALS
LIBRARY MAINLN (TITLE=OBJECT/F77/MAINLN)
IMPORT FROM MAINLN (CONTRL)
END
PROGRAM START
CALL CONTRL
END
In file F77/MAINLN:
C* Library 1 -- F77/MAINLN
$ SHARING = SHAREDBYRUNUNIT
BLOCK GLOBALS
FILE 6 (KIND=DISK, PROTECTION=SAVE, TITLE=OUTPUT.)
LIBRARY GRAPH (TITLE=OBJECT/F77/GRAPH)
IMPORT FROM GRAPH (G1)
EXPORT (CONTRL, 6=OUTPUT)
END
SUBROUTINE CONTRL
WRITE (6, *) IN CONTRL
CALL G1
END
PROGRAM MAINLN
CALL FREEZE (TEMPORARY)
END
In file F77/GRAPH:
C* Library 2 -- F77/GRAPH
C* This graphics library will import a file for output
C* from the library that referenced it.
$ SHARING = SHAREDBYRUNUNIT
BLOCK GLOBALS
LIBRARY LIB1 (TITLE=DUMMY, LIBACCESS=BYINITIATOR)
IMPORT FROM LIB1 (OUTPUT=6)
EXPORT (G1)
END
SUBROUTINE G1
WRITE (6, *) IN G1 OF GRAPH
END
PROGRAM GRAPH
CALL FREEZE (TEMPORARY)
END
IN LIBRARY Statement
The IN LIBRARY statement is used within a subprogram declaration to indicate that
the subprogram is to be found in a library.
The <library id> name must be declared in a LIBRARY statement within the BLOCK
GLOBALS subprogram. The <string>, which must be bounded by quotation marks,
indicates the actual name of the subprogram in the library.
BLOCK GLOBALS
LIBRARY LIB (TITLE = OBJECT/MATHINTRINSICS)
END
REAL FUNCTION SIN (X)
REAL X
IN LIBRARY LIB
END
REAL FUNCTION COS (X)
REAL X
IN LIBRARY LIB (ACTUALNAME = COSIN)
END
C* MAIN PROGRAM
A = 3.1415927
WRITE (6, *) SIN(A), COS(A)
END
IMPORT Statement
As is the IN LIBRARY statement, the IMPORT statement is used to indicate that
subroutines and functions are found in a library. It may also be used to specify
common blocks and files that are to be imported from a library.
,
@ ( <subroutine name> )
# <string> = & <function name>
<common block designator>
# <unit identifier> &
The library from which a given item or items are to be imported is specified by the
<library id>. This library must be declared via a LIBRARY statement before any
IMPORT statement that uses it. As in the EXPORT statement, a <common block
designator> is an identifier delimited by slashes and a <unit identifier> is an integer
constant in the range 0 to 99. A <subroutine name> or <function name> within an
IMPORT statement is the name given to that subprogram by the IMPORTing program.
In some cases, a unit identifier, subprogram name, or common block designator in the
user program may not match the corresponding entry point designator in the library
program. In such a case, the user must specify a quoted <string> signifying the name
under which the entry point was exported by the library. For example, if library LIB
contains the statement EXPORT (6 = 'OUTPUT'), the user program can reference the
imported file as file number 1 by including the statement IMPORT FROM LIB ('OUTPUT'
= 1). Also, if LIB contains the statement EXPORT (SUB), and SUB is known in the user
program as PROC, the user program can include the statement IMPORT FROM LIB
('SUB' = PROC).
Like subprograms, files and common blocks in the <import list> are implicitly declared
by the IMPORT statement. Imported files may not be explicitly declared via FILE
statements in the user program. Imported common blocks are accessed in
non-BLOCK GLOBALS subprograms via the appropriate COMMON statements. The
maximum size of an imported common block is its maximum size when it was
exported.
Note: The IMPORT method is less verbose than the IN LIBRARY method, but the
IMPORT statement, in itself, gives no information about the nature of the imported
subprogram. The IMPORT method is much more context dependent while the IN
LIBRARY method is more straightforward and explicit. There is, however, a
symmetry between IMPORT statements and EXPORT statements, in that both are
used with the same classes of items: subprograms, common blocks, and files.
Common blocks and files cannot be imported with the IN LIBRARY method.
Example 1
The file RESULT, is created when the files SEARCH/SORT/USER and
SEARCH/SORT/LIBRARY are compiled and the former's object file is executed.
A (unsorted): 3 1 4 1 5 9 2 6 5 3
A (sorted) : 1 1 2 3 3 4 5 5 6 9
4 was found in A(6)
BLOCK GLOBALS
LIBRARY SSLIB (TITLE = OBJECT/SEARCH/SORT/LIBRARY)
IMPORT FROM SSLIB (SEARCH, SORT, 1)
END
LOGICAL ORDER
EXTERNAL ORDER
INTEGER SEARCH, TARGET, I, A(10)
DATA A / 3, 1, 4, 1, 5, 9, 2, 6, 5, 3 /
TARGET = 4
I = SEARCH (TARGET, A, 1, 10)
IF (I .EQ. -1) THEN
WRITE (1, *) TARGET, was not found in A
ELSE
WRITE (1, *) TARGET, was found in A(, I, )
END IF
END
BLOCK GLOBALS
FILE 1 (KIND=DISK, TITLE=RESULT., NEWFILE=.TRUE.)
EXPORT (1, BUBBLE=SORT, LINEAR=SEARCH)
END
DO 10 I = FIRST, LAST-1, 1
DO 20 J = LAST, I+1, -1
IF (.NOT. ORDER (A(J), A(J-1))) THEN
CALL SWAP (A(J), A(J-1))
END IF
20 CONTINUE
10 CONTINUE
END % of BUBBLE routine
C* Linear search for TARGET in A[FIRST...LAST]. Return the index C* into A of the first
such occurrence, or -1 if TARGET is not C* present.
C* Main program...
Example 2
The following two FORTRAN77 programs (in files IMP and EXP) produce the following
output when IMP is run.
Output:
BLOCK GLOBALS
LIBRARY LIB (TITLE=OBJECT/EXP)
IMPORT FROM LIB (/CMN/, OUTPUT=1)
END
PROGRAM MAIN
COMMON /CMN/ A
A = 3
WRITE (1, *) HELLO FROM IMPORTER
END
BLOCK GLOBALS
FILE 6 (KIND=REMOTE)
EXPORT (6=OUTPUT, /CMN/)
END
PROGRAM MAIN
COMMON /CMN/ B, C
B = 1
C = 2
WRITE (6, *) HELLO FROM EXPORTER
WRITE (6, *) B, C
CALL FREEZE (TEMPORARY)
WRITE (6, *) B, C
END
Table 18-1 describes the mapping of FORTRAN77 subprogram arguments onto ALGOL
subprogram arguments:
(ALGOL)
PROCEDURE BLNK(LINE,LNGTH);
VALUE LNGTH;
EBCDIC ARRAY LINE[*];
INTEGER LNGTH;
BEGIN
REPLACE LINE[0] BY "" FOR LNGTH;
END;
Note that a subscript of [0], not [*], should be used in any executable ALGOL
statement that accesses the beginning of the character entity. Also no attempt
should be made to store into the character entity beyond the length that is passed
as an argument.
Example
When the code file for INITIATE/CIRCULAR/LIB is executed, the following is output:
BLOCK GLOBALS
LIBRARY F77LIB (TITLE=OBJECT/F77/LIB)
END
SUBROUTINE ENTER
IN LIBRARY F77LIB
END
CALL ENTER
END
BLOCK GLOBALS
LIBRARY ALGLIB (TITLE=OBJECT/ALGOL/LIB)
EXPORT (SUB, ENTER)
END
SUBROUTINE ENTER
CALL PROC (VAL, VAR)
PRINT *, VAL = , VAL, VAR = , VAR
END
BEGIN
LIBRARY F77LIB (TITLE="OBJECT/F77/LIB.");
PROCEDURE SUB (X, Y);
VALUE X; REAL X, Y;
LIBRARY F77LIB;
FILE OUT (KIND=REMOTE);
PROCEDURE PROC (A, B);
REAL A, B;
BEGIN
WRITE (OUT, //, "ENTERING PROCEDURE PROC...");
A := 0;
B := 0;
% Note that since the first argument to SUB has been
% declared to be by value, the following line has no
% effect on the value of A.
SUB (A, B);
END;
EXPORT PROC;
FREEZE (TEMPORARY);
END.
BLOCK GLOBALS
LIBRARY TASK (TITLE=OBJECT/ALGOL/LIB)
END
REAL FUNCTION TV ()
IN LIBRARY TASK
END
CHARACTER*12 CONT
READ (5, FMT=(A12)) CONT
CHANGE (TASK, LIBPARAMETER=CONT)
WRITE (6, 900) CONT, ABS(TV())
900 FORMAT (2X, A12, IS : , F5.0)
END
BEGIN
TASK LIB1TASK, LIB2TASK;
PROCEDURE DYNLIB1;
BEGIN
REAL PROCEDURE TV;
BEGIN
TV := MYSELF.STATION;
END;
EXPORT TV;
FREEZE (TEMPORARY);
END; % DYNLIB1
PROCEDURE DYNLIB2;
BEGIN
REAL PROCEDURE TV;
BEGIN
TV := MYSELF.PRIORITY;
END;
EXPORT TV;
FREEZE (TEMPORARY);
END; % DYNLIB2
PROCEDURE SELECTIONPROC (LIBPARAMETER, NAMINGPROC);
VALUE LIBPARAMETER;
STRING LIBPARAMETER;
PROCEDURE NAMINGPROC (LIBTASK);
TASK LIBTASK; FORMAL;
BEGIN
IF LIBPARAMETER = "STATION LSN " THEN
BEGIN
IF LIB1TASK.STATUS NEQ VALUE(FROZEN) THEN
PROCESS DYNLIB1 [LIB1TASK];
NAMINGPROC (LIB1TASK);
END
ELSE
IF LIBPARAMETER = "PRIORITY " THEN
BEGIN
IF LIB2TASK.STATUS NEQ VALUE(FROZEN) THEN
PROCESS DYNLIB2 [LIB2TASK];
NAMINGPROC (LIB2TASK);
END;
END; % SELECTIONPROC
REAL PROCEDURE TV;
BY CALLING SELECTIONPROC;
EXPORT TV;
FREEZE (TEMPORARY);
END.
The main objective of the FORTRAN77 features provided for MCP/AS (Extended)
machines is to recognize that multiple iterations of an operation can be performed in
one instruction; this process is called vectorization. In FORTRAN77, a vector is a
series of elements of an array. The elements need not be adjacent, but must occur at
constant intervals.
Vectorizing Statements
Executing a vector operator is equivalent to one instruction performing the operations
on all of the elements, which takes multiple iterations of a conventional FORTRAN DO
loop.
Example
DO 10 I=1,10
10 A(I) = B(I) + C(I)
For the previous conventional loop statement, either of the following statements can
be performed before, after, or at the same time as the other:
The results are the same. Therefore, the statement can be vectorized. However, not
all statements can be legally vectorized.
Example
This loop is not considered for vectorization:
20 JLOC = CHAIN(JOFF+JLOC)
IF (VALUES(JOFF+JLOC).NE.ITEM) GO TO 20
As a rule, programs using linked lists as data structures do not vectorize well since
multiple iterations of loops of linked lists cannot be done in parallel. The compiler must
do each iteration of a loop to determine which array element to access in the next
iteration. In the previous example, JLOC is an index into array CHAIN to get the next
value of JLOC, therefore preventing evaluation of multiple iterations of the loop.
Although the compiler attempts vectorization for DO loops, the loops must meet the
following criteria for their statements to be candidates for vectorization:
A statement may not be vectorized if the compiler can determine that the vectorized
code is not likely to be as fast as standard code. When in doubt, vectorized code is
produced because it is easier to turn off vectorization than to force it on. Various
factors influence this decision, including:
Dependence Theory
Dependence theory is necessary for restructuring programs to increase vectorization.
Definition of Dependence
A dependence exists between two statements, S1 and S2, if S1 must be executed
before S2 to preserve the semantic relationship between the two statements in the
original program.
Data dependence and control dependence completely define the necessary execution
order of statements in a DO loop. When vectorization does not violate a dependence,
the statement can be executed using vector operators.
Data Dependence
Data dependence ensures that variables are used and defined in the proper order.
Flow dependence
S1 is flow-dependent to S2 if S1 defines a variable that is used by S2.
Example
S1: X =
S2: = X
Antidependence
S1 is antidependent to S2 if S1 uses a variable that is defined by S2.
Example
S1: = X
S2: X =
Output dependence
S1 is output-dependent to S2 if S1 defines a variable that is also defined by S2.
Example
S1: X =
S2: X =
The three types of data dependence fully relate the necessary ordering of statements
based on the definition and use of variables. If one of them exists in a FORTRAN
program, the vectorizer must preserve that dependence in the vectorized code.
Control Dependence
Control dependence ensures that a statement is executed in the vectorized program
only if it is executed in the original program.
Example
S1: IF (A(I) .GT. 0.0) GO TO 10
S2: B(I) = C(I) + T
10 CONTINUE
In this example, there is no data dependence between S1 and S2, since data
dependence requires both statements to reference the same variable. However, the
execution of S1 can cause S2 to be skipped; S1 must be executed before S2.
Therefore, there is a control dependence from S1 to S2.
Example 1
DO 60 I = 1,N
A(I) = B(I) + C(I)
D(I) = A(I) * 0.5
60 CONTINUE
Listing the variables that are defined and used by the first two iterations of the loop in
Example 1 allows the dependences that the vectorizer detects to be seen easily.
*
*
*
+,,,,,,-
*
*
*
V
On the first iteration, A(1) is defined by the first statement and used by the second
statement in the loop. Therefore, there is a flow dependence from the first statement
to the second. The flow dependence is also shown by the definition and use of A(2) in
the second iteration. As long as the first statement is executed before the
corresponding iteration of the second statement, the values of array A that are used
by the second statement are correct. No dependence is violated and the statement
can be vectorized.
The following order of the statements from the first two iterations is legal:
A(1) and A(2) are defined before they are used by the second statement. Since the
variables are defined and used in the same order that they were defined and used in
the original program, the new ordering is legal. The result of executing the statements
are the same. Therefore, the dependence for Example 1 shows that the statements
can be vectorized as long as the first statement is executed before the second
statement.
Example 2
DO 70 I = 2,N
A(I) = B(I-1) + C(I)
B(I) = A(I) * 0.5
70 CONTINUE
Listing the variables that are defined and used by the first two iterations of the loop in
Example 2 allows the dependences that the vectorizer detects to be seen easily.
*
*
*
+,,,,,,-
*
*
*
V
*
*
*
+,,,,,,-
*
*
*
V
On the first iteration, A(2) is defined by the first statement and used by the second
statement in the loop. Therefore, there is a flow dependence from the first statement
to the second. On the first iteration, B(2) is defined by the second statement. On the
second iteration, this new value of B(2) is used by the first statement. Therefore, there
is a flow dependence from the second statement to the first. It is impossible to
rearrange these statements to execute multiple iterations of one statement before
the other statement without violating one of the dependences.
These two statements have a cycle of dependences between them. In such cases,
the statements in the cycle cannot be vectorized. The statements and dependences
that form an unvectorizable cycle are called a strongly connected component. The
statements must be treated as a single unit during execution, with one iteration of all
the statements in the strongly connected component being done before the next
iteration is started. It is not possible to do multiple iterations of any of the statements.
If the statements are rearranged to execute more than one iteration of the first
statement before executing the second, the previous value of B(2) is used in the
second iteration. This violates the flow dependence from the second statement to the
first. Rearranging the statements to execute the second statement before the first
violates the flow dependence from the first statement to the second. Since there is no
way to rearrange the statements to do multiple iterations of one statement before the
other, the statements cannot be vectorized. The vectorizer cannot generate vector
code for the statements in Example 2.
Breaking an Antidependence
Antidependences can be broken by saving the value of a variable before redefining it.
Breaking antidependences is the place to start rewriting loops whose statements
form a strongly connected component.
Example
DO 90 I = 1,N
A(I) = B(I)
90 B(I) = A(I+1)
Looking at the dependences for the first two loop iterations of this example shows
the cycle.
*
*
*
4,,,,,,5
*
*
*
V
B(1) = A(2)
*
*
*
4,,,,,,5
*
*
*
V
Second iteration: A(2) = B(2)
*
*
*
4,,,,,,5
*
*
*
V
B(2) = A(3)
From the use of B(1) in the first statement to the definition of B(1) in the second
statement, both on the first iteration
From the use of A(2) in the second statement on the first iteration to the definition
of A(2) in the first statement on the second iteration
Therefore, these statements form a strongly connected component and cannot be
vectorized. However, an antidependence indicates that a previous value of a variable
must be used before that variable can assume a new value. Do this by saving the
previous value in another variable.
DO 90 I = 1,N
T(I) = A(I+1)
A(I) = B(I)
90 B(I) = T(I)
Since the array T is used to save off the values of the array A before they are changed,
the cycle of dependences is now broken and the statements vectorize. The vectorizer
detects dependences as if the first two iterations were as follows:
4,,,,,,,,,,,,,,,-
* *
* *
*
First iteration: T(1) = A(2) *
*
* *
* *
4,,,,,,,,,,,,,,,,5 *
* *
* *
* A(1) = B(1) *
* *
* * *
* * *
* 4,,,,,,5 4,,,,,,,5
* * *
* * *
* V V
*
* B(1) = T(1)
*
*
*
Second iteration: * T(2) = A(3)
*
* *
* *
+,,,,,,,,- +,,,,,,,,,,,,,,-
* *
* *
V *
*
A(2) = B(2) *
*
* *
* *
4,,,,,,5 4,,,,,,,5
* *
* *
V V
B(2) = T(2)
The vectorizer can now rearrange the statements to do multiple iterations without
violating the dependences generated for the rewritten loop, as follows:
T(1) = A(2)
T(2) = A(3)
A(1) = B(1)
A(2) = B(2)
B(1) = T(1)
B(2) = T(2)
Example
DO 100 I = 3,10
B(I) = C(I) * D(I)
100 A(I) = A(I-2) + B(I)
The first statement defines B(I) and the second statement uses B(I), causing a flow
dependence from the first statement to the second. Since there is no dependence
back to the first statement from the second, no dependence cycle includes the first
statement. Therefore, multiple iterations of the first statement can execute in parallel.
The second statement has a flow dependence from its first iteration to its third
iteration, as follows:
DO 101 I = 3,10
101 B(I) = C(I) * D(I)
DO 102 I = 3,10
102 A(I) = A(I-2) + B(I)
Example
DO 110 I = 1,N
B(I) = A(J)
A(I) = C(I) * D(I)
110 CONTINUE
Without further information about the value of variable J in the previous example, the
vectorizer cannot determine the relationship between A(J) and A(I). The following are
the two possible relationships:
If J = N+1, no dependence exists since the second statement never defines A(N+1)
If J = 1, an antidependence exists from the first statement to the second
statement since the first statement uses A(1) before the second statement
defines A(1). A flow dependence also exists from the first iteration of the second
statement to the second iteration of the first statement, since the first statement
uses A(1) on every iteration of the loop.
If the compiler cannot determine the relationship between two references, it assumes
worst-case dependences. In Example 1, if the compiler knows nothing about the value
of J, it assumes both the flow dependence and antidependence exist. Assumptions
like these force the vectorizer to include dependences that may not actually exist.
When writing code to be vectorized, make sure that subscript expressions do not
force the compiler to include worst-case dependences. Use the IVDEP Compiler
Control Option to inform FORTRAN77 that no ambiguous subscript expressions cause
a dependence.
Equivalenced Array
If the vectorizer cannot determine which storage location is being referenced on each
iteration, the compiler must include worst-case dependences, as explained for
unknown array values. The same problem can appear in other forms, such as
equivalenced arrays. When an EQUIVALENCE statement contains arrays, the vectorizer
can have trouble determining whether there is a real dependence or not. The compiler
often makes worst case assumptions about references to arrays that are
equivalenced.
Example
C This example uses an array reference as the subscript
C for another array reference.
DO 112 I = 1,N
112 A(K(I)) = A(K(I))+B(I)
Increment of Zero
When an increment can be zero, the vectorizer must assume that all instances of the
array subscript reference the same storage location. This forces the statements in the
loop to remain scalar.
Example
This example uses a value that is possibly zero for JINC, which is the increment for a
variable in an array subscript expression:
J = JSTART
DO 113 I = 1,N
A(J) = A(J) + B(J)
113 J = J + JINC
The vectorizer can vectorize the loop in the previous example if the loop is rewritten
to push the increment into the DO statement, as follows:
DO 113 J = JSTART,JSTART+N*JINC,JINC
113 A(J) = A(J) + B(J)
The definition of the DO statement requires that the increment be a nonzero value.
The vectorizer can use this extra information to determine that it is legal to vectorize
this statement.
Example
DO 115 I = J,K
115 A(I) = A(I-L(I)) + B(I)
The distance between uses and definitions depends on the values of vector L(I). Since
L(I) changes on each iteration, there is no constant iteration distance between
references to the same array element. Therefore, this statement does not vectorize
and must remain scalar.
Sum Reductions
Sum reductions are the most common special case of vectorization. FORTRAN77 can
vectorize linear (summation), linear absolute value (summation, absolute), and
quadratic (dot product) sum reductions.
Example 1
DO 140 ISUM = 1,N
140 S = S + A(ISUM)
Example 2
DO 150 ISUM = 1,N
150 S = A(ISUM) - S
Example 3
DO 160 ISUM = 1,N
160 S = S + A(ISUM) * B(ISUM)
Example 4
DO 170 ISUM = 1,N
170 S = S + ABS(A(ISUM))
Example 1
DO 160 I = 1,N
160 AMIN = MIN (AMIN, A(I))
Example 2
DO 170 I = 1,N
170 AMAX = MAX (AMAX, A(I))
Example 3
DO 180 I = 1,N
170 AMAX = MAX (AMAX, ABS(A(I)))
Note that the value of each of the following options at the DO statement is used by
the vectorizer throughout the loop: HEAP, IVDEP, OWN, OWNARRAYS, and
V_GLOBALTEMPS.
Enable Vectorization
Vectorization does not occur unless both the OPTIMIZE CCO and its VECTOR argument
are both set and the TARGET of the compile is an MCP/AS (Extended) machine.
For further information on TARGET, see the TARGET compiler control option in Section
17.
Hidden aliasing is the use of a storage location by different variables that is not
declared in an equivalence statement in the local subprogram. Hidden aliasing can
occur because actual arguments are declared in a common block and the same
common block is also declared in the called subroutine or because two actual
arguments are the same item. It can also occur if an array in common is indexed
beyond its declared bound, therefore accessing adjacent common block members.
Hidden aliasing is also when the value of any subscript used to reference an array is
not within the declared bounds for its dimension of the array. Note that these run-time
activities are disallowed by the ANSI standard.
Vector Temporaries
The V_GLOBALTEMPS option is used to indicate to the vectorizer whether or not a
temporary array should be put at D2 or D3. Typically, temporary arrays are put at D2,
which is the default. However, for the case of code that is intended to be re-entrant (it
is contained in a library that is shared or it is a routine that is processed off from an
ALGOL host to which it is bound) or if there is a need to conserve D2 stack space, it
may be desirable or necessary to place temporaries at D3. Note that when the
temporaries are located at D3 (V_GLOBALTEMPS is reset), the actual location is
affected by the compiler control options HEAP, OWN, and OWNARRAYS.
Ignoring Dependencies
When the vectorizer encounters variables with unknown values in subscript
expressions, it is often forced to make worst-case assumptions and generate
dependences that stop vectorization. If it is known that these unknown variables can
never have a value that would prevent vectorization, use the IVDEP (Ignore Vector
DEPendences) CCO to inform the vectorizer that it can ignore all dependences in DO
loops encountered while this option is set.
Example
DO 10 I = J,K
A(I) = B(L)
B(I) = A(I) + C(I)
10 CONTINUE
The relationship between references B(L) and B(I) is ambiguous to the vectorizer. B(L)
could use an element before that element is defined by B(I). It could use an element
before and after B(I) defines it. The two references can be completely unrelated with
B(I) never referring to the same element as B(L). This ambiguity forces the vectorizer
to make worst-case assumptions. However, if the IVDEP CCO is set when the DO
statement in this example is compiled, the compiler ignores all ambiguous
subscripting problems in the DO loop defined by the DO statement and ignores the
possibility of a dependence existing. The loop vectorizes. Be careful when using the
IVDEP directive since FORTRAN77 can ignore a dependence that actually exists; this
could cause unexpected program results. Be certain that there is no dependence
between references in the loop.
Note: IVDEP only applies to the next DO loop encountered and all statements and
DO loops nested within that DO loop.
Example
$$ SET IVDEP
DO 10 ...
DO 20 ...
.
.
.
20 CONTINUE
10 CONTINUE
DO 30 ...
DO 40 ...
.
.
.
40 CONTINUE
30 CONTINUE
In this example, IVDEP applies to the DO 10 and DO 20 loops, but not to the Do 30 and
DO 40 loops.
Example
T = 0.0
DO 10 I = 1,100
S = A(I) * B(I)
C(I) = S + T
10 T = S
In the previous loop, variable T is used before it is defined. Rewriting the loop allows
vectorization, as follows:
If variables S and T are used later in the program, the values they would have had at
loop exit can be assigned outside the loop. Even though the rewritten loop requires
more memory references than the original loop, the vectorization of the loop
significantly speeds up its execution.
Example
DO 10 I = 1,100
C(I) = 0.0
DO 20 J = 1,2
20 C(I) = C(I) + A(J) * B(I,J)
10 CONTINUE
After unrolling the inner loop in this example, the statement vectorizes on the outer
loop, as follows:
DO 10 I = 1,100
C(I) = A(1) * B(I,1) + A(2) * B(I,2)
10 CONTINUE
If the short loop is nested inside other DO loops, you can reorder the loops to achieve
better performance.
There is a start-up time for each vector operator before any results are available. If the
vectorized loop has only two or three elements, it may be faster to leave the loop
scalar. If the vectorized loop is nested within other longer loops, it may be possible to
rewrite the loop to permit vectorization on these longer loops.
Example
DO 10 I = 1,1000
DO 10 J = 1,3
10 A(J,I) = A(J,I) + B(J,I)
The inner loop contains only three iterations. The vectors generated by vectorizing this
inner loop contain only three elements, which is not an efficient use of the vector
operators. Reorder these loops to allow vectorization on the much longer outer loop.
DO 10 J = 1,3
DO 10 I = 1,1000
10 A(J,I) = A(J,I) + B(J,I)
Characte Meaning
r
V Statement was completely vectorized with one or more vector
operators.
P Statement was partially vectorized with a combination of vector
operators and DO loops.
D Statement was not vectorized because it is in a cycle of
dependencies.
N Statement was not vectorized.
U Statement was not vectorized because of one or more
unvectorizable operators or data.
X Statement limits or prevents vectorization of loops in which it is
enclosed. If a DO loop cannot be vectorized because of such a
statement, this character also appears at the DO statement and none
of the loop's statements were considered for vectorization.
E A compiler error prevents vectorization of this statement. This letter
indicates that the compiler failed an internal check; the error should
be reported to Unisys.
The following sample program listing shows examples of the vectorization result
flags. Note that the listing was compressed and truncated to display the fields of
interest.
00002000
DO 2 I = 1, N-1 00002100
V B(I+1) = A(I) + 1. 00002200
D B(I+1) = B(I) + 1. 00002300
V B(I) = A(I+1) + 1. 00002400
D B(I+1) = A(I+1) + 1. 00002500
2 CONTINUE 00002600
00002700
! OPTIMIZE CCO effects 00002800
00002900
$ SET OPTIMIZE (RESET NOALIAS) 00003000
DO 3 I = 1, N 00003100
D B(I) = A(I) + 1. 00003200
3 CONTINUE 00003300
$ SET OPTIMIZE (SET NOALIAS) 00003400
00003500
$ SET OPTIMIZE (RESET EXPRORDER) 00003600
DO 4 I = 1, N 00003700
10 CONTINUE 00006800
00006900
! Vectorizable? recurrences 00007000
00007100
DO 11 I = 1, N 00007200
V R = R + A(I) 00007300
11 CONTINUE 00007400
00007500
DO 12 I = 1, N 00007600
N R = D_OF_R + A(I) 00007700
12 CONTINUE 00007800
00007900
DO 13 I = 1, N 00008000
V R = R + I 00008100
13 CONTINUE 00008200
00008300
DO 14 I = 1, N 00008400
N R = R + D_OF_I 00008500
14 CONTINUE 00008600
00008700
! Loop killer statements 00008800
00008900
X DO 15 I = 1, N 00009000
X IF (I .EQ. 5) GOTO 99 00009100
B(I) = A(I) + 1. 00009200
15 CONTINUE 00009300
99 CONTINUE 00009400
00009500
X DO 16 I = 1, N 00009600
X DEBUG PROGRAMDUMP 00009700
B(I) = A(I) + 1. 00009800
16 CONTINUE 00009900
00010000
X DO 17 I = 1, N 00010100
B(I) = A(I) + 1. 00010200
X WRITE A_NAMELIST 00010300
17 CONTINUE 00010400
00010500
X DO 18 I = 1, N 00010600
B(I) = A(I) + 1. 00010700
X I = 5 00010800
18 CONTINUE 00010900
00011000
! Calls can cause LCV assignments 00011100
00011200
DO 19 J = 1, N 00011300
X CALL KILLER (J) 00011400
DO 19 I = 1, N 00011500
Vectorization Report
Additional vectorization information may be printed by specifying the V_REPORT CCO.
For all statements with both V_REPORT and LIST set, additional information is printed
in a separate report section after the last line of the subroutine. The report is only
printed if at least one printed line has a nonblank vectorization result flag (in column
30).
There are two sections of the report. The first section gives more detail for each line
in the program listing with a vectorization result flag. The second section lists the
dependencies found or assumed by the compiler, effecting vectorization, between
statements with both V_REPORT and LIST set.
For every source program line printed with a vectorization result flag, a line is printed
in the first section. Each line begins with the sequence number of the flagged line (as
printed on the source printout line), followed by a colon, followed by an explanation
for the flag. Note that flagged source lines with a nonsequential series of 'sequence
numbers' can still be matched to lines in the report section because the order of flags
is maintained; that is, the fifth flag in the subroutine listing matches the fifth
explanation in the vectorization report for the subroutine.
The second section of the report is a list of dependencies that may have effected
vectorization. An entry is made of all such dependencies occurring between
statements that both have both V_REPORT and LIST set. There are four columns:
'From', 'To', 'Type', and 'Carried by'. These show: the statement from which the
dependency flows, the statement to which the dependency flows, the type of the
dependency ('flow', 'anti', 'output', 'I/O', and 'call'), and the variables, common blocks,
or equivalence groups which create the dependency. Flow, anti, and output
dependencies are described in this section. I/O and call dependencies are assumed
between I/O statements and between subprogram (subroutine or function) calls to
assure that such statements are executed in the original order to preserve their side
effects.
The variables named in the 'Carried by' column may be simple variables or array
names. If the dependency is carried by a common block or equivalence group, that
name appears first followed by the one or two variables involved in parentheses.
Compiler-supplied names start with a '.': unnamed common is called '.BLNK.', and
equivalence groups have names like '.EQ001'. If there is no name associated with the
dependency carrier, '.noname.' is printed.
For the first occurrence of the vectorization report only, explanations of the two
sections of the report itself are printed.
The printout was compressed and reformatted to display in this manual. Also, the
report explanations are not shown.
========================================================================
V E C T O R I Z A T I O N R E P O R T
========================================================================
When the OPTIMIZE option and its BLAS argument are both set and the TARGET of
the compile is an MCP/AS (Extended) machine, the compiler recognizes the following
BLAS as intrinsics and vector operators are emitted instead of a call on the
user-supplied subprogram.
The BLAS recognized when OPTIMIZE(BLAS) is set are ISET, SSET, DSET, ICOPY,
SCOPY, DCOPY, SSCAL, DSCAL, SVCAL, DVCAL, SADD, DADD, SSUB, DSUB, SAXPY,
DAXPY, SDOT, DDOT, DSDOT, SDSDOT, ISUM, SSUM, DSUM, SASUM, DASUM, IIMIN,
ISMIN, IDMIN, IIMAX, ISMAX, IDMAX, ISAMAX, and IDAMAX. In the discussion of each
of the BLAS, N is the number of elements of the vectors that are affected by the
subprogram, INCX is the increment value for the vector X, and INCY is the increment
value for the vector Y. If the increment value is positive, the elements of the vector
that are affected are: 1, 1+INC, 1+INC*2, 1+INC*3, ..., 1+INC*(N-1), where INC is the
increment. If the increment value is negative, the elements of the vector that are
affected are: 1-(N-1)*INC, 1-(N-2)*INC, ..., 1, where INC is the increment. If the number of
elements is zero, the subprogram returns without affecting any elements of the
vector and if the subprogram is a function, a zero is returned.
SET Subroutines
The SET subroutines set the specified locations of the vector X to the value of the
variable A, that is, X(I)=A where I is the indices of the specified locations of X.
FORTRAN77 recognizes the following SET subroutines:
ISET
SUBROUTINE ISET (N, A, X, INCX)
INTEGER N, A, X(1), INCX
SSET
SUBROUTINE SSET (N, A, X, INCX)
INTEGER N, INCX
REAL A, X(1)
DSET
SUBROUTINE DSET (N, A, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION A, X(1)
COPY Subroutines
The COPY subroutines copy the specified locations of the vector X to the specified
locations of the vector Y, that is, Y(I)=X(J) where I is the indices of the specified
locations of Y and J is the indices of the specified locations of X. FORTRAN77
recognizes the following COPY subroutines:
ICOPY
SUBROUTINE ICOPY (N, X, INCX, Y, INCY)
INTEGER N, X(1), INCX, Y(1), INCY
SCOPY
SUBROUTINE SCOPY (N, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
REAL X(1), Y(1)
DCOPY
SUBROUTINE DCOPY (N, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
DOUBLE PRECISION X(1), Y(1)
SCAL Subroutines
The SCAL subroutines scale the specified locations of the vector X by the value of the
variable A, that is, X(I)=A*X(I) where I is the indices of the specified locations of X.
FORTRAN77 recognizes the following SCAL subroutines:
SSCAL
SUBROUTINE SSCAL (N, A, X, INCX)
INTEGER N, INCX
REAL A, X(1)
DSCAL
SUBROUTINE DSCAL (N, A, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION A, X(1)
VCAL Subroutines
The VCAL subroutines set the specified locations of the vector Y to the values
obtaining by scaling the specified locations of the vector X by the value of the variable
A, that is, Y(I)=A*X(J) where I is the indices of the specified locations of Y and J is the
indices of the specified locations of X. FORTRAN77 recognizes the following VCAL
subroutines:
SVCAL
SUBROUTINE SVCAL (N, A, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
REAL A, X(1), Y(1)
DVCAL
SUBROUTINE DVCAL (N, A, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
DOUBLE PRECISION A, X(1), Y(1)
ADD Subroutines
The ADD subroutines add the variable A to the specified locations of the vector X, that
is, X(I)=X(I)+A where I is the indices of the specified locations of X. FORTRAN77
recognizes the following ADD subroutines:
SADD
SUBROUTINE SADD (N, A, X, INCX)
INTEGER N, INCX
REAL A, X(1)
DADD
SUBROUTINE DADD (N, A, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION A, X(1)
SUB Subroutines
The SUB subroutines subtract the specified locations of the vector X from the variable
A, that is, X(I)=A-X(I) where I is the indices of the specified locations of X. FORTRAN77
recognizes the following SUB subroutines:
SSUB
SUBROUTINE SSUB (N, A, X, INCX)
INTEGER N, INCX
REAL A, X(1)
DSUB
SUBROUTINE DSUB (N, A, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION A, X(1)
AXPY Subroutines
The AXPY subroutines set the specified locations of the vector Y to the values
obtaining by scaling the specified locations of the vector X by the value of the variable
A and adding that to the specified locations of the vector Y, that is, Y(I)=A*X(J)+Y(I)
where I is the indices of the specified locations of Y and J is the indices of the
specified locations of X. FORTRAN77 recognizes the following AXPY subroutines:
SAXPY
SUBROUTINE SAXPY (N, A, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
REAL A, X(1), Y(1)
DAXPY
SUBROUTINE DAXPY (N, A, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
DOUBLE PRECISION A, X(1), Y(1)
DOT Functions
The DOT functions perform the inner product of the specified locations of the vector X
and the specified locations of the vector Y, that is, the summation of Y(I)*X(J) where I
is the indices of the specified locations of Y and J is the indices of the specified
locations of X. FORTRAN77 recognizes the following DOT functions:
SDOT
REAL FUNCTION SDOT (N, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
REAL X(1), Y(1)
DDOT
DOUBLE PRECISION FUNCTION DDOT (N, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
DOUBLE PRECISION X(1), Y(1)
DSDOT Function
The DSDOT function performs the inner product of the specified locations of the
vector X and the specified locations of the vector Y using double precision arithmetic,
that is, the summation of DBLE(Y(I))*DBLE(X(J)) where I is the indices of the specified
locations of Y and J is the indices of the specified locations of X.
DSDOT
DOUBLE PRECISION FUNCTION DSDOT (N, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
REAL X(1), Y(1)
SDSDOT Function
The SDSDOT function returns the sum of the variable A and the inner product of the
specified locations of the vector X and the specified locations of the vector Y (the
inner product is performed using double precision arithmetic), that is, A + the
summation of DBLE(Y(I))*DBLE(X(J)) where I is the indices of the specified locations of
Y and J is the indices of the specified locations of X.
SDSDOT
REAL FUNCTION SDSDOT (N, A, X, INCX, Y, INCY)
INTEGER N, INCX, INCY
REAL A, X(1), Y(1)
SUM Functions
The SUM functions return the sum of the specified locations of the vector X, that is,
the summation of X(I) where I is the indices of the specified locations of X.
FORTRAN77 recognizes the following SUM functions:
ISUM
INTEGER FUNCTION ISUM (N, X, INCX)
INTEGER N, X(1), INCX
SSUM
REAL FUNCTION SSUM (N, X, INCX)
INTEGER N, INCX
REAL X(1)
DSUM
DOUBLE PRECISION FUNCTION DSUM (N, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION X(1)
ASUM Functions
The ASUM functions return the sum of the absolute value of the specified locations of
the vector X, that is, the summation of ABS(X(I)) where I is the indices of the specified
locations of X. FORTRAN77 recognizes the following ASUM functions:
SASUM
REAL FUNCTION SASUM (N, X, INCX)
INTEGER N, INCX
REAL X(1)
DASUM
DOUBLE PRECISION FUNCTION DASUM (N, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION X(1)
IIMIN
INTEGER FUNCTION IIMIN (N, X, INCX)
INTEGER N, X(1), INCX
ISMIN
INTEGER FUNCTION ISMIN (N, X, INCX)
INTEGER N, INCX
REAL X(1)
IDMIN
INTEGER FUNCTION IDMIN (N, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION X(1)
IIMAX
INTEGER FUNCTION IIMAX (N, X, INCX)
INTEGER N, X(1), INCX
ISMAX
INTEGER FUNCTION ISMAX (N, X, INCX)
INTEGER N, INCX
REAL X(1)
IDMAX
INTEGER FUNCTION IDMAX (N, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION X(1)
ISAMAX
INTEGER FUNCTION ISAMAX (N, X, INCX)
INTEGER N, INCX
REAL X(1)
IDAMAX
INTEGER FUNCTION IDAMAX (N, X, INCX)
INTEGER N, INCX
DOUBLE PRECISION X(1)
The railroad diagrams are traversed left to right or in the direction of arrowhead.
Adherence to the limits illustrated by bridges produces a syntactically valid statement.
Continuation from one line of a diagram to another is represented by a right arrow (>)
appearing at the end of the current line and the beginning of the next line. The
complete syntax diagram is terminated by a vertical bar (|).
Items contained in angle brackets (< >) are syntactic variables that are defined in the
manual or are information that the user is required to supply.
Uppercase items not enclosed in angle brackets must appear literally (or as
abbreviated).
Example
/4\ ,
$ <loops> (
The following are some of the syntactically valid constructs that may be generated
from the preceding diagram:
3957 6053003 A1
Railroad Diagrams
Railroad Components
<required items>
No alternate path through the railroad diagram exists for required items or required
punctuation.
Example
REQUIRED ITEM . (
<optional items>
Items shown as a vertical list indicate that the user may make a choice of the items
specified. An empty path through the list allows the optional item to be absent.
Example
REQUIRED ITEM (
<loops>
A loop is a recurrent path through a railroad diagram and has the following general
format:
Example
/1\ ,
The following are some of the valid constructs that may be generated from the
preceding diagram:
The loop must be traversed in the direction in which the arrowhead points; the limits
specified by the bridges cannot be exceeded.
A2 3957 6053003
Railroad Diagrams
<bridges>
A bridge illustrates the minimum or maximum number of times a path may be
traversed in a railroad diagram.
/n\ where n is an integer that specifies the maximum number of times that the
path may be traversed.
/n*\ where n is an integer that specifies the maximum number of times that the
path may be traversed. The asterisk indicates that the path must be
traversed at least once.
Example
/2\ ,
The loop may be traversed a maximum of two times and the path for <optional item
2> must be traversed at least once but no more than twice.
The following are some of the valid constructs that may be generated from the
preceding diagram:
3957 6053003 A3
Railroad Diagrams
A4 3957 6053003
Appendix B
Comparison of FORTRAN/FORTRAN77
Compilers for Unisys A Series
Systems
Statement Ordering
1. In FORTRAN77, data statements must follow specification statements. In the old
compiler data statements may be interspersed with specification statements if
subsequent specification statements do not affect the elements appearing in the
data statement (for example, attempting to change the type of a variable after
assigning an initial value to it).
2. In FORTRAN77, statement function statements must appear after specification
statements and before the first executable statement. In the old compiler the
statement function definition may appear anywhere, as long as it is not referenced
before it is defined.
3. In FORTRAN77, specification statements that specify the symbolic name of a
constant must precede the PARAMETER statement that defines the constant
name. Additionally, the PARAMETER statement must precede all statements using
symbolic names that are defined in the PARAMETER statement. Note that there is
no PARAMETER statement in the old compiler.
3957 6053003 B1
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
New Statements
Block IF ... ELSE IF ... ELSE ... END IF Statements
The IF-THEN-ELSE statement has been included in FORTRAN77. Each IF block must
end with an END IF statement, and branches into an IF block, ELSE IF block, or ELSE
block are prohibited. Otherwise, the IF-THEN-ELSE functions as it does in ALGOL.
INTRINSIC Statement
The INTRINSIC statement allows the passing of intrinsic functions as actual
arguments. A symbolic name must not appear in both an INTRINSIC statement and an
EXTERNAL statement in the same program unit.
PARAMETER Statement
The PARAMETER statement is used to associate a symbolic name with a constant.
Normal type rules apply. Only one assignment per symbolic name in a program unit is
permitted. No implicit or explicit type change is permitted to the symbolic name after
it has appeared in the PARAMETER statement.
PROGRAM Statement
The PROGRAM statement allows association of a symbolic name with the main
program. If the PROGRAM statement appears, it must be the first statement of the
main program. It cannot be the same as the name of an external procedure, block data
subprogram, local name or common block of the same executable program.
SAVE Statement
1. The SAVE statement prevents the specified entities from becoming undefined as
the result of execution of a RETURN or END statement in a subprogram. The
following items are affected by a SAVE statement: variables, arrays, common
block name (enclosed in slashes). A SAVE statement without a list specifies that all
allowed items in that program unit are to be SAVEd.
2. An individual element of a common block may not be specified in a SAVE
statement.
Format
Run-time Formatting
FORTRAN77 allows run time formats to be character variables, character arrays, and
character expressions, in addition to non-character arrays.
B2 3957 6053003
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
A Editing
When using the A edit descriptor with non-character list elements, FORTRAN77 allows
six characters to be stored in word for all non-character types, except INTEGER. For an
INTEGER, only the right-most four characters of the word may contain character data.
Old FORTRAN determined the number of characters per word from the CHARS
compiler control option, regardless of the data type of the list element.
B Editing
1. FORTRAN77 B editing is valid on input only for I, F, E, D, and G edit descriptors and
specifies the interpretation of embedded blanks for subsequent edit descriptors.
2. BN => Blanks are ignored, the input is right justified in its field. A field of all blanks
is interpreted as a zero.
3. BZ => All blanks in succeeding numeric fields are treated as zeros.
Colon Editing
Provides the facility to terminate format control on exhaustion of the input/output list.
G Editing
1. Old FORTRAN allows the G edit descriptor to be used with REAL, INTEGER, or
DOUBLE PRECISION list elements. FORTRAN77 extends this to incorporate
LOGICAL list elements.
2. With the LOGICAL list element (Gw.d) the field occupies w positions, and is edited
with an Lw edit descriptor.
Integer Editing
The I format descriptor is extended in FORTRAN77 to permit specification of a
minimum number of digits that are required to be displayed on output. The form is
Iw.m; the optional m applies to output only and specifies the required number of
digits. 'm' must be less than w. Unsigned output is always produced. If m is zero, and
the value of the data is zero then the field is unconditionally output as blanks.
L Editing
1. New permissible form: the left-most character of the first item may be preceded
by a '.' (for example, '.TRUE', '.TR').
2. The list item is now restricted to type LOGICAL on both input and output. Old
FORTRAN permitted list items of types other than LOGICAL.
Numeric Editing
The interpretation of non-leading blanks is determined by a combination of the "BLANK
=" specifier given when the file was connected, and the BZ or BN blank control in
effect, if any.
3957 6053003 B3
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
Positional Editing
1. The TL and TR edit descriptors have been added to FORTRAN77. TL indicates a
skip to the left (backward) the specified number of characters before transmitting.
TR means skip forward.
2. There is no distinction between TRc and nX formats in FORTRAN77. In the old
compiler the X format acts as a TRc descriptor on input, but on output it BLANKS
the specified number of characters. Note that in the old compiler it does not just
skip.
S Editing
1. The S edit descriptor is an addition to FORTRAN77. It controls optional plus signs
in subsequent numeric output fields (I, F, D, E, G).
2. S => The compiler determines the use of the sign.
3. SP => All subsequent positions that may have an optional plus sign must have it.
4. SS => Inhibits the optional plus.
Specification Statements
DIMENSION Statement
1. Dimensions of actual arrays may be specified by integer constant expressions.
The old compiler restricts dimension bound declarations to constants.
2. Arrays of type CHARACTER are allowed.
EQUIVALENCE Statement
1. In FORTRAN77, if array elements appear in EQUIVALENCE statements, the number
of subscript expressions must equal the number of declared dimensions.
2. CHARACTER entities may be EQUIVALENCed to CHARACTER entities only.
Although there was no character data type in the old language, the old compiler
does allow Hollerith data to be stored into any data type, and therefore to be
equivalent to numeric data types. The FORTRAN77 compiler enforces the
segregation of character and non-character data types in equivalence groups.
COMMON Statement
If a character array or character variable appears in a common block, then all entities in
that common block must be of type character.
B4 3957 6053003
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
Type Statements
CHARACTER Type-statement
1. CHARACTER is a new data type intended to provide the capability to manipulate
character data.
2. The CHARACTER data type applies to arrays, variables and FUNCTION names
(including statement functions).
3. A length specification may specify the length (number of characters) of a character
variable, character array element, or a character function. If a length is not
specified, then the default length of 1 is applied. The length specification is an
integer constant expression; an asterisk (*) may be used if the entity is a dummy
argument or a function.
4. The character assignment statement allows assignment of character values.
Assignment into an entity of smaller size results in truncation from the right.
Assignment into an entity of larger size results in left justification with blank fill.
5. Character substrings are contiguous portions of character data and are made up of
character variables or character array elements.
6. Operations on character data include concatenation of character strings,
substrings, character variables, character array element references, character
constants, and character function references.
7. Character entities may be incorporated in EQUIVALENCE, COMMON, and DATA
statements. Character entities may be equivalent only to other character entities.
Similarly, if a character variable or character array is in a common block, then all of
the entities of the common block must be of type character.
IMPLICIT Statement
FORTRAN77 permits more than one IMPLICIT statement per program unit. The old
compiler allows only one.
EXTERNAL Statement
FORTRAN77 permits a block-data subprogram name to appear in an EXTERNAL
statement. The old compiler does not.
Control Statements
Assigned GO TO Statements
1. The variable representing the label must be defined via an ASSIGN statement in
the same program unit for the FORTRAN77 compiler. In the old compiler, the
ASSIGN could take place outside of the program unit in which the GO TO
appeared.
2. In the old compiler, the optional label list is used for documentation purposes only.
The FORTRAN77 compiler specifies that if the statement label list is present, only
statement labels contained in the label list may be assigned to the variable.
3957 6053003 B5
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
DO Statement
1. An optional comma is now permitted after the terminal statement label, for
example DO 10, I = 1,10.
2. In FORTRAN77, the DO variable may be double precision, with conversion
performed as required. The initial, terminal, and incremental arguments may be
double precision arithmetic expressions. The old compiler restricts the DO variable
and arguments to single precision.
3. In FORTRAN77, the iteration count is tested before execution of any statement
within the range of the DO-loop. Note that the range of the DO-loop is not
necessarily executed at least one time, as it is in the old compiler (the old compiler
performs incrementation processing at the end of the loop). The FORTRAN77
compiler initiates the old FORTRAN DO-loop code when the CONVERT option is
set.
4. The DO variable may not be explicitly redefined within the range of the DO in
FORTRAN77. The old compiler allowed the user to change the value of the
DO-variable within the loop, and for that to affect the number of times the loop
was executed.
5. Transfer of control into the range of the DO-loop is not permitted in FORTRAN77.
The old language allowed what was generally referred to as the "extended range
of the DO" in that the user could branch out of the DO, perform some work, and
then branch back into the DO. The FORTRAN77 compiler does not restrict this;
however, the results are undefined.
STOP Statement
A character constant may be substituted for the integer constant following the STOP
statement.
PAUSE Statement
A character constant may be substituted for the integer constant following the PAUSE
statement.
END Statement
1. An END statement may not be continued in FORTRAN77. In the old compiler an
END statement was treated like any other statement.
2. In FORTRAN77 no other statement may have an initial line that appears to be an
END statement. In the old compiler if the word "END" appears on an initial line,
followed by a continuation line consisting of an assignment to "END", no syntax
error is given.
DATA Statement
In FORTRAN77, the constant list may include names of constants.
B6 3957 6053003
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
Subprograms
Block Data
1. In FORTRAN77, block data subprograms may have an optional symbolic name.
The old language does not permit named block data subprograms.
2. FORTRAN77 permits more than one block data subprogram to appear in an
executable program; however, there may only be one unnamed block data
subprogram per executable program. The old compiler permits more than one.
3. In FORTRAN77, the same named common block may not appear in more than one
block data subprogram. The old compiler permits this.
Entry
1. In FORTRAN77, an entry statement may not appear within the bounds of a block IF
or a DO statement. The old compiler permits an entry point to appear with a DO
statement.
2. Like normal functions, entry points are not required to have arguments in
FORTRAN77. An empty pair of parentheses is used to signify this case.
3. In FORTRAN77, a function or entry point may be of type character. There was no
character data type in the old language.
4. In a function, a variable name that is the same as an entry name may not precede
the appearance of that entry name in an entry statement. The old compiler permits
this.
5. In FORTRAN77, executable statements referencing dummy arguments may
appear only after definition of those dummy arguments; that is, a dummy
argument unique to an entry point may not appear in any statement prior to the
entry point (including statement function definitions). In the old compiler, dummy
arguments to entry points may appear at any point in the program unit. The main
use of this feature is in statement functions defined prior to the entry statement.
Note that this prohibits the use of unique entry point arguments unless the entry
point appears prior to the definition of the statement function.
6. In FORTRAN77, if a dummy argument appears in an executable statement, it is
valid to execute the statement only if the argument is a dummy argument of the
procedure name currently being referenced. In other words, the valid scope of the
dummy argument is the entry point through which the subprogram was entered.
The old compiler allows a reference to the "alien" argument and uses a (default)
value of zero for it.
Functions
1. Intrinsic Functions
a. Generic names have been added to FORTRAN77 to ease referencing intrinsic
functions. When a generic name is used in place of a specific name, the type
of the result returned is determined from the type of the arguments. If
multiple arguments are permitted, then all of the arguments must be of the
same type.
3957 6053003 B7
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
B8 3957 6053003
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
Subroutines
1. In FORTRAN77 an empty set of parentheses may be used in the specification and
calling statement if no arguments are specified.
2. Character dummy arguments are permitted in FORTRAN77.
Character Arguments
1. The length of actual character arguments must be equal to, or greater than, the
length of the dummy argument. Actual arguments are left justified, with truncation
performed as required.
2. The length restriction for character arrays applies to the entire array, not to each
array element. It is necessary only to ensure that the total size of the array is less
than or equal to the actual array.
Input/Output
Files
1. File designators from 0-99 are permitted in FORTRAN77. The old compiler did not
allow file 0.
2. In the old compiler file designators other than 5, 6, or 7 defaulted to tape. The
FORTRAN77 default for these files is disk.
3. In FORTRAN77, if a mnemonic appears in an attribute assignment clause it must
be in quotation marks or apostrophes.
Result Clauses
1. There is no specific "DATA" action specifier in FORTRAN77. The new "IOSTAT"
specifier handles this function.
2. What is referred to as the "result descriptor" in the old language is now handled by
means of an "IOSTAT" specifier. The system-specified information formerly
returned by "RESULT" is now transformed into a nonspecific integer result code.
The IOSTAT specifier may be used in all auxiliary I/O statements. The old compiler
restricts its use to READ and WRITE statements.
3. In FORTRAN77 error branches may be specified in all of the auxiliary I/O
statements. In the old compiler they are permitted only for READ and WRITE
statements.
I/O Statements
1. READ and WRITE
a. In FORTRAN77, the form "n=r", where n is the file designator, and r is the
record designator, is not permitted. The form where "=" is replaced by "'" is
permitted.
b. In FORTRAN77, the unit specifier for internal I/O may be of type character only.
The old compiler permitted the internal file to be a real or integer array.
3957 6053003 B9
Comparison of FORTRAN/FORTRAN77 Compilers for Unisys A Series Systems
c. Only formatted I/O is permitted for an internal file in FORTRAN77. In the old
compiler unformatted I/O could be accomplished to an internal file (array).
d. Internal files in FORTRAN77 have different record properties than those in the
old language, since they contain different data types.
2. Auxiliary I/O Statements
a. In FORTRAN77, all pointer-valued attributes must be mapped to entities of
type character. The old compiler specified that these items map to real or
integer arrays. It also specified that attribute mnemonics appear in any valid
attribute assignment if they are enclosed in quotation marks.
b. In the FORTRAN77 FILE statement, all mnemonics must be enclosed in
quotation marks.
c. In general FORTRAN77 has added language-specific attributes to set and
extract file properties. The most significant of these is "BLANK", which is used
to control the significance of blank characters in numeric formatted input
fields.
d. There is no PURGE or LOCK statement in FORTRAN77. An equivalent of the
PURGE statement is CLOSE(<unit id>,STATUS="DELETE"). The equivalent of
LOCK is CLOSE(<unit id>,STATUS="KEEP").
e. FORTRAN77 specifies that an attempt to use a different title to open an
already opened file has the effect of closing the first file before the open
statement (that is, there has been no explicit close). This was not permitted in
the old compiler.
f. The BLANK attribute may be changed by means of an OPEN statement on a
file that is already in the open state. In the old compiler, a file that has already
been opened may not be opened.
g. FORTRAN77 permits an OPEN on an already open file if all of the file attributes
are the same as the attributes currently in effect. An OPEN of an already open
file in the old compiler is not permitted.
h. FORTRAN77 does not permit the "<file>=<rec>" form of file and record
specifier in the FIND statement.
i. In FORTRAN77, the default state of a file, if no CLOSE statement appears, is as
if a CLOSE with STATUS="KEEP" had been executed (unless SCRATCH was
specified when the file was opened). The old compiler will scratch the file.
j. In FORTRAN77, a backspace is permitted to position a file after the last record
if the prior operation was an Endfile. In the old compiler, a backspace after an
Endfile causes an end-of-file error.
Separate Compilation
FORTRAN77 has a generalized separate compilation facility. Any program unit may be
modified, added, deleted or moved.
Binding
Binding of FORTRAN77 programs is allowed only if the compiler control option
BINDINFO has been set. When AUTOBIND is set along with SEPARATE or LIBRARY, all
program units, including any main program, are treated as separate subprograms; the
host program must come from outside the source file.
Libraries
Libraries can be invoked and written in both FORTRAN 77 and old FORTRAN. In
FORTRAN77, the argument in the CALL FREEZE statement must appear in single or
double quotes.
Zip
The ZIP statement (independent process) is not available in FORTRAN77.
CHARS
GRAPH
INSTALLATION
MONITOR
NEWSEGMENT
NOBINDINFO
OPT
PRINTER
READER
SEGS
TIME
Compiler Files
1. The secondary input file in FORTRAN77 has been changed from TAPE to SOURCE.
2. The internal file name of the updated symbol file produced when both the NEW
and MERGE options are set is NEWSOURCE in FORTRAN77. The name is
NEWTAPE in the old compiler.
Optimization
The FORTRAN77 compiler performs extensive local (statement level) optimization by
default. There is a global optimization option, and the local optimization that is
performed is not under user control.
Debugging Aids
The syntax of the DEBUG statements differ from old FORTRAN. See Section 14 for the
FORTRAN77 syntax. FORTRAN77 supports debugging using the Test and Debug
System (TADS). Refer to Section 17 for more information on TADS.
The error messages contained in this appendix are normal compiler output messages
that occur when the FORTRAN77 compiler detects an error in program code. These
errors are listed in alphabetic order, with special characters, symbols, and numbers
preceding the usual alphabetic sequence.
3957 6053003 C1
Error Messages
C2 3957 6053003
Error Messages
3957 6053003 C3
Error Messages
C4 3957 6053003
Error Messages
<string> THAT CONTAINS THE <type> <class> <name> HAS BEEN MADE
INTO A LONG ARRAY BECAUSE IT WILL CAUSE AN ODD OFFSET THAT
WILL OVERLAP A SEGMENT BOUNDARY. IF THIS CAUSES A
PERFORMANCE PROBLEM, THE DATA AREA SHOULD BE REMAPPED TO
ELIMINATE THE ODD OFFSET.
A COMMON block or EQUIVALENCE area will span multiple segments when the item
named is added. The item is either DOUBLE PRECISION or COMPLEX and the second
word does not fit in the segment. The area is made LONG to contain the item. A single
precision item added before the item in error will start the item in a new segment.
<string>, WHICH HAS BEEN MADE INTO A LONG ARRAY, EXCEEDS THE
SYSTEM LIMIT OF 65535 WORDS FOR A LONG ARRAY. REMAP THE DATA
AREA TO ELIMINATE THE ODD OFFSET DESCRIBED ABOVE AND
RECOMPILE.
A previous message described that the data area (COMMON block or EQUIVALENCE
group) was made into a long array because a double precision variable caused an odd
offset that would overlap a segment boundary. To eliminate this error, the data area
must be remapped so that no double precision item whose first word is offset an odd
number of words from the beginning of the data area spans a segment boundary. (It is
sufficient to remap the area so that all double precision items are offset an even
number of words from the beginning of the data area.) Alternately, the data area may
be made smaller by assuring that all declarations of the data area consume less than
65536 words; possibly by splitting the data area into two or more areas.
3957 6053003 C5
Error Messages
C6 3957 6053003
Error Messages
3957 6053003 C7
Error Messages
A control statement (other than logical if, block if, and do) prevents
vectorization of its enclosing loop.
This message should only appear in a vectorization report (V_REPORT compiler control
option set).
C8 3957 6053003
Error Messages
3957 6053003 C9
Error Messages
A SPECIFIER MAY ONLY APPEAR WITHOUT THE '<spec> =' PART AS THE
FIRST OR SECOND ITEM IN THE CONTROL INFORMATION LIST.
Items in the control information list may be specified by 'Spec = value' or by its
position in the list. The first position is reserved for the unit number and the second
position for the format specification. All other items must be specified with the 'Spec
= value' form to identify them.
COMMA EXPECTED.
Two edit descriptors in the FORMAT specification were not separated by a comma.
COMMA EXPECTED.
A comma was expected in the TARGET.
EMPTY FILE.
An end-of-file was encountered when trying to read the file. Check the source file to
find where the records exist.
INVALID STRING.
The string used for the FORMAT specification cannot be understood. Refer to Section
9 of this manual for a description of FORMAT specification strings.
INVALID UNIT.
An invalid unit identifier is specified in the DEBUG DUMP statement. It must be a unit
number, variable name, or an asterisk.
LIST DIRECTED I/O ('*' FORMAT) MAY NOT APPEAR WITH A RECORD
NUMBER.
A format specification must be used when writing a record to a specific location on
the file.
More than one scalar loop would have to be created to vectorize this
statement.
This message should only appear in a vectorization report (V_REPORT compiler control
option set).
NO INITIAL CARD.
A continuation line was specified, but there is no preceding line to be continued. If
using free-form input (see the $FREE option), a continuation line begins with an
asterisk (*) or minus sign (-). Otherwise, a non-blank character other than zero (0) in
column 6 indicates a continuation line.
THE 'LIBRARY' OPTION WILL REMAIN SET WHEN SEPARATE IS SET AND
THE COMPLETION IS INITIATED THROUGH CANDE.
The LIBRARY option is automatically set when the SEPARATE option is set if the job is
initiated through CANDE. It cannot be reset if SEPARATE is set. When initiated through
CANDE, only one code file is produced and the LIBRARY and SEPARATE options
perform the same function. For more information on the LIBRARY and SEPARATE
compiler control options, see Section 17 in this manual.
THE ONLY ATTRIBUTES ALLOWED FOR THIS STATEMENT ARE UNIT, ERR,
AND IOSTAT.
A specifier appeared in the control information list that is not allowed for the
BACKSPACE, ENDFILE, REWIND, or FIND statement. General attributes for files should
be specified in the OPEN or FILE statement.
THE REPEAT CONSTANT BEFORE THE '*' IN AN INITIAL VALUE LIST MUST
BE A NONZERO UNSIGNED INTEGER.
The number preceding the asterisk (*) indicates the number of times the value
following it is to be repeated. It must be an integer constant greater than zero.
THE XREFFILE IS NOT COMPATIBLE WITH THE HOST FILE -- THE COMPILER
WILL NOT ATTEMPT TO PRODUCE UP-TO-DATE CROSS REFERENCE
INFORMATION.
The XREFFILES option will only produce a cross reference for a separately compiled
program if the current cross reference file matches the host cross reference file.
Because they do not match, no new cross reference is created.
WHEN THE 'FMT =' PART OF THE FORMAT SPECIFIER DOES NOT APPEAR,
THE FORMAT SPECIFIER MUST BE THE SECOND ITEM IN THE LIST. THE
UNIT SPECIFIER MUST BE THE FIRST ITEM IN THE LIST AND MUST
APPEAR WITHOUT THE 'UNIT =' PART.
The format specification in the control information list was specified incorrectly.
Precede the specification by the specifier FMT=.
ZERO WILL BE USED FOR THE ABOVE NUMBER, WHICH IS TOO SMALL TO
REPRESENT AS A SINGLE PRECISION, NON-ZERO NUMBER; THE LOWER
BOUND IS APPROXIMATELY 8.8E- 47.
This number is so small there is no representation for it available on this machine in
single precision. Zero will be used instead. Use double precision for greater precision.
T vectorization, 19-1
vectorization of loop statements, 19-2
vectorization report, 19-22, 19-23
TASKSTRING task attribute, 16-9
vectorization result, 19-18
TYPE statement, 4-5
vectorization result flag, 19-18
type statements, B-5
U Special Characters
$ edit descriptor, 9-20
unavailable edit descriptors in
FORTRANN77, B-4
unit, 8-3
unit specifier, 8-5
urgent specifier, 8-10
V
variable, 2-11, 15-2
name, 2-11
type, 2-11
*39576053-003*
3957 6053003