mecej4
Joined: 31 Oct 2006 Posts: 1896
|
Posted: Sun Mar 05, 2023 2:33 pm Post subject: Please add function result to list of variables |
|
|
Inside the body of a non-recursive function, the name of the function may be used as an ordinary variable in expressions, I/O lists, etc. In some codes such as SLATEC, there are functions in which the result variable is used and updated several times in the body of the function before returning from the function. Other Fortran symbolic debuggers (VS+Ifort, Absoft+FX2, for example) include the function name in the list of variables whose values may be seen in a Variables pane, or by hovering the mouse on the variable. SDBG does not do so.
Here is an example that may clarify the issue. Run it in SDBG/SDBG64 and try to observe what is going on in the subroutine. Notice that the return variable FIB is updated several times inside the function, which is entered only once, but we are unable to observe the changes in the value of FIB.
Code: | program tfibonacci
implicit none
print *,fib(10)
contains
integer function fib(n) ! not recursive
integer n, sp, spp, i
if (n < 3) then
fib = n-1
return
endif
spp = 0
sp = 1
do i = 3, n
fib = spp + sp
spp = sp
sp = fib
end do
return
end function fib
end program tfibonacci |
|
|