mkh6317@summa.tamu.edu (HOWARD, MATTHEW KENDALL) (01/26/91)
I'd like to collectively thank those individuals who took the time to kindly explain why equivalencing a character variable to a numeric variable violates the standard. In short, portability. Word length can vary from machine to machine for both numeric and character variables. A real variable may require 32 bits on one machine and 64 bits on another. Thus, alignments made using equivalence statements many not hold following a port. Furthermore, since machines have different rules about aligning variables in core relative to word boundaries, single byte elements, (a single character for example), might be stored in byte 1 of a 4 byte machine word on one machine and in byte 2 or 4 on another. And as an aside to the original I/O article. Since the internal representation of characters may differ from one platform to another (ACSII vs. EBCDIC for example), attempting to manipulate character values via numeric assignments is also potentially non-portable. Of course we all do it anyway. Matt
ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (01/31/91)
In article <11514@helios.TAMU.EDU>, mkh6317@summa.tamu.edu (HOWARD, MATTHEW KENDALL) writes: > I'd like to collectively thank those individuals who took the > time to kindly explain why equivalencing a character variable > to a numeric variable violates the standard. > In short, portability. I'd just like to add an anecdote. The one time I had to do some paid work in Fortran it involved porting a program *from* a FIVE character per "word" machine (BCD code, I think) *to* a FOUR character per "word" machine (ASCII) *through* a SIX character per "word" machine (EBCDIC) One rather nasty point was that not all bit-patterns were valid integers on the six-char-per-word machine, so that INTEGER FRED DATA FRED/'ABCDE'/ FRED = FRED+0 could blow up. Precisely one thing saved me: the 6 char per word machine was a Burroughs B6700 and the compiler had a directive "$CHARS = n" which told the compiler and the formatted I/O library to pretend that words held only n bytes. To this day I have no real hope that I got that conversion right. -- The Marxists have merely _interpreted_ Marxism in various ways; the point, however, is to _change_ it. -- R. Hochhuth.
roth@dtoa1.dt.navy.mil (Roth) (01/31/91)
An extra $.02 re how strings eventually _should_ be done: Cf. SOFTWARE PRACTICE & EXPERIENCE , Dec 1990 article entitled "DYNAMIC STRINGS IN FORTRAN 90" by Schonfelder & Morgan. Peter N Roth