<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — Debugging OOP]]></title>
		<link>https://forums.approximatrix.com/viewtopic.php?id=518</link>
		<atom:link href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=518&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Debugging OOP.]]></description>
		<lastBuildDate>Fri, 23 Dec 2016 00:22:56 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2714#p2714</link>
			<description><![CDATA[<p>I was wrong, the debugger did not freeze up. My program was waiting for a text input but the dialog window was covered up by the other windows. My apologies. Great product.</p>]]></description>
			<author><![CDATA[null@example.com (tun_day)]]></author>
			<pubDate>Fri, 23 Dec 2016 00:22:56 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2714#p2714</guid>
		</item>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2710#p2710</link>
			<description><![CDATA[<p>By &quot;freeze-up,&quot; what exactly do you mean?&nbsp; If you wish, you can send along some example code that causes this behavior, and we&#039;ll be happy to sort the bug out.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Thu, 08 Dec 2016 21:35:11 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2710#p2710</guid>
		</item>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2709#p2709</link>
			<description><![CDATA[<p>I am having the debugger freeze-up problem with version 2.31 build 2290 GNU Fortran 6.1.0. My code is all Fortran 77 with the exception of the main subroutine.</p>]]></description>
			<author><![CDATA[null@example.com (tun_day)]]></author>
			<pubDate>Thu, 08 Dec 2016 20:10:45 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2709#p2709</guid>
		</item>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2436#p2436</link>
			<description><![CDATA[<p>I can confirm this is now working. Thanks very much Jeff.</p>]]></description>
			<author><![CDATA[null@example.com (davidb)]]></author>
			<pubDate>Tue, 22 Mar 2016 10:12:33 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2436#p2436</guid>
		</item>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2368#p2368</link>
			<description><![CDATA[<p>Jeff,</p><p>Thanks. I will wait for 2.26.</p>]]></description>
			<author><![CDATA[null@example.com (davidb)]]></author>
			<pubDate>Sat, 13 Feb 2016 22:17:28 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2368#p2368</guid>
		</item>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2367#p2367</link>
			<description><![CDATA[<p>David,</p><p>The problem was due to the internal definition of abstract variables in the GNU debugger for Fortran.&nbsp; For some reason, the &quot;type&quot; of an abstract variable contained a pointer to its parent type, and it&#039;s parent type was itself.&nbsp; When it attempts to perform the necessary bookkeeping for our front end, it walks up the tree of types, but, as I mentioned, the parent type was itself.&nbsp; This climbing the tree, therefore, caused an infinite loop within GDB itself.&nbsp; Simply cutting off the infinite loop by making sure the parent type isn&#039;t itself seems to fix the problem with locking up.&nbsp; I&#039;ll be making sure there are no other side effects over the next few days, and version 2.26 will contain the corrected debugger.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Fri, 12 Feb 2016 19:15:09 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2367#p2367</guid>
		</item>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2363#p2363</link>
			<description><![CDATA[<p>David,</p><p>They are supposedly supported in development versions, but it seems that they are not treated the same as other variables as far as I can tell.&nbsp; However, the problem with abstract variables seems to persist in the development version.&nbsp; For that reason, I&#039;ll probably proceed with fixing the version we ship for consistency.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Thu, 11 Feb 2016 14:56:58 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2363#p2363</guid>
		</item>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2362#p2362</link>
			<description><![CDATA[<p>Jeff,</p><p>It would be great if something could be done. Maybe allocatable variables are supported now on the main branch?</p>]]></description>
			<author><![CDATA[null@example.com (davidb)]]></author>
			<pubDate>Thu, 11 Feb 2016 14:48:09 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2362#p2362</guid>
		</item>
		<item>
			<title><![CDATA[Re: Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2342#p2342</link>
			<description><![CDATA[<p>David,</p><p>The underlying debugger, GNU Debugger, is apparently failing when trying to analyze the variable <strong>bundle</strong> declared as an abstract class.&nbsp; You&#039;ll notice that under &quot;Variables&quot; on the Debugging panel, the variables <strong>bundle</strong> and all other locals following it alphabetically are not listed.&nbsp; Furthermore, GDB is completely locking up while trying to deal with this error.&nbsp; I&#039;ll have to look into what&#039;s gone wrong; we&#039;re not using mainline GDB with Simply Fortran because mainline GDB was not supporting allocatable variables a year or more back.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Mon, 01 Feb 2016 17:47:40 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2342#p2342</guid>
		</item>
		<item>
			<title><![CDATA[Debugging OOP]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=2336#p2336</link>
			<description><![CDATA[<p>I am getting back into OOP but in Fortran 2003. I have the following code, which solves a non-linear equation f(x) = x^2 - 1<br />using bisection on an initial interval 0 to 2 (the correct result is 1 of course).</p><p>I am using a type data_t to setup the various constants needed by the function being solved. This is derived from the abstract class bundle_t (which has no components). The solve subroutine passes values of x (trial solutions) and the bundle variable (which happens to have the dynamic type of data_t) to the function. Bisection is used to get the solution.</p><p>I am doing it this was so I can solve any function by providing the correct f and a suitable extended type. At the moment everything is in 1 file. But eventually I will separate the &quot;utility&quot; module from the &quot;user problem&quot; module in separate files.</p><p>I am quite sure the code is correct and it does work.</p><p>However, I cannot trace execution through the solve function using the debugger. The code just freezes when I step into it, and it won&#039;t step again or continue. Any ideas?</p><div class="codebox"><pre><code>module solver

   ! Abstract type, problem data type is an extension of this.
   type, abstract :: bundle_t
   end type bundle_t
   
contains

   function solve(f, a, b, bundle)
   
      double precision, intent(in) :: a, b
      ! Next variable is of type bundle_t or any extended type of bundle_t
      class(bundle_t), intent(in) :: bundle
      interface
         function f(x, bundle)
            import
            double precision, intent(in) :: x
            class(bundle_t), intent(in) :: bundle
            double precision :: f
         end function f
      end interface
      double precision :: solve
      
      double precision :: xlo, xhi, x, flo, fhi, fn
      
      ! Bisection (I&#039;m assuming a &gt;= b)
      xlo = a
      xhi = b
      flo = f(xlo, bundle)
      fhi = f(xhi, bundle)
      do
         x = 0.5d0*(xlo + xhi)      
         fn = f(x, bundle)
         if (fn &gt; 0.0d0 .eqv. fhi &gt; flo) then
            xhi = x
         else
            xlo = x
         end if
         if (xhi - xlo &lt; 1.0d-5) exit
      end do

      solve = x

   end function solve
   
end module solver

module problem

   use solver

   private

   ! An extended data type is created to store the &quot;problem data&quot;.
   type, extends(bundle_t) :: data_t
      double precision :: c
   end type data_t
   
   public :: xxx

contains

   subroutine xxx
   
      type(data_t) :: data
   
      ! The constant in the equation to be solved.
      data%c = 1.0d0
   
      print *, solve(f, 0.0d0, 2.0d0, data)
      
   end subroutine xxx

   function f(x, bundle)
      double precision, intent(in) :: x
      class(bundle_t), intent(in) :: bundle
      double precision :: f
      select type (bundle)
      type is (data_t)
      f = x**2 - bundle%c
      end select
   end function f

end module problem

program anon

   use problem
   
   call xxx
   
end program anon</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (davidb)]]></author>
			<pubDate>Fri, 29 Jan 2016 19:08:53 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=2336#p2336</guid>
		</item>
	</channel>
</rss>
