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

ASSOCIATE statement

John4
Valued Contributor I
665 Views

I'm trying to learn to use the ASSOCIATE statement (i.e., trying to see if I understood correctly what such statement intends to do). I have the following test:


program test

implicit none

type tabletype
integer :: p, q
end type

type globaltype
type(tabletype), allocatable :: table(:,:)
end type

integer :: i
type(globaltype), target :: global
integer, pointer :: p2q(:,:)

continue

allocate (global%table(10,10))

ASSOCIATE (p => global%table%p)
p = RESHAPE([(i, i = 1, 100)], [10,10])
write (*,'(10(10I5/))') p
END ASSOCIATE

p2q => global%table%q
p2q = RESHAPE([(i, i = 1, 100)], [10,10])
write (*,'(10(10I5/))') p2q

nullify(p2q)

end program test

When I try to compile this source code, I get:

internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.
ASSOCIATE (p => global%table%p)
^
[ Aborting due to internal error. ]
compilation aborted for test.f90 (code 1)

So my question is, am I using the ASSOCIATE statement right (i.e., as a replacement for pointers like p2q) or not?

John.

0 Kudos
1 Solution
Steven_L_Intel1
Employee
665 Views
This error has been corrected for a future release.

View solution in original post

0 Kudos
4 Replies
TimP
Honored Contributor III
665 Views

ASSOCIATE (p => global%table%p)

I guess this violates the rule against using ASSOCIATE to redefine a name. The compiler ought to say what is wrong, rather than throw an internal error.

0 Kudos
John4
Valued Contributor I
665 Views
Quoting - tim18

I guess this violates the rule against using ASSOCIATE to redefine a name.

Yes, it was my fault for not writing a test case that represents exactly the code I have (i.e., in my code, the target values are never modified when accessed through the pointer). Anyway, the following code stills throws the same internal error:

program test

implicit none

type tabletype
integer :: p, q
end type

type globaltype
type(tabletype), allocatable :: table(:,:)
end type

integer :: i
type(globaltype), target :: global
integer, pointer :: p2q(:,:)

continue

allocate (global%table(10,10))

global%table%p = RESHAPE([(i, i = 1, 100)], [10,10])
ASSOCIATE (p => global%table%p)
write (*,'(10(10I5/))') p
END ASSOCIATE

p2q => global%table%q
p2q = RESHAPE([(i, i = 1, 100)], [10,10])
write (*,'(10(10I5/))') p2q

nullify(p2q)

end program test

0 Kudos
Steven_L_Intel1
Employee
665 Views

Thanks - I can reproduce this and have passed it on to development. Our issue ID is DPD200110830. I will let you know of any progress.

0 Kudos
Steven_L_Intel1
Employee
666 Views
This error has been corrected for a future release.
0 Kudos
Reply