1 11/26/80  fortran_77.conversions
  2 
  3 This info segment outlines some suggested procedures for converting
  4 FORTRAN programs fron ansi66 to ansi77.  The implementation of FORTRAN
  5 77 on Multics is not yet complete, so this list of suggested
  6 conversion procedures may grow with future releases.  The paragraphs
  7 below are titled:
  8 
  9           common blocks
 10           equivalence groups
 11           default character string length
 12           packed character string layout
 13           zero trip DO loop
 14           blank lines
 15 
 16 
 17 common blocks:
 18 Under the ansi77 option, it is invalid to mix character mode variables
 19 and variables of other modes within a single common block.  Common
 20 blocks in ansi66 programs that contain both character and
 21 non-character data must be split into two separate common blocks, one
 22 for character data and one for non-character data.
 23 
 24 
 25 equivalence groups:
 26 Under the ansi77 options, it is invalid to equivalence character mode
 27 variables with variables of other modes.  Such equivalencing in ansi66
 28 programs should be replaced with explicit assignment statements.  For
 29 complex and double precision data, the corresponding character
 30 variable should be given the length 8.  For integer, real, and logical
 31 data, the corresponding character variable is of length 4.
 32 
 33 Whenever the storage in question is to be viewed as non-character
 34 data, the program should explicitly assign the character value to an
 35 integer, real, etc. variable.  Whenever the storage is to be viewed
 36 as character data, it may be inspected directly.
 37 
 38 
 39 default character string length:
 40 Under the ansi77 option, the default length for character variables
 41 has changed from 8 to 1.  To avoid ambiguity, all CHARACTER statements
 42 in the program should be inspected to ensure that every character mode
 43 variable has an explicitly declared length.
 44 
 45 
 46 packed character string layout:
 47 The representation of character data in storage is different under the
 48 ansi77 option.  This change in storage layout will most seriously
 49 affect programs which use permanent common blocks (those whose names
 50 end with "$") or unformatted files which contain character data and
 51 which were written by an ansi66 program.
 52 
 53 ansi77 programs can access character data in ansi66 format as follows:
 54 for each character datum in ansi66 format, the ansi77 program should
 55 declare a corresponding character datum.  The length of the character
 56 datum in the ansi77 program should be the smallest multiple of 4 that
 57 is greater than or equal to the length declared in the ansi66 program.
 58 For example, a CHARACTER*15 variable becomes CHARACTER*16, and a
 59 CHARACTER*32 variable remains CHARACTER*32.
 60 
 61 The next step is to use the substring notation wherever an ansi77
 62 variable is used to access ansi66 data.  If the variable was declared
 63 CHARACTER*15 in the ansi66 program, the ansi77 program should
 64 reference a CHARACTER*16 variable with the substring notation (1:15).
 65 
 66 This technique can be used in converting old format data to the new
 67 format by reading the data as described above, and writing the data to
 68 a new file or common block straightforwardly with an ansi77 program.
 69 
 70 
 71 zero trip DO loop:
 72 For ansi66 programs being converted to ansi77, each DO loop must be
 73 examined.  If the logic of the program depends on the loop body being
 74 executed at least once in all circumstances, the final loop value
 75 should be changed to use the MAX or MIN intrinsic function.  For
 76 example, the statement
 77 
 78           DO 100 I = J,K
 79 
 80 might be changed to
 81 
 82           DO 100 I = J,MAX(J,K)
 83 
 84 to ensure that the loop is executed at least once under the ansi77
 85 option.  If the increment is known to be negative, the MIN intrinsic
 86 function should be used instead of MAX.
 87 
 88 
 89 blank lines:
 90 The interpretation of a blank line differs in the ansi66 and ansi77
 91 options.  In ansi66, it is interpreted as an initial line, i.e.  it
 92 begins a statement, whereas in ansi77, it is ignored.  This will
 93 present no difficulty in all but the most pathological cases.
 94 
 95 
 96 Consider the following program:
 97 
 98 %options card;
 99       program blank_line
100       integer foo, foogoto5, k
101       data foo /66/, foogoto5 /77/
102       k = foo
103 
104      &go to 5
105   100 format (" This was compiled with the ansi", i2, " option.")
106     5 write (6, 100) k
107       stop
108       end
109 
110 If this program compiled with the ansi66 option, it will set  k to the
111 value of the variable foo, because the blank line terminates the
112 assignment.  If compiled with the ansi77 option, it will set k to the
113 value of foogoto5, because the blank line is ignored and the what we
114 might think of as the goto statement is considered part of the
115 assignment statement.  If the ansi66 semantics of this program were
116 desired while compiling under the ansi77 option, it would be necessary
117 to insure that the goto statement was not interpreted as a
118 continuation line to the assignment.  The remedy is to simply remove
119 the continuation marker in column six.