![](/img/trans.png)
[英]Converting a variable length c-string to Fortran string in Visual Studio
[英]Automatic array length in Fortran and Visual Studio debug
我有一個關於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
窗口中顯示整個數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.