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

On the ASSOCIATE construct

John4
Valued Contributor I
896 Views

Hi,

I don't know if the code below is valid, since I'm still *trying* to learn how to use the associate construct. I get internal error with version 11.1.

module mod1
implicit none
type :: t3
integer :: d
end type
type :: t2
type(t3), allocatable :: c(:,:,:)
end type
type :: t1
type(t2) :: b
end type
end module mod1

program prog1
use mod1
implicit none
integer :: i, j, k
character(5) :: chr
type(t1) :: a

allocate (a%b%c(3,3,3))
a%b%c%d = 3
associate (d => a%b%c%d == 3)
do k = 1, SIZE(d, 3)
do j = 1, SIZE(d, 2)
do i = 1, SIZE(d, 1)
chr = MERGE('three', 'other', d(i,j,k))
write (*,*) chr
enddo
enddo
enddo
end associate
end program prog1

0 Kudos
1 Solution
Steven_L_Intel1
Employee
896 Views
This is fixed in Update 6, available now.

View solution in original post

0 Kudos
5 Replies
Steven_L_Intel1
Employee
896 Views
Whether or not it is valid (and I see nothing wrong with your code), an internal compiler error is almost always a compiler bug. I will report this to the developers - issue ID is DPD200137359.
0 Kudos
Andrew_Smith
Valued Contributor I
896 Views
Does the compiler teat the associate as a small chuck of code that replaces the asscocated name?, a bit like the C #define but with limited scope?
0 Kudos
Steven_L_Intel1
Employee
896 Views
It's not a macro like C #define. It's sort of like creating a new variable which "maps" onto the data specified in the "selector". The selector can be an expression or variable, where "variable" can be an array slice, component reference, etc. The associate name takes its type and shape from the selector, but unlike a macro, any changes to subscripts, etc. that are in the selector do not get re-evaluated inside the block.
0 Kudos
Steven_L_Intel1
Employee
896 Views
The cause of this problem has been found and fixed. I do not yet know when the fix will appear - when I do, I'll update this thread.
0 Kudos
Steven_L_Intel1
Employee
897 Views
This is fixed in Update 6, available now.
0 Kudos
Reply