totalview 只识别一些变量,可执行行
totalview only recognizes some variables, executable lines
如何让 totalview 提供对我代码中所有变量的访问权限?
我正在尝试使用 totalview 调试 Fortran90 程序。我使用“-g”标志编译并链接了英特尔的 ifort。 totalview 可以单步执行我的程序,但只为我的子程序中的四个变量提供 "dive",而且许多可执行源代码行没有我可以检查以设置操作点的框。在下面声明的所有变量中,只有 cell_EW、cell_NS、area 和 pct 可用于稍后在子例程中潜水。
164 REAL, allocatable, DIMENSION(:), INTENT(in) :: lon, lat
165 REAL, ALLOCATABLE, DIMENSION(:, :, :, :) :: area, pct
166 REAL, ALLOCATABLE, DIMENSION(:, :, :), INTENT(in) :: in_flux
167 REAL, ALLOCATABLE, DIMENSION(:, :, :), INTENT(inout) :: out_flux
168 REAL :: cell_EW, cell_NS
169 INTEGER status, ierr, dimid, nlon, nlat, ntimes
170 INTEGER i, j, k, LOGDEV, this_var, this_t
171 INTEGER jdate, jtime, this_date, this_time
再举个例子:190行不允许我设置动作点,ntimes无法识别为变量
189 CALL calc_land_area(pct, cell_EW, cell_NS, lon, lat, area)
190 ntimes = SIZE(in_flux, 1) ! first dimension is time
191 do i = 1, ntimes
当变量在 gdb 和 totalview 等检查工具中不可用时,通常是因为编译器已将它们优化掉。这在 totalview faq
中有所暗示
Don't compile your program with optimization flags while you are
debugging it. Compiler optimizations can "rewrite" your program and
produce machine code that doesn't necessarily match your source code.
由于不同的编译器具有不同的默认优化级别(并且可能 -g
可能具有除了包含符号之外的其他含义)通常最好包含显式的 -O0
或等效项以便禁用任何优化。某些编译器(例如 gfortran 版本 >= v4.8)使用 -Og
标志提供特定的调试优化级别,如本 answer 中所述。这允许在不影响调试能力的情况下进行优化。
如何让 totalview 提供对我代码中所有变量的访问权限?
我正在尝试使用 totalview 调试 Fortran90 程序。我使用“-g”标志编译并链接了英特尔的 ifort。 totalview 可以单步执行我的程序,但只为我的子程序中的四个变量提供 "dive",而且许多可执行源代码行没有我可以检查以设置操作点的框。在下面声明的所有变量中,只有 cell_EW、cell_NS、area 和 pct 可用于稍后在子例程中潜水。
164 REAL, allocatable, DIMENSION(:), INTENT(in) :: lon, lat
165 REAL, ALLOCATABLE, DIMENSION(:, :, :, :) :: area, pct
166 REAL, ALLOCATABLE, DIMENSION(:, :, :), INTENT(in) :: in_flux
167 REAL, ALLOCATABLE, DIMENSION(:, :, :), INTENT(inout) :: out_flux
168 REAL :: cell_EW, cell_NS
169 INTEGER status, ierr, dimid, nlon, nlat, ntimes
170 INTEGER i, j, k, LOGDEV, this_var, this_t
171 INTEGER jdate, jtime, this_date, this_time
再举个例子:190行不允许我设置动作点,ntimes无法识别为变量
189 CALL calc_land_area(pct, cell_EW, cell_NS, lon, lat, area)
190 ntimes = SIZE(in_flux, 1) ! first dimension is time
191 do i = 1, ntimes
当变量在 gdb 和 totalview 等检查工具中不可用时,通常是因为编译器已将它们优化掉。这在 totalview faq
中有所暗示Don't compile your program with optimization flags while you are debugging it. Compiler optimizations can "rewrite" your program and produce machine code that doesn't necessarily match your source code.
由于不同的编译器具有不同的默认优化级别(并且可能 -g
可能具有除了包含符号之外的其他含义)通常最好包含显式的 -O0
或等效项以便禁用任何优化。某些编译器(例如 gfortran 版本 >= v4.8)使用 -Og
标志提供特定的调试优化级别,如本 answer 中所述。这允许在不影响调试能力的情况下进行优化。