- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello there,
I've been trying to use some allocatable arrays in a user-defined data type. After an object is created and the allocatable array is allocated, it may be accessed with no error. But if I point to the object, I'm not able to access the allocated array, usingthe pointer. It seems to loose the array address.
I'm attaching a sample project with the error.
Regards
Roger
I've been trying to use some allocatable arrays in a user-defined data type. After an object is created and the allocatable array is allocated, it may be accessed with no error. But if I point to the object, I'm not able to access the allocated array, usingthe pointer. It seems to loose the array address.
I'm attaching a sample project with the error.
Regards
Roger
Link Copied
12 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would have expected this to run afoul of scoping, since Fortran requires automatic deallocation when going out of scope. So, you might add diagnostic code to see whether the pointer target remains allocated. Sorry if I have been thrown off track by the coding style.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your situation is a scoping error (allocated array goes out of scope) as Tim suggestedbut your coding intention is to keep the object persistant (and accessible via pointer) after exit from subroutine/function that performs allocationthen allocate to the pointer or placethe array (descriptor) in a module (as opposed to onstack).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I took a look at this and I think it is a bug. I understand where Tim is coming from, but as "this" is a dummy argument and not a local variable, automatic dealloication does not apply.
What I see is that the pointer is not filled in properly, even in the test program - or at least it looks that way to me. I'll report this to the developers.
What I see is that the pointer is not filled in properly, even in the test program - or at least it looks that way to me. I'll report this to the developers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Tim and Jim, but Steve got it right. It's not a problem of going out of scope, because it's not a local variable. Actually, the pointer is correctly addressed at first, but inside a routine, the 'this' pointer looses information. Notice that the pointerin the main routineis still working, correctly addressed.
It is a bug :)
Thanks again,
Roger
It is a bug :)
Thanks again,
Roger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Issue ID is DPD200140796
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I also notice that the debugger does not display the correct information.
For example,
(1) Just after the allocation in Child2ProcedureSub, debuger shows this%child1%parent%parentvariable as undefined pointer/array.
(2) After returning to the main program, when the type variable itself is put in the watch window, the "parentvariable" is not displayed correctly. Instead of array bounds 1 to 2, it shows as parentvariable(0) with value 0.
(3) child3_var%parentvariable gives "invalid structure".
Regarding point (2) above, I have to put child3_var(1) in the watch-window. If I put jus child3_var, the expanded tree would should only one array element but with element 0. The corresponding value of the parentvariable(0) is displayed as 6369624.
Abhi
p.s. Also I tested the program with XLFortran and it does print 3, 4 as expected.
I also notice that the debugger does not display the correct information.
For example,
(1) Just after the allocation in Child2ProcedureSub, debuger shows this%child1%parent%parentvariable as undefined pointer/array.
(2) After returning to the main program, when the type variable itself is put in the watch window, the "parentvariable" is not displayed correctly. Instead of array bounds 1 to 2, it shows as parentvariable(0) with value 0.
(3) child3_var%parentvariable gives "invalid structure".
Regarding point (2) above, I have to put child3_var(1) in the watch-window. If I put jus child3_var, the expanded tree would should only one array element but with element 0. The corresponding value of the parentvariable(0) is displayed as 6369624.
Abhi
p.s. Also I tested the program with XLFortran and it does print 3, 4 as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I noticed that as well and included that in my report. The pointer is displayed incorrectly even before it is allocated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
Yes, I noticed that as well and included that in my report. The pointer is displayed incorrectly even before it is allocated.
Indeed, although it does not display correctly in debug mode, it does work. That's why I'm printing the results in the screen. I believe it was reported before by someone else, at least I remember reading about it. I did notice this behavior, but since it was already reported, and the developers notified, I'm expecting that this bug willl be corrected in the next update.
Actually, why Fortran doesn't have a function like TRACE? It would help a lot.
Regards,
Roger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is TRACE?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
What is TRACE?
TRACE is a diagnosis C function that writesout the stack in debug mode. It works only in debug mode, and is a print-like function, but the standard (and only) output is the IDE output window. I notice that there is a similar function in Fortran, but I have not tried it yet: TRACEBACKQQ
Regards,
Roger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem originally reported has been fixed in our sources. I expect the fix to appear in Update 5, scheduled for late January.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure why the fix did not appear in Update 5, but it is in 11.1 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