[Info-vax] Alpha Fortran data alignment
glen herrmannsfeldt
gah at ugcs.caltech.edu
Tue Aug 31 16:23:38 EDT 2010
Richard B. Gilbert <rgilbert88 at comcast.net> wrote:
> tadamsmar wrote:
>> I was checking the locations of variables.
>> If I run this:
>> integer*2 prmidx
>> real*4 vlu
>> prmidx = 1
>> vlu = 10000000
>> call sub(prmidx,%loc(prmidx),%loc(vlu))
>> end
>> subroutine sub(prmidx,lp,lv)
>> integer*4 prmidx,lv,lp
>> type *,prmidx,lp,lv
>> end
>> 1 196608 196616
>> But if I change prmidx to real*4 in main and real*8 in
>> the sub, I get:
>> 128.000036285423 196608 196612
>> It appear that 8 bytes are allocated for an integer*2 and 4 bytes are
>> allocated for a real*4
There is no requirement that variables be allocated in memory
in the order that they are declared. Sometimes the compiler even
needs temporary variables that might also be allocated.
>> Why is this?
> Because you are breaking all the rules!!!!!!!
> You have assigned different sizes (INTEGER*2 and INTEGER*4) for the same
> variable in MAIN and SUB. The subroutine will see 16 bits of data and
> 16 bits of garbage.
That is true, but completely unrelated to the question being asked.
The question only has to do with the addresses of the variables
in the main program. %loc() finds the address and passes that
as an integer. The OP only was asking about the sizes and
positions in memory of the variables.
-- glen
More information about the Info-vax
mailing list