- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is fixed in Update 6, available now.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page