<?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 Interface of an internal module function as class constructor in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830553#M52233</link>
    <description>I got it to work with 12.0.3 if I renamed the generic interface and derived type to something other than shape (clash with the intrinsic?) and added the module keyword to the procedure-stmt.</description>
    <pubDate>Wed, 04 May 2011 05:14:33 GMT</pubDate>
    <dc:creator>IanH</dc:creator>
    <dc:date>2011-05-04T05:14:33Z</dc:date>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830551#M52231</link>
      <description>I am trying to compile the following code with Intel Fortran 11.1, where I would like to have the constructor function to be called by a function with the same name of my class.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;************************************** shape.f90 ************************************** &lt;BR /&gt;module shape_mod&lt;BR /&gt; private ! hide the type-bound procedure implementation procedures&lt;BR /&gt; public :: shape ! allow access to shape &amp;amp; constructor procedure&lt;BR /&gt;&lt;BR /&gt; type shape&lt;BR /&gt;  private ! hide the underlying details&lt;BR /&gt;   integer :: color&lt;BR /&gt;   logical :: filled&lt;BR /&gt;   integer :: x&lt;BR /&gt;   integer :: y&lt;BR /&gt;  contains&lt;BR /&gt;  private ! hide the type bound procedures by default&lt;BR /&gt;  procedure :: initShape ! private type-bound procedure&lt;BR /&gt;  procedure, public :: isFilled ! allow access to isFilled type-bound procedure&lt;BR /&gt;  procedure, public :: print ! allow access to print type-bound procedure&lt;BR /&gt; end type shape&lt;BR /&gt;&lt;BR /&gt; interface shape&lt;BR /&gt;  procedure constructor&lt;BR /&gt; end interface&lt;BR /&gt;&lt;BR /&gt; contains&lt;BR /&gt;&lt;BR /&gt; function constructor(color, filled, x, y)&lt;BR /&gt;  type(shape) :: constructor&lt;BR /&gt;  integer :: color&lt;BR /&gt;  logical :: filled&lt;BR /&gt;  integer :: x&lt;BR /&gt;  integer :: y&lt;BR /&gt;  call constructor%initShape(color, filled, x, y)&lt;BR /&gt; end function&lt;BR /&gt;&lt;BR /&gt; logical function isFilled(this)&lt;BR /&gt;  class(shape) :: this&lt;BR /&gt;  isFilled = this%filled&lt;BR /&gt; end function&lt;BR /&gt;&lt;BR /&gt; subroutine initShape(this, color, filled, x, y)&lt;BR /&gt;  ! initialize shape objects&lt;BR /&gt;  class(shape) :: this&lt;BR /&gt;  integer :: color&lt;BR /&gt;  logical :: filled&lt;BR /&gt;  integer :: x&lt;BR /&gt;  integer :: y&lt;BR /&gt;&lt;BR /&gt;  this%color = color&lt;BR /&gt;  this%filled = filled&lt;BR /&gt;  this%x = x&lt;BR /&gt;  this%y = y&lt;BR /&gt; end subroutine&lt;BR /&gt;&lt;BR /&gt; subroutine print(this)&lt;BR /&gt;  class(shape) :: this&lt;BR /&gt;  print *, this%color, this%filled, this%x, this%y&lt;BR /&gt; end subroutine&lt;BR /&gt;end module&lt;BR /&gt;&lt;BR /&gt;program shape_prg&lt;BR /&gt; use shape_mod&lt;BR /&gt; type(shape) :: sh&lt;BR /&gt; logical filled&lt;BR /&gt; sh = shape(5, .true., 100, 200) ! invoke constructor through shape generic interface&lt;BR /&gt; call sh%print()&lt;BR /&gt;end&lt;BR /&gt;************************************** shape.f90 ************************************** &lt;BR /&gt;&lt;BR /&gt;But I am getting the following error:&lt;BR /&gt;&lt;BR /&gt;*************************************************************************************&lt;BR /&gt;d:\\lc\\shape\\src&amp;gt; ifort shape.f90&lt;BR /&gt;Intel Visual Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100414 Package ID: w_cprof_p_11.1.065&lt;BR /&gt;Copyright (C) 1985-2010 Intel Corporation. All rights reserved.&lt;BR /&gt;&lt;BR /&gt;shape.f90(19): error #6643: This statement is incorrectly positioned.&lt;BR /&gt; procedure constructor&lt;BR /&gt;----------------^&lt;BR /&gt;shape.f90(19): error #8168: Parentheses are required after the PROCEDURE keyword.&lt;BR /&gt; procedure constructor&lt;BR /&gt;----------------^&lt;BR /&gt;shape.f90(62): error #6296: The type of this structure constructor is use associated with the PRIVATE fields attribute&lt;BR /&gt;[SHAPE]&lt;BR /&gt; sh = shape(5, .true., 100, 200) ! invoke constructor through shape generic interface&lt;BR /&gt;-------------^&lt;BR /&gt;compilation aborted for shape.f90 (code 1)&lt;BR /&gt;*************************************************************************************&lt;BR /&gt;&lt;BR /&gt;What am I doing wrong?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;Luiz</description>
      <pubDate>Tue, 03 May 2011 23:12:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830551#M52231</guid>
      <dc:creator>lccostajr</dc:creator>
      <dc:date>2011-05-03T23:12:02Z</dc:date>
    </item>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830552#M52232</link>
      <description>I don't think you're doing anything wrong. I know that the 11.1 and 12.0 compiler does not accept "procedure" in a generic interface. The 12.0 compiler actually does worse on this, triggering an internal compiler error. I already have a bug report filed on this - I will verify that yours is the same issue.</description>
      <pubDate>Wed, 04 May 2011 00:25:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830552#M52232</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-05-04T00:25:41Z</dc:date>
    </item>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830553#M52233</link>
      <description>I got it to work with 12.0.3 if I renamed the generic interface and derived type to something other than shape (clash with the intrinsic?) and added the module keyword to the procedure-stmt.</description>
      <pubDate>Wed, 04 May 2011 05:14:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830553#M52233</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2011-05-04T05:14:33Z</dc:date>
    </item>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830554#M52234</link>
      <description>It is indeed the intrinsic SHAPE that is conflicting here, though the compiler's response to that is not very nice. I will report that. Issue ID is DPD200169073.&lt;BR /&gt;&lt;BR /&gt;The standard considers intrinsic procedures and type names to be of the same "local identifier class". It says (F2008, 16.3.1):&lt;BR /&gt;&lt;BR /&gt;"Within its scope, a local identifier of one class shall not be the same as another local identifier of the same class, except that a generic name may be the same as the name of a procedure as explained in 12.4.3.4 or the same name as a derived type (4.5.10)."&lt;BR /&gt;&lt;BR /&gt;So it is fine to have the generic have the same name as the type, but not ok to have the type the same name as an intrinsic. Unfortunately, while the language has a way of "affirming" that an identifier is an intrinsic, it doesn't have a good way of specifying that it is NOT an intrinsic for the purpose of defining a type name.&lt;BR /&gt;&lt;BR /&gt;As Ian writes, Intel Fortran currently insists on the "module" keyword, which will prevent you from using procedure pointers in a generic interface. That has already been reported.</description>
      <pubDate>Wed, 04 May 2011 14:19:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830554#M52234</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-05-04T14:19:43Z</dc:date>
    </item>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830555#M52235</link>
      <description>The compiler is having a bit of a bet both ways then, as 12.0.3 happily accepts:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]PROGRAM ShapeShifter
  IMPLICIT NONE
  
  TYPE :: Shape
    INTEGER :: i
  END TYPE Shape
  TYPE(Shape) :: z

  !***
  
  z%i = 1
  PRINT "(I0)", z%i
  
  z = Shape(i=3)  
  PRINT "(I0)", z%i  
END PROGRAM ShapeShifter
[/fortran]&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 May 2011 01:00:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830555#M52235</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2011-05-05T01:00:03Z</dc:date>
    </item>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830556#M52236</link>
      <description>My explanation was, as "Click and Clack" (The NPR Car Talk guys) would say, BOOOOO-GUSSSS! Something else is going on here and we'll figure out what it is. My point about the MODULE keyword still applies.</description>
      <pubDate>Thu, 05 May 2011 14:19:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830556#M52236</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-05-05T14:19:47Z</dc:date>
    </item>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830557#M52237</link>
      <description>A derived type may have the same name as a generic function. If a reference could be interpreted as either a generic function reference or a structure constructor, it is to be treated as a generic function reference. We arenot doing this right and will fix it.</description>
      <pubDate>Tue, 28 Jun 2011 14:01:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830557#M52237</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-06-28T14:01:22Z</dc:date>
    </item>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830558#M52238</link>
      <description>This problem has been fixed in our sources. The fix will appear in a future update.</description>
      <pubDate>Thu, 08 Sep 2011 17:51:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830558#M52238</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-09-08T17:51:05Z</dc:date>
    </item>
    <item>
      <title>Interface of an internal module function as class constructor</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830559#M52239</link>
      <description>The internal compiler error is fixed in Update 7. You still need the "module" prefix to "procedure" in the interface block - that will be remedied in a future version.</description>
      <pubDate>Thu, 27 Oct 2011 18:40:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interface-of-an-internal-module-function-as-class-constructor/m-p/830559#M52239</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-10-27T18:40:45Z</dc:date>
    </item>
  </channel>
</rss>

