Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!uunet!timbuk!raphael!wws From: wws@raphael.cray.com (Walter Spector) Newsgroups: comp.lang.fortran Subject: Re: I/O Message-ID: <134822.25178@timbuk.cray.com> Date: 30 Jan 91 20:14:35 GMT References: <27a6aacc@ThreeL.co.uk> Reply-To: wws@raphael.cray.com (Walter Spector) Organization: Cray Research, Inc. Lines: 60 In article <27a6aacc@ThreeL.co.uk>, jf@threel.co.uk (John Fisher) writes: > mkh6317@rigel.tamu.edu (HOWARD, MATTHEW KENDALL) asks: > > > Ok, ok. Uncle. Since I don't have a copy of the "standard" I > > will have to take your word that "equivalencing a character > > variable to a non-character variable" is a violation of the > > standard. Now tell me why. > > Why the sneer quotes round standard? > > Reason: because it's very unportable. Why? > > 1) Endian problems > 2) Word-length problems > 3) Character-code problems All three very good reasons from a portablility point of view. Much of the use of this 'feature' is to avoid rewriting old Fortran-66 '8HHOLLERIT,1HH' based programs when adding new code. The new code uses character data type (for obvious maintainability reasons), but can still get at the old existing data structures. Porting large (.gt. 10**5 lines) Hollerith-based codes can be a nightmare. A fourth reason is word *alignment* problems. Not all the world is a VAX. (Actually, *none* of it was when the '77 standard was created.) Consider something approximating the following: character*100 string integer i equivalence (string(2:2),i) This would, if legal, force the integer to be equivalenced to the second character of the character variable. Since the integer would no longer be word-aligned, performance penalties would result on word-addressable machines. (I understand this is even true for most byte-addressable machines, since the hardware still doubles your memory references and then shifts to align - even if invisible to the programmer.) The same situation exists when mixing character and non-character data in common blocks. The '77 standard does not allow mixing in common either. Many compilers do support mixing of character/non-character types in equivalence/common. Some implementations only allow it when alignment rules are followed to avoid the performance problems. Consider: character*100 string integer i equivalence (string(1:1),i) The integer is word-aligned, and equivalencing is possible with no performance problems. Walt Spector (wws@renaissance.cray.com) Sunnyvale, California _._ _._ _.... _. ._.