1 09/28/82  fortran_77.differences.info
  2 
  3 This info segment describes the differences between the languages
  4 accepted by the Multics FORTRAN compiler under the ansi66 and ansi77
  5 options.  The implementation of FORTRAN 77 is not yet complete, so
  6 this list of differences may grow with future releases.  The
  7 differences described in the following paragraphs are:
  8 
  9 
 10           zero trip DO loop
 11           character array layout
 12           unformatted file layout
 13           data type restriction for common and equivalence
 14           substring references
 15           concatenation
 16           assumed size character strings
 17           default character string length
 18           descriptors for character arguments
 19 
 20 
 21 zero trip DO loop:
 22 Under the ansi77 option, the semantics of the DO statement have been
 23 changed to conform with the FORTRAN 77 standard.  This new
 24 interpretation differs from the ansi66 DO statement in two ways.
 25 
 26 The first and most important difference is that the range of a DO loop
 27 may be executed zero times.  That is, the statements which comprise
 28 the loop may be skipped altogether.  For example, the range of the
 29 statement
 30           DO 300 I = M1, M2, M3
 31 will be skipped if M1 > M2 and M3 > 0, or if M1 < M2 and M3 < 0.  If
 32 the range is not executed, the DO variable has the initial value (M1).
 33 Under the ansi66 option, the range of a DO loop is always executed at
 34 least once.
 35 
 36 The second difference is that the increment value (M3 in the statement
 37 above) is saved at the time the DO statement is encountered, and this
 38 saved value is used to increment the DO variable.  Under the ansi66
 39 option, the increment value may be changed within the loop if it is a
 40 simple variable or array element.
 41 
 42 
 43 Example:
 44           N = 0
 45           DO 200 I = 1, 10
 46           J = I
 47           DO 200 K = 5, 1
 48           L = K
 49      200  N = N + 1
 50      201  CONTINUE
 51 
 52 If the above statements are compiled under the ansi77 option and
 53 executed, the result is I = 11, J = 10, K = 5, and N = 0.  The value
 54 of L is not defined.
 55 
 56 If the same statements are compiled under the ansi66 option and
 57 executed, the result is I = 11, J = 10, K = 6, L = 5, and N = 10.
 58 
 59 
 60 character array layout:
 61 Under the ansi77 option, character data in Multics FORTRAN conforms to
 62 the FORTRAN 77 standard.  The most significant difference from
 63 character data under the ansi66 option is that character strings are
 64 unaligned, i.e. not necessarily beginning on a word boundary.  This
 65 distinction is most important in dealing with arrays of character
 66 data: each array element now immediately follows the preceding one
 67 with no intervening pad characters.  In the old (ansi66)
 68 implementation of character data, each array element is aligned on a
 69 word boundary by preceding the array element with 0 to 3 pad
 70 characters.
 71 
 72 
 73 Example:
 74 Consider the array aleph, declared as follows:
 75 
 76           character*3 aleph (4)
 77 
 78 In the old (ansi66) implementation, aleph is represented in storage as
 79 follows:
 80 
 81  --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 82 |   |   |   |XXX|   |   |   |XXX|   |   |   |XXX|   |   |   |XXX|
 83 |            XXX|            XXX|            XXX|            XXX|
 84 |   |   |   |XXX|   |   |   |XXX|   |   |   |XXX|   |   |   |XXX|
 85  --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 86 [ aleph (1) ]   [ aleph (2) ]   [ aleph (3) ]   [ aleph (4) ]
 87 
 88 In the new (ansi77) implementation, aleph is respresented as follows:
 89 
 90  --- --- --- --- --- --- --- --- --- --- --- ---
 91 |   |   |   |   |   |   |   |   |   |   |   |   |
 92 |               |               |               |
 93 |   |   |   |   |   |   |   |   |   |   |   |   |
 94  --- --- --- --- --- --- --- --- --- --- --- ---
 95 [ aleph (1) ]           [ aleph (3) ]
 96             [ aleph (2) ]           [ aleph (4) ]
 97 
 98 
 99 unformatted file layout:
100 As a result of the new storage layout for character data with the
101 ansi77 option, the format of data read and written by unformatted I/O
102 statements has also changed.  Unformatted files which contain
103 character data written by an ansi66 program may be read (and
104 converted, if desired) using the technique described in
105 fortran_77.conversion.info.  Only unformatted files containing
106 character data are affected by this change.
107 
108 
109 data type restriction for common and equivalence:
110 Under the ansi77 option, a new restriction on the types of variables
111 that may appear in common blocks and equivalence groups is imposed.
112 If any of the items in a common block or equivalence group are
113 character data, all items in that common block or equivalence group
114 must be character data.  In other words, character and non-character
115 data may not be mixed in the same common block or equivalence group.
116 
117 
118 substring references:
119 Substring references are available under the ansi77 option.  A
120 substring reference specifies a contiguous section of a character
121 variable or character array element, and may appear in any context
122 that a character variable or array element may appear.  The form of a
123 substring reference is:
124 
125           var (first : last)
126 or        arr (sub1, ..., subn) (first : last)
127 
128 where var is a character variable, arr is a character array, and
129 (sub1, ..., subn) is the subscript information for an array reference.
130 The items first and last are integer valued expressions; first gives
131 the index of the first character included in the substring, and last
132 gives the index of the last character included in the substring.  If
133 first is omitted, 1 (the first character) is assumed; if last is
134 omitted, the length of the string (the last character) is assumed.
135 The substring reference is in error unless the following relation is
136 satisfied:
137 
138           1 <= first <= last <= length of string
139 
140 
141 Examples:
142 In the following examples, suppose atoe is a character*5 variable with
143 the value "abcde".
144 
145           atoe (3:5)          "cde"
146           atoe (2:2)          "b"
147           atoe (3:2)          ERROR
148           atoe (:)            "abcde"
149 
150 
151 concatenation:
152 Character string concatenation is a defined operation under the ansi77
153 option.  The concatenation operator is //, and is higher in precedence
154 than the relational and logical operators.  Expressions involving
155 multiple concatenations may be parenthesized, but the parentheses do
156 not alter the value of the expression.  Only character data may appear
157 as an operand of a concatenation operator.
158 
159 
160 Examples:
161 In the following examples, suppose that atoe is a character*5 variable
162 with the value "abcde", and vtoz is a character*5 variable with the
163 value "vwxyz".
164 
165           atoe // vtoz                  "abcdevwxyz"
166           atoe (2:3) // vtoz (3:3)      "bcx"
167           atoe (3:3) // vtoz (2:2)
168                // atoe (4:4)            "cwd"
169 
170 
171 assumed size character strings:
172 Under the ansi77 option, the length of a dummy argument, named
173 constant, or function subprogram of type character may be given as
174 "(*)" in the declarative statement.  For a dummy argument, the "(*)"
175 length is defined as the length of the corresponding actual argument.
176 For a named constant, the "(*)" length is defined as the length of the
177 constant expression which defines the named constant.  For a function
178 subprogram, the length of the value returned is determined by the
179 declarative statements of the program unit in which the function
180 subprogram is called.
181 
182 
183 default character string length:
184 Under the ansi77 option, the default length of character data has been
185 changed from 8 to 1.  The default length is used whenever a name is
186 declared to be of type character and no length is specified.
187 
188 
189 descriptors for character arguments:
190 Under the ansi77 option, standard Multics argument descriptors are
191 generated for all CALL statements and references to external functions
192 which contain arguments of type character.