Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uunet!mcsun!ukc!cam-cl!news From: cet1@cl.cam.ac.uk (C.E. Thompson) Newsgroups: comp.lang.fortran Subject: Re: Cheating on the types Message-ID: <1991Mar25.163447.10166@cl.cam.ac.uk> Date: 25 Mar 91 16:34:47 GMT Article-I.D.: cl.1991Mar25.163447.10166 References: <1991Mar20.195732.15376@appmag.com> <4554@alliant.Alliant.COM> Reply-To: cet1@cl.cam.ac.uk (C.E. Thompson) Organization: U of Cambridge Comp Lab, UK Lines: 42 In article <4554@alliant.Alliant.COM> tj@Alliant.COM (Tom Jaskiewicz) writes: >In article <1991Mar20.195732.15376@appmag.com> pa@appmag.com (Pierre Asselin) writes: >}This simplified fragment violates the standard by passing reals to a >}routine that expects integers. >} >} program wrong >} real rin, rout >} rin= 0.577215665 ! or whatever... >} call icopy(rin, rout) >} write(6,*) rout >} end >} >} subroutine icopy(iin, iout) >} integer iin, iout >} iout= iin >} return >} end >} >}Seems fairly innocuous, though. Q: are there implementations >}where it would fail ? > >Yes. It been 10 years since I've used one, but there is at least one >Fortran implementation that uses 16 bit INTEGER's and 32 bit REAL's. >(this in itself violates Fortran-77). > From the mists of time: on TITAN (and other Atlas-1 and Atlas-2 Fortran implementations as well, I expect) integers were halfwords (24 bits) while reals were words (48 bits). The above code would not have worked. This implementation long preceded the Fortran 77 rules on storage units. However, in some cases it was compatible with them: for example, an INTEGER array and a REAL array with the same number of elements that were EQUIVALENCEd or overlaid in COMMON would correspond 1:1 (half the space in the INTEGER array was "wasted"). Copying the INTEGER array element by element to another such INTEGER/REAL pair would not have the effect of copying the REAL array (only half the bits would be moved), and there is nothing in the Fortran 77 standard to say that it should. Chris Thompson JANET: cet1@uk.ac.cam.phx Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk