我有一个关于调试 fortran 文件的问题。因此我用 d(*) 自动声明了它。然而,在调试和数组监督期间,它只显示相应数组的第一个数字,而不是其他 60 个。
(我使用 Fortran 95 编译器和 Visual Studio 2010)
我怎样才能查看数组的所有变量?
好的,这是代码的一个示例:
ia 是来自主程序的变量整数,取决于某些输入参数。
subroutine abc(ia,a,b,c)
dimension d(*)
a = d(ia+1)
b = d(ia+2)
c = d(ia+3)
return
end
但是对于调试,了解 d(*) 的端点很有用
最佳答案
我发现这样做的唯一方法是使用 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
当然,对于长度为 60 的数组,如您建议的那样,则表达式
d(61)
将显示该数组地址指向的内存位置中的值。
当然,您真的应该将数组声明为
d(:)
.如果这样做,那么 VS 调试器会在通常的 Locals
中显示整个数组。 window 。
关于arrays - Fortran 和 Visual Studio 调试中的自动数组长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13563998/