<?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 derived type as a function result in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771039#M22600</link>
    <description>I have found a problem when a function is of a derived type. I have isolated the problem and added it below. Running the command " ifort /warn / traceback filename " the compiler produces error #7977 complaining the the function reference not being the same as the function type. This problem is caused by the compiler that produces an interface for that particular function and adds a result variable to the function definition.&lt;BR /&gt;If I compile with the addition of "/nogen-interfaces" in the command linethere is no problem at all!&lt;BR /&gt;What is going on here? The construction that I use is completely legal (Metcalf pag. 80) as long as the function is non-recursive. I did not encounter a similar problem with a function that has a scalar variable as a function result.&lt;BR /&gt;&lt;BR /&gt;The example:&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;MODULE ctf_mod&lt;/P&gt;&lt;P&gt;TYPE my_type&lt;/P&gt;&lt;P&gt;INTEGER :: i, j&lt;/P&gt;&lt;P&gt;END TYPE my_type&lt;/P&gt;&lt;P&gt;END MODULE ctf_mod&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;PROGRAM ctf&lt;/P&gt;&lt;P&gt;USE ctf_mod&lt;/P&gt;&lt;P&gt;IMPLICIT none&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;TYPE(my_type) :: type_function&lt;/P&gt;&lt;P&gt;TYPE(my_type) :: type_result&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;type_result = type_function(3,8) ! the problem line&lt;/P&gt;&lt;P&gt;write(*,*) 'result:', type_result &lt;/P&gt;&lt;P&gt;STOP&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;TYPE(my_type) FUNCTION type_function(k,l)&lt;/P&gt;&lt;P&gt;USE ctf_mod&lt;/P&gt;&lt;P&gt;IMPLICIT none&lt;/P&gt;&lt;P&gt;INTEGER,INTENT(in) :: k,l&lt;/P&gt;&lt;P&gt;type_function%i=k&lt;/P&gt;&lt;P&gt;type_function%j=l&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jul 2010 07:10:26 GMT</pubDate>
    <dc:creator>Robert_van_Amerongen</dc:creator>
    <dc:date>2010-07-30T07:10:26Z</dc:date>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771039#M22600</link>
      <description>I have found a problem when a function is of a derived type. I have isolated the problem and added it below. Running the command " ifort /warn / traceback filename " the compiler produces error #7977 complaining the the function reference not being the same as the function type. This problem is caused by the compiler that produces an interface for that particular function and adds a result variable to the function definition.&lt;BR /&gt;If I compile with the addition of "/nogen-interfaces" in the command linethere is no problem at all!&lt;BR /&gt;What is going on here? The construction that I use is completely legal (Metcalf pag. 80) as long as the function is non-recursive. I did not encounter a similar problem with a function that has a scalar variable as a function result.&lt;BR /&gt;&lt;BR /&gt;The example:&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;MODULE ctf_mod&lt;/P&gt;&lt;P&gt;TYPE my_type&lt;/P&gt;&lt;P&gt;INTEGER :: i, j&lt;/P&gt;&lt;P&gt;END TYPE my_type&lt;/P&gt;&lt;P&gt;END MODULE ctf_mod&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;PROGRAM ctf&lt;/P&gt;&lt;P&gt;USE ctf_mod&lt;/P&gt;&lt;P&gt;IMPLICIT none&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;TYPE(my_type) :: type_function&lt;/P&gt;&lt;P&gt;TYPE(my_type) :: type_result&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;type_result = type_function(3,8) ! the problem line&lt;/P&gt;&lt;P&gt;write(*,*) 'result:', type_result &lt;/P&gt;&lt;P&gt;STOP&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;TYPE(my_type) FUNCTION type_function(k,l)&lt;/P&gt;&lt;P&gt;USE ctf_mod&lt;/P&gt;&lt;P&gt;IMPLICIT none&lt;/P&gt;&lt;P&gt;INTEGER,INTENT(in) :: k,l&lt;/P&gt;&lt;P&gt;type_function%i=k&lt;/P&gt;&lt;P&gt;type_function%j=l&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 07:10:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771039#M22600</guid>
      <dc:creator>Robert_van_Amerongen</dc:creator>
      <dc:date>2010-07-30T07:10:26Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771040#M22601</link>
      <description>Robert,&lt;BR /&gt;&lt;BR /&gt;This issue has been previously reported and is our issue ID DPD200157843. It is not yet fixed. Thanks for the report.&lt;BR /&gt;</description>
      <pubDate>Fri, 30 Jul 2010 14:19:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771040#M22601</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-07-30T14:19:53Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771041#M22602</link>
      <description>&lt;P&gt;What happens if you explicitly add your own interface?&lt;BR /&gt;&lt;BR /&gt;MODULE ctf_mod&lt;BR /&gt;TYPE my_type&lt;BR /&gt;INTEGER :: i, j&lt;BR /&gt;END TYPE my_type&lt;BR /&gt;END MODULE ctf_mod&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;PROGRAM ctf&lt;/P&gt;&lt;P&gt;USE ctf_mod&lt;BR /&gt;&lt;BR /&gt;! VVV add this VVV&lt;/P&gt;&lt;P&gt;INTERFACE&lt;BR /&gt;TYPE(my_type) FUNCTION type_function(k,l)&lt;BR /&gt;USE ctf_mod&lt;BR /&gt;IMPLICIT none&lt;BR /&gt;INTEGER,INTENT(in) :: k,l&lt;BR /&gt;END FUNCTION type_function&lt;BR /&gt;END INTERFACE&lt;BR /&gt;! ^^^ end add this ^^^&lt;BR /&gt;&lt;BR /&gt;IMPLICIT none&lt;/P&gt;&lt;P&gt;! comment/remove this&lt;/P&gt;&lt;P&gt;! TYPE(my_type) :: type_function&lt;/P&gt;&lt;P&gt;TYPE(my_type) :: type_result&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;type_result = type_function(3,8) ! the problem line&lt;/P&gt;&lt;P&gt;write(*,*) 'result:', type_result &lt;/P&gt;&lt;P&gt;STOP&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;!&lt;/P&gt;&lt;P&gt;TYPE(my_type) FUNCTION type_function(k,l)&lt;/P&gt;&lt;P&gt;USE ctf_mod&lt;/P&gt;&lt;P&gt;IMPLICIT none&lt;/P&gt;&lt;P&gt;INTEGER,INTENT(in) :: k,l&lt;/P&gt;&lt;P&gt;type_function%i=k&lt;/P&gt;&lt;P&gt;type_function%j=l&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 15:52:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771041#M22602</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-07-30T15:52:02Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771042#M22603</link>
      <description>That does prevent the error.</description>
      <pubDate>Fri, 30 Jul 2010 15:59:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771042#M22603</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-07-30T15:59:14Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771043#M22604</link>
      <description>I am afraid that is not the case as I saw after doing it.Even with an explicit interface the compilation fails if there is /nogen-interfaces used in the command line. If it is present, no problem!&lt;BR /&gt;The point with regard to the issue raised in this thread is, of course, that I may expect the compiler to accept legal fortran constructs without any restriction.&lt;BR /&gt;&lt;BR /&gt;Robert</description>
      <pubDate>Sat, 31 Jul 2010 13:23:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771043#M22604</guid>
      <dc:creator>Robert_van_Amerongen</dc:creator>
      <dc:date>2010-07-31T13:23:44Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771044#M22605</link>
      <description>Robert,&lt;BR /&gt;&lt;BR /&gt;This seems to contradict Steve's observatons.&lt;BR /&gt;I am also confused at your statement "/nogen-interfaces"&lt;BR /&gt;as opposed to "no /gen-interfaces", or "without /gen-interfaces option"&lt;BR /&gt;Are you entering this (/nogen-interfaces) by hand (in additional command line options)?&lt;BR /&gt;&lt;BR /&gt;Note, it is the "/warn:interfaces" that compares agains interface files of defined file name conventions.&lt;BR /&gt;Check to see if compiling without /geninterfaces but with /warn:interfaces .AND. out of date interface files from prior compilation (or hand written interface files). The error you are observing appears to be one of conflicting interfaces.&lt;BR /&gt;&lt;BR /&gt;Jim</description>
      <pubDate>Sat, 31 Jul 2010 17:14:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771044#M22605</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-07-31T17:14:13Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771045#M22606</link>
      <description>Jim,&lt;BR /&gt;&lt;BR /&gt;I am working with the command line, so every part is written by hand. From the ifort /help I found, among other things, the /nogen-interfaces option. I did never use /gen-interfaces. Why should I do that! The Fortran example does not require an explicit interface so I did neitherwrite it my self nor asks the compiler to do that for me.&lt;BR /&gt;&lt;BR /&gt;I have run the program with several different command lines. &lt;BR /&gt;Everything works fine with&lt;BR /&gt;ifort /free /extfor:f03 ctf.f03&lt;BR /&gt;ifort /free /extfor:f03 /nogen-interfaces ctf.f03&lt;BR /&gt;but problems arise with:&lt;BR /&gt;ifort /free /extfor:f03 /warn:all ctf.f03&lt;BR /&gt;ifort /free /extfor:f03 /warn:all /nogen-interfaces ctf.f03&lt;BR /&gt;ifort /free /extfor:f03 /warn:interfaces ctf.f03&lt;BR /&gt;&lt;BR /&gt;So, if the compiler is sopriggish to make interfaces, it would be nice if that are the correct ones! And that is not the case.&lt;BR /&gt;&lt;BR /&gt;Robert</description>
      <pubDate>Sat, 31 Jul 2010 21:05:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771045#M22606</guid>
      <dc:creator>Robert_van_Amerongen</dc:creator>
      <dc:date>2010-07-31T21:05:02Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771046#M22607</link>
      <description>/nogen-interfaces would be used when the default options include /gen-interfaces. There is likely a config file, or environment variable that is used to specify the default options.&lt;BR /&gt;&lt;BR /&gt;In your situation, it looks as if the default options omit /gen-interfaces (which is fine), therefore /nogen-interfaces essentially does nothing. And therefore&lt;BR /&gt;&lt;BR /&gt;ifort /free /extfor:f03 ctf.f03&lt;BR /&gt;ifort /free /extfor:f03 /nogen-interfaces ctf.f03&lt;BR /&gt;&lt;BR /&gt;are equivelent&lt;BR /&gt;&lt;BR /&gt;/warn:all includes /warn:interfaces&lt;BR /&gt;&lt;BR /&gt;therefore&lt;BR /&gt;&lt;BR /&gt;ifort /free /extfor:f03 /warn:all ctf.f03&lt;BR /&gt;ifort /free /extfor:f03 /warn:all /nogen-interfaces ctf.f03&lt;BR /&gt;ifort /free /extfor:f03 /warn:interfaces ctf.f03&lt;BR /&gt;&lt;BR /&gt;are equivelent (with respect to /warn:interfaces)&lt;BR /&gt;&lt;BR /&gt;The "problem" is the /warn:interfaces (/warn:all) is requesting that the interfaces of the functions and subroutines are to be provided and compared with those used. In your case your code has&lt;BR /&gt;&lt;BR /&gt;(no explicit interface declared in function/subroutine where call is made)&lt;BR /&gt;.or.&lt;BR /&gt;(interface not declared in module USE'd in function/subroutine where call is made)&lt;BR /&gt;.or.&lt;BR /&gt;(function having interface not declared in the same source file in a manner such that it isa forward/unknown reference)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The above essentialymeans the compiler does not know the interface at the point of use of functionand with /warn:interfaces enabled (/warn:all) it is informing you that it does not know the interface.&lt;BR /&gt;&lt;BR /&gt;Add the interface&lt;BR /&gt;&lt;BR /&gt;You might also try&lt;BR /&gt;&lt;BR /&gt;/warn:all /nowarn:interfaces&lt;BR /&gt;&lt;BR /&gt;*** However ***&lt;BR /&gt;&lt;BR /&gt;Doing so, omits checking interfaces which is an important diagnostic.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Sun, 01 Aug 2010 13:06:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771046#M22607</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-08-01T13:06:09Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771047#M22608</link>
      <description>Apologies - I'm just repeating what has already been said - but to remove my confusion, here's my understanding with 11.1.065:&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;There's a known bug with interface checking of external function subprograms that return derived types. &lt;/LI&gt;&lt;LI&gt;/warn:all includes /warn:interfaces, which as of 11.1 includes /gen-interfaces. So if you have specified /warn:interfaces (or /warn:all) you have implicitly been asking for the __genmod files to be created. If you don't want them, then you need to explicitly add /nogen-interfaces.&lt;/LI&gt;&lt;LI&gt;One the xxx__genmod files are there, they will be picked up by /warn:interfaces on any subsequent compiles, even if you later specify /nogen-interfaces. If you don't want them used you need to manually blow them away.&lt;/LI&gt;&lt;LI&gt;Having an explicit interface block in the main program for the external function subprogram makes no difference (is this a different bug?), the interface checking still trips up if /warn:interfaces is on and a xxx__genmod.mod file for the external function subprogram exists.&lt;/LI&gt;&lt;/UL&gt;The results listed in post #6 could be consistent with that, assuming you didn't blow away the xxx__genmod files in between tests. Until the bug is fixed, you either need to avoid /warn:interfaces altogether for the problematic source files (or always use it with /nogen-interfaces, which effectively nobbles it), or...&lt;BR /&gt;&lt;BR /&gt;Out of curiosity - a question to the OP: why isn't type_function a module procedure? &lt;BR /&gt;&lt;BR /&gt;Opining, so feel free to cut me back to size: The fortran standard may not require an explicit interface here, but the number of cases where external subprograms (i.e. not module procedures) are unavoidable under F2003 is vanishingly small - the only valid "standard" reason I can think of is that you need to call the subprogram from existing untouchable F77 code (Are there others? Some sort of compilation dependency issue? Playing games with sequence association?). That can't be your situation if you are using derived types because F77 didn't have derived types. If type_function was in a module, you'd avoid the bug, and you'd also be less likely (?) to trip up with things the multiple non-sequence derived type definition problem that is in your other post, plus you'd pick up the other benefits that come with modules. (The fact that you can compile with /warn:all and not have all your directories littered with strange looking __genmod files is enough of a justification for me...)&lt;BR /&gt;&lt;BR /&gt;I'd argue that one of the reasons this bug (still) exists is that the use of external fuction subprograms with derived type result is rather uncommon. &lt;BR /&gt;</description>
      <pubDate>Mon, 02 Aug 2010 05:06:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771047#M22608</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2010-08-02T05:06:39Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771048#M22609</link>
      <description>Thanks for the reply/analysis&lt;BR /&gt;&lt;BR /&gt;... /warn:interfaces, which as of 11.1 includes /gen-interfaces&lt;BR /&gt;&lt;BR /&gt;IMHO that is a mistake - they should remain seperate.&lt;BR /&gt;With implicit /gen-interfaces the programmer would not know of a missing explicit interface that would be required in their general purpose interfaces file.&lt;BR /&gt;&lt;BR /&gt;Additionaly, there should be a /use:interfaces option (implicitly set with /warn:interfaces) that uses the xxx_genmod files. This would permit you to compile _without_ the xxx_genmod files when present on disk.&lt;BR /&gt;This would help you catch a missing USE (general purpose interfaces file).&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Aug 2010 13:06:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771048#M22609</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-08-02T13:06:16Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771049#M22610</link>
      <description>I encountered the same problem. But not until yesterday - since I changed from XE 2011, Update 2 to XE 2011, Update 3.&lt;BR /&gt;&lt;BR /&gt;Did somebody observe the same - has something changed here in Update 3?&lt;BR /&gt;&lt;BR /&gt;Ralf</description>
      <pubDate>Fri, 01 Apr 2011 07:48:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771049#M22610</guid>
      <dc:creator>fritschen</dc:creator>
      <dc:date>2011-04-01T07:48:34Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771050#M22611</link>
      <description>Ralf,&lt;BR /&gt;&lt;BR /&gt;I installed the update 3 recently and saw the same you saw: this (reported) problem has disappeared!&lt;BR /&gt;&lt;BR /&gt;Robert van Amerongen</description>
      <pubDate>Fri, 01 Apr 2011 13:30:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771050#M22611</guid>
      <dc:creator>Robert_van_Amerongen</dc:creator>
      <dc:date>2011-04-01T13:30:36Z</dc:date>
    </item>
    <item>
      <title>derived type as a function result</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771051#M22612</link>
      <description>The error reported in the original post was indeed fixed in Update 3. Ralf, are you seeing something different?</description>
      <pubDate>Fri, 01 Apr 2011 16:54:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-as-a-function-result/m-p/771051#M22612</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-01T16:54:25Z</dc:date>
    </item>
  </channel>
</rss>

