<?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: Can't Define Statement Function? in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793879#M34067</link>
    <description>&lt;DIV&gt;I'm not sure we agree -- unlike C macros, statement functions do have a type, as well as their arguments. If you don't use IMPLICIT NONE, their return valuegets the implicit type by their name. Thus:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: black 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; BORDER-LEFT: black 1px solid; PADDING-TOP: 10px; BORDER-BOTTOM: black 1px solid"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;PRE&gt;implicit none&lt;/PRE&gt;&lt;PRE&gt;integer iAdd, a, b, j

iAdd(a,b) = a + b

j = iAdd(7.9, 2.5)
write(*,*) j  !Returns 9&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I find a bit odd that CVF does not complain about argument mismatch (integer vs. real) but I'm not sure what the Standard says about it either. Apparently, implicit conversion takes place &lt;STRONG&gt;before &lt;/STRONG&gt;execution (i.e. it's INT(7.9) + INT(2.5)).&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Still, it's much better to use internal routines instead.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jugoslav&lt;/DIV&gt;</description>
    <pubDate>Wed, 18 Aug 2004 21:16:03 GMT</pubDate>
    <dc:creator>Jugoslav_Dujic</dc:creator>
    <dc:date>2004-08-18T21:16:03Z</dc:date>
    <item>
      <title>Can't Define Statement Function?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793875#M34063</link>
      <description>&lt;DIV&gt;Hi all,&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I found if I add 'implicit none' in code, my 'statement functioin' can't be compiled.&lt;/DIV&gt;
&lt;DIV&gt;Can anyone tell me how to solve the problem?&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thanks,&lt;/DIV&gt;
&lt;DIV&gt;Zhanghong Tang&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: black 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; BORDER-LEFT: black 1px solid; PADDING-TOP: 10px; BORDER-BOTTOM: black 1px solid"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;PRE&gt;PROGRAM SINES
implicit none
           DOUBLE PRECISION X, PI
           PARAMETER (PI=3.141592653589793238D0)
           COMMON V(3)

    !    Define SIN as a statement function 

           SIN(X) = COS(PI/2-X)
           DO X = -PI, PI, 2*PI/100

    !    Reference the statement function SIN 

             WRITE (6,100) X, V, SIN(X)
           END DO
   100     FORMAT (5F10.7)
         END&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Aug 2004 16:03:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793875#M34063</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2004-08-18T16:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can't Define Statement Function?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793876#M34064</link>
      <description>&lt;DIV&gt;Well, add&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;REAL Sin&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;to your declarations.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Statement functions are on obsolescent list of F90+ standards. Although useful at times, (acting much like C macros), they have quite quirky typing rules -- unlike C macros, they must be typed, and you have to declare their type separately from their body, as above. If I recall correctly, you can't have them in a MODULE for some of typing/scoping reasons. Internal functions (behind CONTAINS statement) are the preferred "F90-style".&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jugoslav&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Aug 2004 18:13:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793876#M34064</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2004-08-18T18:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can't Define Statement Function?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793877#M34065</link>
      <description>&lt;DIV&gt;Actually, they follow the same typing rules as anything else. If you have IMPLICIT NONE, you must explicitly declare the type - you don't get a free ride because an intrinsic exists of the same name. Because a statement function is just a single line, if you're going to give it a type it must be done separately.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I agree that statement functions should not be used in new code; contained procedures are much better, flexible and easier to understand.&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Aug 2004 20:48:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793877#M34065</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2004-08-18T20:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Can't Define Statement Function?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793878#M34066</link>
      <description>&lt;DIV&gt;Thank you very much, Jugoslav!&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I think a statement function will not restric the data type. That is to say, It can return to any data type (integer, real, real*8) as user need (the input data X is similar), because it is not a real function, when compiling, compiler will simplily replace the statement function with its expression.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Zhanghong Tang&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Aug 2004 20:51:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793878#M34066</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2004-08-18T20:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can't Define Statement Function?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793879#M34067</link>
      <description>&lt;DIV&gt;I'm not sure we agree -- unlike C macros, statement functions do have a type, as well as their arguments. If you don't use IMPLICIT NONE, their return valuegets the implicit type by their name. Thus:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: black 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; BORDER-LEFT: black 1px solid; PADDING-TOP: 10px; BORDER-BOTTOM: black 1px solid"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;PRE&gt;implicit none&lt;/PRE&gt;&lt;PRE&gt;integer iAdd, a, b, j

iAdd(a,b) = a + b

j = iAdd(7.9, 2.5)
write(*,*) j  !Returns 9&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I find a bit odd that CVF does not complain about argument mismatch (integer vs. real) but I'm not sure what the Standard says about it either. Apparently, implicit conversion takes place &lt;STRONG&gt;before &lt;/STRONG&gt;execution (i.e. it's INT(7.9) + INT(2.5)).&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Still, it's much better to use internal routines instead.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jugoslav&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Aug 2004 21:16:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793879#M34067</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2004-08-18T21:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Can't Define Statement Function?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793880#M34068</link>
      <description>&lt;DIV&gt;You'll get an argument mismatch if you compile with standards warnings enabled. The compiler has an extension where it will convert values when it knows what to do. In some contexts, though, it's more forgiving than I like to see....&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Aug 2004 21:51:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793880#M34068</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2004-08-18T21:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Can't Define Statement Function?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793881#M34069</link>
      <description>&lt;DIV&gt;It seems I misunderstand the function of statement function. I just think it like C's macros. Compiler only simply replace the statement functionwith its expression. The input and output data is decided by how it is called.&lt;/DIV&gt;
&lt;DIV&gt;Thank you again, Jugoslav and Steve!&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Zhanghong Tang&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Aug 2004 21:58:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-Define-Statement-Function/m-p/793881#M34069</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2004-08-18T21:58:31Z</dc:date>
    </item>
  </channel>
</rss>

