Silverfrost Forums

Welcome to our forums

Please add function result to list of variables

5 Mar 2023 1:33 #29990

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.

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
5 Mar 2023 5:25 #29991

I will look into it

Please login to reply.