<?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 Both terms will be evaluated. in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957694#M93933</link>
    <description>&lt;P&gt;Both terms will be evaluated.&lt;/P&gt;

&lt;P&gt;The .and. behaves like the &amp;amp; operator in C. There isn´t an operator like &amp;amp;&amp;amp; in Fortran.&lt;/P&gt;

&lt;P&gt;I don´t like it too because for array checks you always have to use two if clauses&lt;/P&gt;

&lt;P&gt;[fortran]&lt;/P&gt;

&lt;P&gt;! this one will crash when i &amp;lt;= 0&lt;/P&gt;

&lt;P&gt;if(i &amp;gt; 0 .and. array(i) &amp;lt; 5) then&lt;/P&gt;

&lt;P&gt;! do something&lt;/P&gt;

&lt;P&gt;end if&lt;/P&gt;

&lt;P&gt;! this one works&lt;/P&gt;

&lt;P&gt;if(i&amp;gt;0) then&lt;/P&gt;

&lt;P&gt;&amp;nbsp; &amp;nbsp; if(array(i) &amp;lt; 5) then&lt;/P&gt;

&lt;P&gt;! do something&lt;/P&gt;

&lt;P&gt;end if&lt;/P&gt;

&lt;P&gt;[/fortran]&lt;/P&gt;

&lt;P&gt;Because if i is 0 array(0) is out of bounds...&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Markus&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jan 2014 13:22:20 GMT</pubDate>
    <dc:creator>onkelhotte</dc:creator>
    <dc:date>2014-01-13T13:22:20Z</dc:date>
    <item>
      <title>Evaluate Expression .AND. error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957689#M93928</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I have a expression like this:&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I = 5&lt;/P&gt;

&lt;P&gt;DO WHILE (I &amp;lt;= 4 .AND. "ThrowError")&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Do something'&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;I = I + 1&lt;BR /&gt;
	ENDDO&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;In Intel Fortran, as the variable I is greather than 4, the second part of the .AND. operator shouldnt even be evaluated, correct? (since the first operand is .FALSE.) But thats not the case, the second part is evaluated and throws an error.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;In compaq fortran that expression works as expect: the execution verifies that the first operand is .FALSE. and dont continue evaluating the expression.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Does anyone know anything about it?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 12:52:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957689#M93928</guid>
      <dc:creator>Guilherme_S_</dc:creator>
      <dc:date>2014-01-13T12:52:11Z</dc:date>
    </item>
    <item>
      <title>Found the answer in :  http:/</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957690#M93929</link>
      <description>&lt;P&gt;Found the answer in : &amp;nbsp;http://software.intel.com/en-us/forums/topic/388931&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 13:01:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957690#M93929</guid>
      <dc:creator>Guilherme_S_</dc:creator>
      <dc:date>2014-01-13T13:01:42Z</dc:date>
    </item>
    <item>
      <title>Found the answer in: http:/</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957691#M93930</link>
      <description>&lt;P&gt;Found the answer in: &lt;A href="http://software.intel.com/en-us/forums/topic/388931" target="_blank"&gt;http://software.intel.com/en-us/forums/topic/388931&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 13:02:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957691#M93930</guid>
      <dc:creator>Guilherme_S_</dc:creator>
      <dc:date>2014-01-13T13:02:29Z</dc:date>
    </item>
    <item>
      <title>The compiler can evaluate in</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957692#M93931</link>
      <description>&lt;P&gt;The compiler can evaluate in any order it chooses and may evaluate some or all terms. If you want standard fortran you cannot assume the order...&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 13:16:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957692#M93931</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2014-01-13T13:16:31Z</dc:date>
    </item>
    <item>
      <title>From the Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957693#M93932</link>
      <description>&lt;P&gt;From the Intel Fortran documentation:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;You should not write logical expressions whose results might depend on the evaluation order of subexpressions. The compiler is free to evaluate subexpressions in any order.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;Logical operations cannot be performed on other data types (than logical or integer).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Your understanding is incorrect regarding whether short-circuit evaluation is &lt;STRONG&gt;required&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;Secondly, I do not understand what you expect to happen when a character constant is used in a place where a logical (or, grudgingly, an integer expression) is expected; perhaps you used "ThrowError" as a place-holder for something longer that is of type logical.&lt;/P&gt;

&lt;P&gt;Although one can make arguments for and against short-circuited evaluation of logical/boolean expressions, one needs to remember that a Fortran program that depends on order of evaluation or enforced short-circuiting is not a standard-conforming program.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 13:22:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957693#M93932</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-01-13T13:22:00Z</dc:date>
    </item>
    <item>
      <title>Both terms will be evaluated.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957694#M93933</link>
      <description>&lt;P&gt;Both terms will be evaluated.&lt;/P&gt;

&lt;P&gt;The .and. behaves like the &amp;amp; operator in C. There isn´t an operator like &amp;amp;&amp;amp; in Fortran.&lt;/P&gt;

&lt;P&gt;I don´t like it too because for array checks you always have to use two if clauses&lt;/P&gt;

&lt;P&gt;[fortran]&lt;/P&gt;

&lt;P&gt;! this one will crash when i &amp;lt;= 0&lt;/P&gt;

&lt;P&gt;if(i &amp;gt; 0 .and. array(i) &amp;lt; 5) then&lt;/P&gt;

&lt;P&gt;! do something&lt;/P&gt;

&lt;P&gt;end if&lt;/P&gt;

&lt;P&gt;! this one works&lt;/P&gt;

&lt;P&gt;if(i&amp;gt;0) then&lt;/P&gt;

&lt;P&gt;&amp;nbsp; &amp;nbsp; if(array(i) &amp;lt; 5) then&lt;/P&gt;

&lt;P&gt;! do something&lt;/P&gt;

&lt;P&gt;end if&lt;/P&gt;

&lt;P&gt;[/fortran]&lt;/P&gt;

&lt;P&gt;Because if i is 0 array(0) is out of bounds...&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Markus&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 13:22:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957694#M93933</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2014-01-13T13:22:20Z</dc:date>
    </item>
    <item>
      <title>see also http://software</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957695#M93934</link>
      <description>&lt;P&gt;see also &lt;A href="http://software.intel.com/en-us/forums/topic/293083" target="_blank"&gt;http://software.intel.com/en-us/forums/topic/293083&lt;/A&gt;. Some ancient Fortran compilers indeed evaluated "if" clauses from left to right, stopping the evaluation if a term was false. I don't know if that was just a convention or an ommission in the Fortran standard. Now the standard says clearly that the clauses are not neccessarily evaluated from left to right. You have no other possibility than to check your sources and correct the dubious if clauses.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 13:45:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957695#M93934</guid>
      <dc:creator>rase</dc:creator>
      <dc:date>2014-01-13T13:45:43Z</dc:date>
    </item>
    <item>
      <title>Would there be any support</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957696#M93935</link>
      <description>&lt;P&gt;Would there be any support for extending the language to handle this type of situation by adding ordered versions of &lt;EM&gt;.and.&lt;/EM&gt; and &lt;EM&gt;.or.&lt;/EM&gt;, for example &lt;EM&gt;.oand.&lt;/EM&gt; and&lt;EM&gt; .oor.&lt;/EM&gt; or &lt;EM&gt;.andif.&lt;/EM&gt; and &lt;EM&gt;.orif.&lt;/EM&gt; ?&amp;nbsp; Is it difficult for the compiler writers?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 14:44:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957696#M93935</guid>
      <dc:creator>Simon_Geard</dc:creator>
      <dc:date>2014-01-13T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Quote:rase wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957697#M93936</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;rase wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;...Some ancient Fortran compilers indeed evaluated "if" clauses from left to right, stopping the evaluation if a term was false.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Those ancient compilers, as well as current standard-conforming compilers, are allowed to do so. The programmer who assumes that they will &lt;STRONG&gt;always &lt;/STRONG&gt;do so, however, does so at his/her own peril. I see this issue as not much different from, say, assuming that variables are by default initialized to zero, blank, .true., etc., just because some widely-used older compiler did so in the past.&lt;/P&gt;

&lt;P&gt;That said, it is a business decision for the compiler vendor as to whether an option should be provided to allow non-standard-conforming codes to continue to run "correctly".&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 14:49:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957697#M93936</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-01-13T14:49:00Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;Is it difficult for the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957698#M93937</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;Is it difficult for the compiler writers?&lt;/P&gt;

&lt;P&gt;It is not a case of being difficult to do. Rather, it is a case of following the rules of the language.&lt;/P&gt;

&lt;P&gt;The language states any order including&amp;nbsp;concurrently&lt;/P&gt;

&lt;P&gt;Assume:&lt;/P&gt;

&lt;P&gt;IF(functionA(arg) .OR. functionB(arg)) CALL something()&lt;/P&gt;

&lt;P&gt;If functionA and functionB maintain global states, Then shortcutting the above IF statement may cause state inconsistency.&lt;BR /&gt;
	IOW break working code.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 17:37:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957698#M93937</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-01-13T17:37:42Z</dc:date>
    </item>
    <item>
      <title>f2c is the only Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957699#M93938</link>
      <description>&lt;P&gt;f2c is the only Fortran translator I know of which followed C style shortcut evaluation. I would have expected it to reject violations of Fortran 77 such as using .and. with a character string. Any compiler which did permit this would be too untrustworthy for any possibility of a maintained compiler to emulate. If CVF accepted this on the grounds of evaluation to .false. you might as well comment out the bad part.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 18:59:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957699#M93938</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2014-01-13T18:59:00Z</dc:date>
    </item>
    <item>
      <title>Couldn't you just write what</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957700#M93939</link>
      <description>&lt;P&gt;Couldn't you just write what you want explicitly? &amp;nbsp;E.g.&lt;/P&gt;

&lt;P&gt;I = 5&lt;/P&gt;

&lt;P&gt;DO WHILE (I &amp;lt;= 4)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(&amp;nbsp;.NOT. "ThrowError")&amp;nbsp;EXIT&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Do something'&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;I = I + 1&lt;BR /&gt;
	ENDDO&lt;/P&gt;

&lt;P&gt;&amp;nbsp;I'm assuming the stuff in quotes is just shorthand for a legal expression of some sort.&lt;/P&gt;

&lt;P&gt;Whilst I understand the inconvenience of having to fix old codes, it's not realistic to introduce new, non-standard language features every time something like this crops up, the list would be overwhelming. Of course, if you could convince the standards committee, which includes our own Steve Lionel, that would be another matter...&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2014 20:46:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957700#M93939</guid>
      <dc:creator>Martyn_C_Intel</dc:creator>
      <dc:date>2014-01-13T20:46:08Z</dc:date>
    </item>
    <item>
      <title>&lt;blockquote&gt;</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957701#M93940</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;It is not a case of being difficult to do. Rather, it is a case of following the rules of the language.&lt;/P&gt;

&lt;P&gt;The language states any order including&amp;nbsp;concurrently&lt;/P&gt;

&lt;P&gt;Assume:&lt;/P&gt;

&lt;P&gt;IF(functionA(arg) .OR. functionB(arg)) CALL something()&lt;/P&gt;

&lt;P&gt;If functionA and functionB maintain global states, Then shortcutting the above IF statement may cause state inconsistency.&lt;BR /&gt;
	IOW break working code.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;The point of adding new operators as I suggested would be to avoid breaking existing code. I doubt very much that the language rules say anything about operators that don't yet exist.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2014 09:14:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957701#M93940</guid>
      <dc:creator>Simon_Geard</dc:creator>
      <dc:date>2014-01-14T09:14:04Z</dc:date>
    </item>
    <item>
      <title>I am not sure what your</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957702#M93941</link>
      <description>&lt;P&gt;I am not sure what your motivation to having C-style logical operator evaluation (left to right, stop evaluation upon first satisfaction).&lt;/P&gt;

&lt;P&gt;Other than "it looks like C" you might have the misconception that it will generate faster code.&lt;/P&gt;

&lt;P&gt;Consider&lt;/P&gt;

&lt;P&gt;IF((A .GT. B) .OR. (C.LT.D)) E = F&lt;/P&gt;

&lt;P&gt;In the above case, with processor having conditional move, there are no branches required if you do both evaluations.&lt;/P&gt;

&lt;P&gt;And yes there are counter examples, such as your original one where I assume "ThrowError" is an expression that would generate an error that you would rather not encounter, e.g. divide by zero.&lt;/P&gt;

&lt;P&gt;The problem you are wishing to resolve is a change in language. This is hard to do without breaking existing code. Martyn gave you a good example of how to Fortran-ize your C-style thinking.&lt;/P&gt;

&lt;P&gt;How about using FORTH or LISP style expression evaluations and IF statements?&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2014 14:39:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957702#M93941</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-01-14T14:39:52Z</dc:date>
    </item>
    <item>
      <title>Jim Dempsey wrote: </title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957703#M93942</link>
      <description>&lt;P&gt;Jim Dempsey wrote:&amp;nbsp;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; line-height: 16.363636016845703px;"&gt;The problem you are wishing to resolve is a change in language. This is hard to do without breaking existing code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; line-height: 16.363636016845703px;"&gt;There are more objections to the addition of operators and language features without going through the language standards body. &lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; line-height: 16.363636016845703px;"&gt;The compiler people have to ensure that the additions do not cause changes in the behavior of programs that do not use the extensions. &lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; line-height: 16.363636016845703px;"&gt;The primary users of the new operators have to contend with the problem that their code is now going to create for secondary users whose compilers either do not support the new operators or do so with a slightly different implementation.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2014 15:21:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Evaluate-Expression-AND-error/m-p/957703#M93942</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-01-14T15:21:34Z</dc:date>
    </item>
  </channel>
</rss>

