- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When attempting to look at the value of a variable length character array (not sure if this is the correct name) in the debugger all I get is “Undefined Pointer/Array” – even after I’ve assigned to it. The value held is correct; it is purely the value in the debugger which is not showing. This only seems to occur for variables local to a routine; I can see the values if they are declared as a module variable or by adding the save attribute in the routine declaration.
I’m using VS2012 and the latest compiler update – any suggestions?
I’m declaring within a subroutine like this:
[fortran]
CHARACTER(LEN=:), ALLOCATABLE :: tmp1 ! Undefined Pointer/Array in debugger
CHARACTER(LEN=:), ALLOCATABLE, SAVE :: tmp2 ! Works fine
[/fortran]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alas I find such problems are routiine. VS2012 seems a lot worse than VS2010. Here are a couple of tricks you can resort to.
In a watch window, it often helps to type the name of the variable twice. The debugger won't show you the first one, but the addition of an identical copy can convince it to change its mind.
In your situation however that probably won't help. So, another option is to modify the code. Add an ASSOCIATE statement to create an alias name for the variable of interest. Make sure you do this after it has been allocated. The main variable may remain invisible, but its alias is usually OK. Same trick works by creating a pointer.
In fact in general the debugger seems far more willing to show you the value of a pointer, compared to an allocatable. So in your example, use a pointer instead of an allocatable.
Isn't it sad we Fortran programmers have to resort to such underhand tricks? My theory is that its all a conspiracy by C programmers. After all, its they who write all the complers and debuggers... ;-)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page