Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!haven!adm!cmcl2!acf5!jjb3281 From: jjb3281@acf5.NYU.EDU (Thanbo) Newsgroups: comp.lang.fortran Subject: Re: Type punning in FORTRAN (was in C) Summary: weve done this for years Message-ID: <891@acf5.NYU.EDU> Date: 18 Oct 89 23:59:15 GMT References: <475@idacrd.UUCP> <1989Oct10.185851.6490@agate.berkeley.edu> <1131@mpx1.lanl.gov> Organization: New York University Lines: 20 In article <1131@mpx1.lanl.gov>, matthias@mpx1.lanl.gov (Bjorn E. Matthias, M/S H831, 7-6241 or 7-7906) writes: > > > > result = TRANSFER(SOURCE, MOLD, SIZE) . > > If I am not mistaken, then this could be previously accomplished in > VAX FORTRAN with EQUIVALENCE between two variables of whatever types. > I have used this often and it appears that TRANSFER is different only > in that one truly has *two* pieces of data, two memory locations. > Sounds like a useful function, though I do not believe it really This sort of thing has been done for years. We do this with a tiny assembly-language program called MVCX(nbytes, src, dst) which simply copies so many bytes from src to test. It's about 12 instructions on the S/370 machines, or 6 instructions on VAX, with error checks to make sure you're passing valid addresses of arguments, and a valid length (since FORTRAN passes by reference, the function has the addresse of the arguments available). Thanbo Information Builders Inc. jjb3281@acf5.nyu.edu