Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
111 Views

Warning #6379: The structure contains one or more misaligned fields

The following derived type definition generates the warning: warning #6379: The structure contains one or more misaligned fields

 type table_format   
      sequence         
      real(kind=dp), dimension(:), ALLOCATABLE :: array_data     

      real(kind=dp)    :: aa              
      real(kind=dp)    :: bb     
      real(kind=dp)    :: cc      

      integer(kind=i4) :: nn   
      integer(kind=i4) :: kk      
      integer(kind=i4) :: jj       

      character(len=52) :: title                                                 
                                        
   end type table_format

Can someone explain how to align the fields of this derived type?  Does the use of the keyword "sequence" provide a performance benefit by storing all the derived type elements in adjacent memory location or do I not understand how to use sequence? In other words, should I not be using sequence?

Thanks....

 

0 Kudos
1 Reply
Highlighted
111 Views

The problem here is that the descriptor for the allocatable array isn't a multiple of 8 bytes, so it causes the real(dp) components to be misaligned when compiled for 32-bits.

Move that component to after the real and integer components.

Don't use SEQUENCE - it hurts performance in some cases by preventing the compiler from naturally aligning the components.

0 Kudos