6

I got a question concerning the debugging of a fortran file. Thus I declared it with d(*) automaticaly. However during the debugging and the supervision of the array it just shows the first number of the according array and not the 60 others. (I use Fortran 95 compiler and Visual Studio 2010)

How can I still view all variables of the array?


Okay here comes one example for the code:

ia is a variable integer from the main routine depending on some input parameters.

subroutine abc(ia,a,b,c)
dimension d(*)

a = d(ia+1)
b = d(ia+2)
c = d(ia+3)

return 
end

However for debugging it is useful to know the endities of d(*)

5
  • I do not understand what you really did, I only guess. Show us some code. Note that the (*), so called assumed size arrays do not automatically set the size of the array in any way. Commented Nov 26, 2012 at 11:58
  • You don't need to include signature in your post - your user card is added automatically. Read FAQ for more details. Commented Nov 26, 2012 at 12:11
  • Since you have to provide the array size somehow (e.g. in an additional argument), you can use adjustable arrays. Instead of REAL d(*) use REAL d(nsize) where nsize is an INTEGER argument, in which you pass the true size of d in number of elements (REAL here is just an example data type). Then the debugger should be able to show you the content of the whole array. Commented Nov 26, 2012 at 13:23
  • +1 for using a language for real programmers :-) Commented Nov 26, 2012 at 14:05
  • Next time I must enough general tags to get more votes for an "exotic" language. Commented Nov 26, 2012 at 14:20

1 Answer 1

1

The only way I've found to do this is to use the Watch window and add a watch for the array elements. Suppose your array is called d, then I've found that watching the following expressions shows the values in the array:

d(2)      ! which just shows the 2nd element in the array
d(1:10)   ! which shows the first 10 elements of the array
d(1:12:2) ! which shows the odd numbered elements of the array from 1 to 11

And of course, for an array of length 60 such as you suggest you have, then the expression

d(61)

will show you what value is in the memory location to which that array address points.

Of course, you should really be declaring your array as d(:). If you do, then the VS debugger shows the entire array in the usual Locals window.

Sign up to request clarification or add additional context in comments.

3 Comments

Automatic arrays are local arrays, not dummy arguments.
Otherwise +1, assumed shape arrays will be better, because the subroutine knows the array size. OP didn't show any code so one can only guess that he talks about procedure arguments.
Adjustable arrays are also an option when one does not really want to "pollute" old F77 code with Fortran 90+ features (please, spare me the discussion about "no such thing as pure F77 compiler, they all implement one or another feature that later become part of F90" and so on)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.