How can I make totalview offer access to all the variables in my code?
I'm trying to debug a Fortran90 program using totalview. I compiled and linked with Intel's ifort, using the "-g" flag. totalview can step through my program, but only offers "dive" for four of the variables in my subroutine, and many executable source lines have no box I can check to set an action point. Of all the variables declared below, only cell_EW, cell_NS, area, and pct are available to dive later in the subroutine.
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
another example: line 190 does not allow me to set an action point, and ntimes is unrecognized as a variable.
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
When variables are not available in inspection tools like gdb and totalview it's often because the compiler has optimised them away. This is hinted at in the totalview faq
As different compilers have different default optimisation levels (and potentially
-gmay have additional implications other than just including symbols) it's usually a good idea to include an explicit-O0or equivalent in order to disable any optimisation. Some compilers (e.g. gfortran version >= v4.8) provide a specific debugging optimisation level with the-Ogflag as noted in this answer. This allows optimisations that don't impact on the ability to debug.