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)
我有一个关于fortran文件调试的问题。因此我用d(*)自动声明它。但是在调试和监视数组期间,它只显示相应数组的第一个数字而不是其他60个数字。 (我使用Fortran 95编译器和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.
ia是主程序中的变量整数,具体取决于某些输入参数。
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(*)
但是对于调试,了解d(*)的有效性很有用
1 个解决方案
#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:
我发现这样做的唯一方法是使用Watch窗口并为数组元素添加监视。假设您的数组被称为d,那么我发现观察以下表达式会显示数组中的值:
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
当然,对于一个长度为60的数组,如你所建议的,那么表达式
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.
当然,你应该将你的数组声明为d(:)。如果这样做,那么VS调试器会在通常的Locals窗口中显示整个数组。
#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:
我发现这样做的唯一方法是使用Watch窗口并为数组元素添加监视。假设您的数组被称为d,那么我发现观察以下表达式会显示数组中的值:
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
当然,对于一个长度为60的数组,如你所建议的,那么表达式
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.
当然,你应该将你的数组声明为d(:)。如果这样做,那么VS调试器会在通常的Locals窗口中显示整个数组。