Re: what is this statement doing



aeroguy wrote:
I have this problem? Can someone help me understand what is being done
in the following equivalence statement


EQUIVALENCE(V(1),TEMP(1,1))


definitions for V and TEMP is as follows

DOUBLE PRECISION :: V(25000) ! Yes big array
DOUBLE PRECISION :: TEMP(600,10)

i mean which memory location is being refereced.

what should be the fortran 90 equivalent statement for this


The EQUIVALENCE statement says that that the first element of each array is in the same memory location. Because the arrays are guaranteed to be contiguous in memory, that means that so are the second elements, and the third, and so on... effectively you have two superposed arrays. Since both arrays are double precision, this allows you to reference the same memory either with V (using a one-dimensional index) or with TEMP (using a two-dimensional index).

This is perfectly good Fortran 90. If the different indexing methods are what you want to do, then there's no need to change it. If it was done originally to save space by reusing the storage, rather than to give the programmer two different way to refer to the same storage, you might want to dynamically allocate the arrays instead, as and when you need them.

Catherine.
--
Catherine Rees Lay

Polyhedron Software Ltd. Registered Office: Linden House,
93 High St, Standlake, Witney, OX29 7RH, United Kingdom.
Registered in England No.2541693. Vat Reg No. GB 537 3214 57
.



Relevant Pages

  • Re: cannot pass variable size array to subroutine
    ... < Note that I know of no compiler that does not make allocatable arrays ... DOUBLE PRECISION p, p1,valmin ... END SUBROUTINE ... Results with 3 compilers on my PC, ...
    (comp.lang.fortran)
  • Re: Quadruple precision
    ... Your explanation of byte arrays, I guess, is over my ... the data to be all in the same of order of magnitude, where all is fine, ... type Double does not give me a good precision. ... You certainly could create a class which handles arbitrary precision ...
    (microsoft.public.vb.controls)
  • Re: Space leak in Haskell code
    ... While h has the full precision of 47 or so ... only values of similar magnitude are ever subtracted, ... When using immutable arrays, there's continuous allocation ... the cache is full. ...
    (comp.lang.functional)
  • Re: Probleme to convert fortran in mexfile
    ... C STANDARD VARIABLES ... DOUBLE PRECISION GETSCA ... C ASSIGN SECONDARY FORTRAN INPUT SCALARS ... SCALARS AND ARRAYS ...
    (comp.soft-sys.matlab)
  • Re: Singles to Doubles
    ... If arrays were much larger, would probably need to actually implement a general function internally by using a loop by column or the required buffer length to hold the ASCII version would probably exceed the rtl i/o library's internal limitations. ... As for the actual precision of the data, the other poster is correct that the double precision value can have no more "real" precision than the single precision value it is derived from. ... OBTW, this precise subject was a thread subject on comp.lang.fortran not too awful long ago, and this turned out to be the most practical solution as the scaling solutions always end up w/ boundary cases that can cause problems more difficult to solve that the rti i/o library is generally coded to handle. ...
    (microsoft.public.vb.general.discussion)