<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Overring intrinsic procedures with type bound procedures in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830349#M52141</link>
    <description>In F2003 (not yet IVF) there is overiding for operators and assignment using type bound procedures but how about intrinsics?&lt;BR /&gt;&lt;BR /&gt;When we have a type bound precedure we must call using % notation as below. But this will mean we do not overide the intrinsic. Or am I wrong?&lt;BR /&gt;&lt;BR /&gt;MODULE x&lt;BR /&gt;&lt;BR /&gt;TYPE y&lt;BR /&gt; REAL z&lt;BR /&gt; CONTAINS&lt;BR /&gt; PROCEDURE abs =&amp;gt; ABS_a&lt;BR /&gt;END TYPE&lt;BR /&gt;&lt;BR /&gt;CONTAINS&lt;BR /&gt;&lt;BR /&gt;CLASS(y) FUNCTION ABS_a(me)&lt;BR /&gt; CLASS(y), INTENT(IN) :: me&lt;BR /&gt; ABS_a%z = ABS(me.z)&lt;BR /&gt;END FUNCTION&lt;BR /&gt;&lt;BR /&gt;END MODULE&lt;BR /&gt;&lt;BR /&gt;PROGRAM TEST&lt;BR /&gt; TYPE(y) a, b&lt;BR /&gt; a%z = -1.0&lt;BR /&gt; b = abs(a) !Illegal use of intrinsic abs&lt;BR /&gt; b = a%abs !Will use type bound procedure&lt;BR /&gt;END PROGRAM</description>
    <pubDate>Fri, 03 Sep 2010 08:00:42 GMT</pubDate>
    <dc:creator>Andrew_Smith</dc:creator>
    <dc:date>2010-09-03T08:00:42Z</dc:date>
    <item>
      <title>Overring intrinsic procedures with type bound procedures</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830349#M52141</link>
      <description>In F2003 (not yet IVF) there is overiding for operators and assignment using type bound procedures but how about intrinsics?&lt;BR /&gt;&lt;BR /&gt;When we have a type bound precedure we must call using % notation as below. But this will mean we do not overide the intrinsic. Or am I wrong?&lt;BR /&gt;&lt;BR /&gt;MODULE x&lt;BR /&gt;&lt;BR /&gt;TYPE y&lt;BR /&gt; REAL z&lt;BR /&gt; CONTAINS&lt;BR /&gt; PROCEDURE abs =&amp;gt; ABS_a&lt;BR /&gt;END TYPE&lt;BR /&gt;&lt;BR /&gt;CONTAINS&lt;BR /&gt;&lt;BR /&gt;CLASS(y) FUNCTION ABS_a(me)&lt;BR /&gt; CLASS(y), INTENT(IN) :: me&lt;BR /&gt; ABS_a%z = ABS(me.z)&lt;BR /&gt;END FUNCTION&lt;BR /&gt;&lt;BR /&gt;END MODULE&lt;BR /&gt;&lt;BR /&gt;PROGRAM TEST&lt;BR /&gt; TYPE(y) a, b&lt;BR /&gt; a%z = -1.0&lt;BR /&gt; b = abs(a) !Illegal use of intrinsic abs&lt;BR /&gt; b = a%abs !Will use type bound procedure&lt;BR /&gt;END PROGRAM</description>
      <pubDate>Fri, 03 Sep 2010 08:00:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830349#M52141</guid>
      <dc:creator>Andrew_Smith</dc:creator>
      <dc:date>2010-09-03T08:00:42Z</dc:date>
    </item>
    <item>
      <title>Overring intrinsic procedures with type bound procedures</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830350#M52142</link>
      <description>I believe you are right. To actually "override" the intrinsic you would need to provide the usual generic interface. The specific procedure would be selected on the basis of the declared type of the argument. This specific procedure could then forward the call to the appropriate type bound procedure.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]MODULE x
  TYPE y
    REAL z
  CONTAINS
    PROCEDURE :: abs =&amp;gt; ABS_a
  END TYPE

  ! So the intrinsic behaves like we'd expect.
  INTERFACE Abs
    PROCEDURE abs_forwarder
  END INTERFACE Abs
CONTAINS
  ! gets called when dynamic type of me is a y
  FUNCTION ABS_a(me) RESULT
    CLASS(y), INTENT(IN) :: me
    CLASS(y), ALLOCATABLE :: r
    !****
    ALLOCATE(y:: r)
    r%z = ABS(me%z)
  END FUNCTION

  ! gets called when declared type of me is a y
  FUNCTION abs_forwarder(me) RESULT
    CLASS(y), INTENT(IN) :: me
    CLASS(y), ALLOCATABLE :: r
    !****
    ! polymorphic call to abs, which might go to ABS_a or equivalent override 
    ! in an extension of y.  F2008 allows assignment here?
    ALLOCATE(r, SOURCE=me%abs)
  END FUNCTION abs_forwarder
END MODULE x    
    [/fortran]&lt;/PRE&gt;

But don't be surprised if I'm totally wrong :).</description>
      <pubDate>Fri, 03 Sep 2010 08:51:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830350#M52142</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2010-09-03T08:51:27Z</dc:date>
    </item>
    <item>
      <title>Overring intrinsic procedures with type bound procedures</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830351#M52143</link>
      <description>Why the allocate statements? Isn't the variable r that holds the function value already allocated?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Arjen</description>
      <pubDate>Fri, 03 Sep 2010 08:55:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830351#M52143</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2010-09-03T08:55:44Z</dc:date>
    </item>
    <item>
      <title>Overring intrinsic procedures with type bound procedures</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830352#M52144</link>
      <description>&lt;P&gt;module module_x&lt;/P&gt;&lt;P&gt;implicit none&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type, public:: y&lt;/P&gt;&lt;P&gt;real:: z&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;procedure, pass:: abs =&amp;gt; abs_a&lt;/P&gt;&lt;P&gt;end type&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;type(y) function abs_a(me)&lt;/P&gt;&lt;P&gt;implicit none&lt;/P&gt;&lt;P&gt;class(y), intent(in) :: me&lt;/P&gt;&lt;P&gt;abs_a % z = abs(me % z)&lt;/P&gt;&lt;P&gt;return&lt;/P&gt;&lt;P&gt;end function&lt;/P&gt;&lt;P&gt;end module&lt;/P&gt;&lt;P&gt;program test&lt;/P&gt;&lt;P&gt;use module_x&lt;/P&gt;&lt;P&gt;implicit none&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type(y):: a, b&lt;/P&gt;&lt;P&gt;a % z = -1.0&lt;/P&gt;&lt;P&gt;b = abs_a(a) &lt;/P&gt;&lt;P&gt;b = a % abs() ! type bound procedure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;stop&lt;/P&gt;&lt;P&gt;end program&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2010 10:51:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830352#M52144</guid>
      <dc:creator>asymptotic</dc:creator>
      <dc:date>2010-09-03T10:51:41Z</dc:date>
    </item>
    <item>
      <title>Overring intrinsic procedures with type bound procedures</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830353#M52145</link>
      <description>It seams to me that it would have made sence if F2003 or F2008 said that intrinsic procedures should be callable as type bound procedures too, then we could all adopt the new % notation for calling stuff.</description>
      <pubDate>Sat, 04 Sep 2010 19:55:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Overring-intrinsic-procedures-with-type-bound-procedures/m-p/830353#M52145</guid>
      <dc:creator>Andrew_Smith</dc:creator>
      <dc:date>2010-09-04T19:55:18Z</dc:date>
    </item>
  </channel>
</rss>

