Silverfrost Forums

Welcome to our forums

ALIGN attribute is not working

18 May 2012 9:06 #10190

In the code below, the real*4 array A should be aligned on 16 byte (128 bit) address boundarys.

Unfortunately it doesn't seem to work. 😦

program anon
real, align(128) :: a(12)
integer :: addr
a = 0.0
addr = loc(a(1))
if (mod(addr,16) == 0) then
   print *,'Array is aligned on 128 bit boundary''s. It worked!'
else
   print *,'Oops, it didn''t work'
end if
end
21 May 2012 8:32 #10202

David,

This might provide more info, but does not appear to work. program anon real, align(128) :: a(12) real, align(64) :: b(12) integer :: addr_A, addr_B ! a = 0.0 b = 0.0 addr_A = loc(a(1)) addr_B = loc(b(1)) write (,) 'A align = ',addr_A, mod (addr_A,32) write (,) 'B align = ',addr_B, mod (addr_B,32) ! if (mod(addr_A,16) == 0) then print *,'Array is aligned on 128 bit boundary''s. It worked!', addr_A else print *,'Oops, it didn''t work' , addr_A end if ! end

John

28 May 2012 5:24 #10221

Paul,

I tested my above code example and : It worked for FTN95 Ver 6.10 using salflibc.dll Version 13.3.23.20, on XP_64, but failed for FTN95 Ver 6.10 using salflibc.dll Version 13.12.2.9, on Win7_64

The compiler crashed with small changes to the code when I first tried to change David's code to introduce align(64). The error results from the following change.

program anon 
real, align(128) :: a(12) 
real, align(64)  :: b(12) 
integer :: addr_A, addr_B 
! 
!a = 0.0 
!b = 0.0 
addr_A = loc(a(1)) 
addr_B = loc(b(1)) 
   write (*,*) 'A align = ',addr_A, mod (addr_A,32) 
   write (*,*) 'B align = ',loc(b), mod (loc(b),32) 
! 
if (mod(addr_A,16) == 0) then 
   print *,'Array is aligned on 128 bit boundary''s. It worked!', addr_A 
else 
   print *,'Oops, it didn''t work' , addr_A 
end if 
! 
end 
Please login to reply.