For Programmers: Free Programming Magazines  


Home > Archive > Fortran > July 2006 > Re: Viewing Double Precision reals as Integers









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Viewing Double Precision reals as Integers
Steven G. Kargl

2006-07-25, 7:00 pm

In article <ea6b5q$gg6$1@news.nems.noaa.gov>,
Paul Van Delst <Paul.vanDelst@noaa.gov> writes:
> Steven G. Kargl wrote:
>
> I read the standard in the section you indicated and, pardon my
> denseness, but how is an equivalence statement ever to be used
> to equivalence different types? Or have you never been able to do
> that?


We're going to need someone like Richard Maine to comment on the
historical developement of equivalence.

> In 14.7.5 (Events that cause variables to become defined) it states that:
>
> (10) When a character storage unit becomes defined, all associated
> character storage units become defined. When a numeric storage
> unit becomes defined, all associated numeric storage units of
> the *same type* [my emphasis] become defined. When an entity of
> double precision real type becomes defined, all totally associated
> entities of double precision real type become defined. When an
> unspecified storage unit becomes defined, all associated unspecified
> storage units become defined.
>
> Fair enough. Associated storage unit of same type == everything gets
> defined. But the standard also allows equivalencing of different types,
> and of scalars and arrays.


AFAICT, equivalance of different types is simply storage association
where different variables can re-use memory. Back when 64 KB of memory
was considered standard. Re-using memory was very important.

> So, for the case of different types in an equivalence, whenever you
> define one you automatically undefine the other?


Yep. I believe the idiom would be

> That is,
> integer :: i
> real :: x
> equivalence (i, x)
> i=10 ! This causes x to become undefined


Do a bunch of computations involving i where x isn't needed.

> x=1.0 ! Whoa. This causes i to become undefined


Now, do a bunch of computations with x where i isn't needed.
>
> Wha..?
>
> I'm missing something obvious here.


Probably just the 60 year history of a language where memory
went from ? -> 16 KB -> 64 KB -> 640 KB -> 16 MB -> 4 GB -> 16 GB.

--
Steve
http://troutmask.apl.washington.edu/~kargl/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com