From: Lynn McGuire on
Is this considered bad code ? Or is this an extremely
common fortran compiler extension ?

double precision vdy (1000000)
character*8 svdy (1000000)
equivalence (vdy, svdy)

Thanks,
Lynn
From: Ken Fairfield on
On Jun 21, 10:25 am, Lynn McGuire <l...(a)winsim.com> wrote:
> Is this considered bad code ?  Or is this an extremely
> common fortran compiler extension ?
>
>        double precision vdy (1000000)
>        character*8 svdy (1000000)
>        equivalence (vdy, svdy)
>

My recollection from days of old is that
(1) the Standard supports only the equivalence
between numeric and other numeric entities,
or between character entities, but not between
cahracter and numeric entities, and (2) that
this was a fairly common extension (I used it...).

-Ken
From: Gordon Sande on
On 2010-06-21 14:25:22 -0300, Lynn McGuire <lmc(a)winsim.com> said:

> Is this considered bad code ? Or is this an extremely
> common fortran compiler extension ?
>
> double precision vdy (1000000)
> character*8 svdy (1000000)
> equivalence (vdy, svdy)
>
> Thanks,
> Lynn

Bad code! Judging from the overall idiom I would guess that this is
part of a do-it-yourself dynamic allocation as practiced in Fortran 77.
dy for dynamic, v for variable and sv for string variable would be my
guess to explain the names.

At one time it was possible to find sets of routines that packaged all
this into less error prone versions. I would try looking at the PORT library
that was offered by the now departed Bell Labs.

If your usage is tightly controlled and well packaged then it would be
considered
an obsolete way of doing what is readily done now. Otherewise it looks like an
accident in waiting.



From: steve on
On Jun 21, 10:25 am, Lynn McGuire <l...(a)winsim.com> wrote:
> Is this considered bad code ?  Or is this an extremely
> common fortran compiler extension ?
>
>        double precision vdy (1000000)
>        character*8 svdy (1000000)
>        equivalence (vdy, svdy)
>
> Thanks,
> Lynn

I would consider it bad code given that F2003 has

C580 (R555) If an equivalence-object is of type default integer,
default real, double precision real, default complex, default
logical, or numeric sequence type, all of the objects in the
equivalence set shall be of these types.

C581 (R555) If an equivalence-object is of type default character
or character sequence type, all of the objects in the equivalence
set shall be of these types.

--
steve
From: mecej4 on
On 6/21/2010 12:25 PM, Lynn McGuire wrote:
> Is this considered bad code ? Or is this an extremely
> common fortran compiler extension ?
>
> double precision vdy (1000000)
> character*8 svdy (1000000)
> equivalence (vdy, svdy)
>
> Thanks,
> Lynn
Others have already pointed out that this is illegal in Fortran 9X and 2003.

Section 8.2.3 of the Fortran 77 standard says:

"An entity of type character may be equivalenced only with other
entities of type character."

One current compiler, given the code

block data
common /abc/vdy
double precision vdy (1000000)
character*8 svdy (1000000)
equivalence (vdy, svdy)
end

and told to compile it,

f95 -f77 -c equ.f

says

Error: equ.f, line 5: EQUIVALENCE of default char with default numeric

The real question, then, is: how often is this non-standards-compliant
feature used in your code, how much effort are you willing to expend to
fix the code, and what is the estimated cost of going forward without
excising this cancer _now_?

--mecej4