<?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 Re: modules vs. block interfaces in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/modules-vs-block-interfaces/m-p/754637#M10124</link>
    <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
You raise an interesting point about checking dummy procedure calls. I suppose checking via the module definition would require an extension of interprocedural analysis, as syntactically there is no association until run time. So you have to supply an interface block with the name of the function as used at the call site.&lt;BR /&gt;</description>
    <pubDate>Wed, 15 Apr 2009 13:36:14 GMT</pubDate>
    <dc:creator>TimP</dc:creator>
    <dc:date>2009-04-15T13:36:14Z</dc:date>
    <item>
      <title>modules vs. block interfaces</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/modules-vs-block-interfaces/m-p/754636#M10123</link>
      <description>Hi all, &lt;BR /&gt;I have the following two questions:&lt;BR /&gt;&lt;BR /&gt;1) I have read from different sources (including Steve Lionel's Doctor Fortran blog) that in order to create an &lt;BR /&gt;explicit interface for an external procedure, modules are to be preferred to block interfaces. Why is this so?&lt;BR /&gt;&lt;BR /&gt;2) Assume I want to pass a function as an argument of a subroutine. The declaration of EXTERNAL leaves&lt;BR /&gt;the function without an explicit interface; and I have seen that it is possible to create it using block interfaces,&lt;BR /&gt;my example is the following:&lt;BR /&gt;Main program:&lt;BR /&gt;program main&lt;BR /&gt; use interfaces&lt;BR /&gt; implicit none&lt;BR /&gt; real::resulto&lt;BR /&gt; call promedio(func,0.0,1.0,resulto)&lt;BR /&gt; write(*,*) resulto&lt;BR /&gt;end program main&lt;BR /&gt;&lt;BR /&gt;The subroutine:&lt;BR /&gt;subroutine promedio(f,a,b,resulto)&lt;BR /&gt; implicit none&lt;BR /&gt; real, intent(in) :: a&lt;BR /&gt; real, intent(in) :: b&lt;BR /&gt; real, intent(out):: resulto&lt;BR /&gt;&lt;BR /&gt; real::c=2.&lt;BR /&gt;&lt;BR /&gt; interface&lt;BR /&gt; real function f(x)&lt;BR /&gt; implicit none&lt;BR /&gt; real, intent(in) :: x&lt;BR /&gt; end function f&lt;BR /&gt; end interface&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; resulto = 0.5*(f(a,c)+f(b))&lt;BR /&gt; return&lt;BR /&gt;&lt;BR /&gt;end subroutine promedio&lt;BR /&gt;&lt;BR /&gt;The function: &lt;BR /&gt; real function func(x)&lt;BR /&gt; implicit none&lt;BR /&gt; real, intent(in) :: x&lt;BR /&gt; func=x**2&lt;BR /&gt; end function func&lt;BR /&gt;&lt;BR /&gt;The interfaces, included in a module (of course, they could have been in the main program):&lt;BR /&gt;&lt;BR /&gt;module interfaces&lt;BR /&gt;!&lt;BR /&gt; interface&lt;BR /&gt; subroutine promedio(f,a,b,result)&lt;BR /&gt; implicit none&lt;BR /&gt; real, intent(in) :: a&lt;BR /&gt; real, intent(in) :: b&lt;BR /&gt; real, intent(out) :: result&lt;BR /&gt;&lt;BR /&gt; interface&lt;BR /&gt; real function f(x)&lt;BR /&gt; implicit none&lt;BR /&gt; real, intent(in) :: x&lt;BR /&gt; end function f&lt;BR /&gt; end interface&lt;BR /&gt;&lt;BR /&gt; end subroutine&lt;BR /&gt; end interface&lt;BR /&gt;!&lt;BR /&gt;interface&lt;BR /&gt; real function func(x)&lt;BR /&gt; implicit none&lt;BR /&gt; real, intent(in) :: x&lt;BR /&gt; end function func&lt;BR /&gt;end interface&lt;BR /&gt;&lt;BR /&gt;end module interfaces&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;With this structure, if the function in the subroutine is accidentally called with more variables than&lt;BR /&gt;declared, the compiler complains.&lt;BR /&gt;&lt;BR /&gt;My point is the following: Could this have been done without using interface blocks, and using modules?&lt;BR /&gt;I was not able to find the way.&lt;BR /&gt;&lt;BR /&gt;Hope someone can help.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fabio Zyserman&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Apr 2009 11:17:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/modules-vs-block-interfaces/m-p/754636#M10123</guid>
      <dc:creator>zyserman</dc:creator>
      <dc:date>2009-04-15T11:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: modules vs. block interfaces</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/modules-vs-block-interfaces/m-p/754637#M10124</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
You raise an interesting point about checking dummy procedure calls. I suppose checking via the module definition would require an extension of interprocedural analysis, as syntactically there is no association until run time. So you have to supply an interface block with the name of the function as used at the call site.&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Apr 2009 13:36:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/modules-vs-block-interfaces/m-p/754637#M10124</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2009-04-15T13:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: modules vs. block interfaces</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/modules-vs-block-interfaces/m-p/754638#M10125</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
When I wrote that you should use module procedures instead of interface blocks, I meant that the combination of F77-style separate procedures and interface blocks was not a good practice, since you have to specify the interface twice. In your example, function f could be a module procedure and then you would not have to declare its interface separately in promedio.&lt;BR /&gt;&lt;BR /&gt;You do still need an interface block in the declaration of the dummy argument - in F77 this would be EXTERNAL. Fortran 2003 allows use of abstract interface and PROCEDURE declarations here - coming soon to Intel Fortran.&lt;BR /&gt;&lt;BR /&gt;A module containing interface blocks that declare Fortran procedures is bad form. Make those Fortran procedures module procedures instead.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Apr 2009 16:46:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/modules-vs-block-interfaces/m-p/754638#M10125</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2009-04-21T16:46:11Z</dc:date>
    </item>
  </channel>
</rss>

