YaY*_*YaY 6 arrays debugging fortran visual-studio
我有一个关于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
Run Code Online (Sandbox Code Playgroud)
但是对于调试,知道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
Run Code Online (Sandbox Code Playgroud)
当然,对于长度为 60 的数组(如您建议的那样),则表达式
d(61)
Run Code Online (Sandbox Code Playgroud)
将显示该数组地址指向的内存位置中的值。
当然,您确实应该将数组声明为d(:). 如果这样做,VS 调试器会在常用窗口中显示整个数组Locals。