I am debugging the following Fortran code on Microsoft Visual Studio 2012+Intel Visual Fortran:
program customarray
implicit none
real, allocatable, dimension(:):: vector
integer :: nelements, i
real :: sum
print *, 'enter how many values you have'
read *, nelements
allocate(vector(nelements))
print *, 'enter the values'
sum = 0.0
do i=1,nelements
read *, vector(i)
sum = sum+vector(i)
end do
end program customarray
As I step through the code using the debugger "step into" tool. Everything runs as expected. However as soon as I reach the very last line
end program customarray
I get a the following dialog box:
I don't understand why I am getting this error. I am frustrated because it runs smoothly when I "Run without debugging" and does not display the same error.
After the
end program
withStep Into
you are entering the code generated by the compiler to finish the program run and return to Windows.Step Into
will enter any function executed by the program, even internal libraries (might be set-up slightly differently for Fortran). See "Step Over" and "Step Into" in Visual StudioWith
Step Over
orStep Out
you should be able to skip this finishing internal code, but withStep Into
you are asking the debugger to take you there.And, of course, no source is available in that region, because that code executed there is not your user code. It may or may not be compiled C code or even parts of machine code directly inserted there by the compiler.
Similar behaviour can happen at the start of the
program
. You can also enter the procedures executed by the program when preparing the environment to be able to execute your code. If you just want to debug your code, start debugging at a line corresponding to your executable statement.