Community
cancel
Showing results for 
Search instead for 
Did you mean: 
jimdempseyatthecove
Black Belt
112 Views

Request for ability to specify alignment for array of user defined types

Consider:

type foo_t
  double precision :: array(8) ! cache line size
end type foo_t
...
type(foo_t) :: foo(3,3)
...
call fefe(foo)
...
subroutine fefe(fi)
type(foo_t) :: fi(3,3)
...

While I can declare foo to be aligned, I can not instruct the compiler to know that fi(i,j)%array is aligned.

I think that in this case this should be permissible as sizeof(foo_t) is known.

Jim Dempsey

0 Kudos
3 Replies
Steve_Lionel
Black Belt Retired Employee
104 Views

Doesn't the ASSUME_ALIGNED directive do what you want? Or am I misunderstanding the question?

jimdempseyatthecove
Black Belt
101 Views

The compiler complains about having a member variable of an array of user defined type being aligned (even when size of UDT is multiple of alignment). Unfortunately I cannot get the error message now as I cannot Remote Desktop into the development system with the "offending" code.

I do not have the exact text of the error/warning message on this system but it was something to the effect that compiler could not know the alignment of a non-allocatable or non-pointer member of a member variable of an array of user defined types. Presumably should the array of UDT be aligned .AND. .NOT. of sizeof multiple of alignment, then the 2nd (and later) elements of UDT array might not also be aligned as is the base of the array of UDT. In this specific case, the size of the UDT element ought to be known by the compiler, and thus for this case the assume_aligned ought to be permitted.

I will see if I can get the actual circumstance messaged when I can re-connect to the development system.

Jim Dempsey

jimdempseyatthecove
Black Belt
98 Views

BTW note that this applies to the called subroutine and not where the the (aligned) UDT is defined.

Jim Dempsey

Reply