Alignment of Allocatable Dummy Variable

Alignment of Allocatable Dummy Variable


I have a subroutine that allocates a workspace for MKL routines, and I want to specify the alignment of the allocated buffer. I'm using the ATTRIBUTES ALIGN directive. This works for e.g. allocatable automatic variables, but doesn't want to work for allocatable dummy arguments. For example, this fails:

subroutine create_workspace ( this, work )
  class(object),              intent(in)    :: this
  real(kind=DP), allocatable, intent(inout) :: work(:)
end subroutine create_workspace

The error is

error #6406: Conflicting attributes or multiple declaration of name.   [WORK]

Am I doing something totally wrong here? Is there better way to accomplish this? I'm looking for something that works on both Windows and Linux. The compiler version is 64-bit,



3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Interesting - this is something we didn't consider. I'm not sure how to resolve this because the data could be passed already allocated but not at the specified alignment.

I think the way we'd have to do it is with ASSUME_ALIGNED (this is its own directive, not part of ATTRIBUTES)  and then apply that alignment if the variable gets allocated within the procedure. I will suggest this to the developers.

Steve - Intel Developer Support

Thanks Steve. What about allowing it if the dummy argument is declared INTENT(OUT)? This way, it's guaranteed that it will be unallocated - it will call deallocate if already allocated on entry. It's not a show-stopper, though; it's easy enough to workaround. I'll just use a type-bound function that returns the size of the allocation and do the allocation (and alignment) in the calling routine.

Leave a Comment

Please sign in to add a comment. Not a member? Join today