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

!dir$ attributes align issue

!  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
Highlighted
Black Belt Retired Employee
128 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.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
108 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
Highlighted
Black Belt Retired Employee
102 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.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
88 Views

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

Something which is frowned upon.

Jim Dempsey

0 Kudos
Highlighted
Valued Contributor III
84 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