Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

!dir$ attributes align issue

jimdempseyatthecove
Honored Contributor III
651 Views
!  Console2.f90 
module mod_foo
    integer, parameter :: n=8
    double precision :: a(n)
    !dir$ attributes align : sizeof(double precision)*n :: a
    double precision :: b(n)
    !dir$ attributes align : sizeof(b(1))*n :: b
    double precision :: c(n)
    !dir$ attributes align : 8*n :: c
end module mod_foo
    
program tst
    use mod_foo
    print *, a,b
end program
1>C:\Users\Jim\Source\Repos\Console2\Console2\Console2.f90(5): error #6326: This specifier is invalid for this I/O operation.
1>C:\Users\Jim\Source\Repos\Console2\Console2\Console2.f90(7): error #6326: This specifier is invalid for this I/O operation.
1>C:\Users\Jim\Source\Repos\Console2\Console2\Console2.f90(9): error #6326: This specifier is invalid for this I/O operation.

Jim Dempsey

0 Kudos
5 Replies
Steve_Lionel
Honored Contributor III
640 Views

Weird error message, but this directive just wants an integer literal there, not an expression. "sizeof(double precision)" would be invalid almost anywhere (exception being fixed-form where you have a variable "DOUBLEPRECISION").

My guess for the message text is that the developer picked a number for an existing message and didn't think about the wording being appropriate.

0 Kudos
jimdempseyatthecove
Honored Contributor III
620 Views

sizeof(double precision), sizeof(REAL), sizeof(logical), ...  should be a compile time evaluation.

In the actual code, I wanted the compiler to assure that an array of some type, is aligned at a boundary of equal to the sizeof(array) .equiv. to sizeof(type of array)*parameter of number of elements in array.

IMHO sizeof() should be available at compile time in places where identity of what is being sizeof'd can be determined at compile time.

Jim Dempsey

0 Kudos
Steve_Lionel
Honored Contributor III
614 Views

Yes, SIZEOF (an extension) can be evaluated at compile time, but the syntax of directives doesn't provide for expressions or even named (PARAMETER) constants - literals only.

0 Kudos
jimdempseyatthecove
Honored Contributor III
600 Views

Then this leads the solution to having to use /fpp and #define ...

Something which is frowned upon.

Jim Dempsey

0 Kudos
andrew_4619
Honored Contributor II
596 Views

Given these are all non-standard constructs does it really matter which form of extension is used ie fpp or !dec$ or both.

0 Kudos
Reply