<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — Debugging OOP]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=518&amp;type=atom" />
	<updated>2016-12-23T00:22:56Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=518</id>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2714#p2714" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[tun_day]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3696</uri>
			</author>
			<updated>2016-12-23T00:22:56Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2714#p2714</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2710#p2710" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2016-12-08T21:35:11Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2710#p2710</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2709#p2709" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[tun_day]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3696</uri>
			</author>
			<updated>2016-12-08T20:10:45Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2709#p2709</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2436#p2436" />
			<content type="html"><![CDATA[<p>I can confirm this is now working. Thanks very much Jeff.</p>]]></content>
			<author>
				<name><![CDATA[davidb]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3463</uri>
			</author>
			<updated>2016-03-22T10:12:33Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2436#p2436</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2368#p2368" />
			<content type="html"><![CDATA[<p>Jeff,</p><p>Thanks. I will wait for 2.26.</p>]]></content>
			<author>
				<name><![CDATA[davidb]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3463</uri>
			</author>
			<updated>2016-02-13T22:17:28Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2368#p2368</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2367#p2367" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2016-02-12T19:15:09Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2367#p2367</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2363#p2363" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2016-02-11T14:56:58Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2363#p2363</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2362#p2362" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[davidb]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3463</uri>
			</author>
			<updated>2016-02-11T14:48:09Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2362#p2362</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2342#p2342" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2016-02-01T17:47:40Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2342#p2342</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Debugging OOP]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2336#p2336" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[davidb]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3463</uri>
			</author>
			<updated>2016-01-29T19:08:53Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2336#p2336</id>
		</entry>
</feed>
