- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I think i got a problem here.
I have a Dynamical Data Type defined as:
[cpp]
TYPE D_I_V
INTEGER, DIMENSION(:), POINTER :: vec => NULL()
END TYPE D_I_V
[/cpp]
If I Run a program which involves the sequent subroutine:
[cpp]SUBROUTINE try_pointer( a ) IMPLICIT NONE TYPE(D_I_V), DIMENSION(:), INTENT(IN) :: a INTEGER, DIMENSION(:),POINTER :: jj => NULL() INTEGER :: i DO i = 1,size(a); jj => a(i)%vec write(*,*) ASSOCIATED(jj) ENDDO END SUBROUTINE try_pointer[/cpp]
I get a sequence of FALSE, since the pointer "jj" is not associated to "a(i)%vec".
Clearly the bug is in the assignement "jj => a(i)%vec" which in fortran intel compiler 10.0 worked fine, But here must be substituted by "jj => a(i)%vec(:)",
Do you know if I made any error or is it some kind of bug!?
I remind you, that inserting some code (like WRITE this or WRITE that) into the SUBROUTINE, which obviously doesn't touch the variables, the association seems to work fine!!!
I'm really freaking you!
Thanks
DARIO
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
you haven't shown us how exactly you set up your program. Since the default initialization for the component is NULL(), any not explicitly allocated or associated entities will be unassociated. For example the program
program arptr
use mod_arptr
implicit none
type(d_i_v) :: y(5)
allocate(y(2)%vec(7))
call try_pointer(y)
deallocate(y(2)%vec)
end program arptr
when used together with your code, results in
F
T
F
F
F
when using Intel 10.1, and
F
F
F
F
F
when using Intel 11.0. I guess there is indeed a bug in V11 :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The input vector (to be pointed) is indeed correctly allocated and assigned. I get FALSE while using directly the TARGET array a get a TRUE value.
[cpp]PROGRAM example
TYPE(D_I_V), DIMENSION(4) :: B
INTEGER :: i
DO i = 1,4
ALLOCATE( B(i)%vec(3) )
B(i)%vec = i * (/1, 2, 3/)
ENDDO
CALL try_pointer(B)
PROGRAM example
[/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can reproduce this. Curiously, on Windows at least (where I tried it), simply enabling debug symbols (even with optimization) makes the problem go away. I will report it to the developers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can I ask you what kind of debug tools did you used?
I'm under linux, but at least I can give it a shot.
Thanks
DARIO
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No tools - just used the compiler option to generate debug symbols. "-debug full" on Linux.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Entered as DPD200110352. Turning off optimization (-Od) may be the better workaround.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[cpp]a => b % struct[/cpp]
to
[cpp]a => b % struct(:)[/cpp]
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The issue is just starting investigation so I can't speculate on a timeframe for the fix.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page