<?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: Math function not working in Fortran in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740516#M391</link>
    <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Rather than explain what you think is the problem, please show a small but complete program that demonstrates the problem. My experience is that most of the time, when we are shown a single statement and a theory as to what is going wrong, it is actually something else based on code not shown.&lt;BR /&gt;</description>
    <pubDate>Thu, 29 Oct 2009 23:23:18 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2009-10-29T23:23:18Z</dc:date>
    <item>
      <title>Math function not working in Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740513#M388</link>
      <description>&lt;META http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;META name="ProgId" content="Word.Document" /&gt;
&lt;META name="Generator" content="Microsoft Word 11" /&gt;
&lt;META name="Originator" content="Microsoft Word 11" /&gt;
&lt;LINK rel="File-List" href="file:///C:\DOCUME~1\QINGHA~1\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" /&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:WordDocument&gt; &lt;w:View&gt;Normal&lt;/w:View&gt; &lt;w:Zoom&gt;0&lt;/w:Zoom&gt; &lt;w:PunctuationKerning /&gt; &lt;w:ValidateAgainstSchemas /&gt; &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt; &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt; &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt; &lt;w:Compatibility&gt; &lt;w:BreakWrappedTables /&gt; &lt;w:SnapToGridInCell /&gt; &lt;w:WrapTextWithPunct /&gt; &lt;w:UseAsianBreakRules /&gt; &lt;w:DontGrowAutofit /&gt; &lt;w:UseFELayout /&gt; &lt;/w:Compatibility&gt; &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt; &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt; &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;
&lt;STYLE&gt;
&amp;lt;!--
 /* Font Definitions */
 @font-face
	{font-family:SimSun;
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-alt:;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
	{font-family:"\@SimSun";
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 135135232 16 0 262145 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:SimSun;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&amp;gt;
&lt;/STYLE&gt;
&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;P class="MsoNormal"&gt;Hi,&lt;BR /&gt; I just run into this strange problem in my code. The cosine function continuously returns 1, while sine always give 0 for whatever inputs. I check that it happens after a certain number of iterations. Does anyone else see this case before? I put a checking line in different places in the code, and it starts to return warning message after a certain number of iterations:&lt;BR /&gt; &lt;BR /&gt; if(sin(real(Pi/4.0d0))==0) write(1,*),'warning'&lt;BR /&gt; &lt;BR /&gt; I worry whether other math functions, such as log and exp are also affected. My code was run in other cases before without encountering such strange problems. I assure all arrays are not overflowed and no errors was return during the test. Please give me some advice. All your help will be highly appreciated.&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;FYI: I run the code on Linux with the Intel compiler. I check that the some sin/cos functions used in this code give right values in a separated code.&lt;BR /&gt; &lt;BR /&gt; Robert&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2009 19:48:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740513#M388</guid>
      <dc:creator>zengsong</dc:creator>
      <dc:date>2009-10-28T19:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Math function not working in Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740514#M389</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Robert,&lt;BR /&gt;&lt;BR /&gt;What is the value of Pi at the time of the error?&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Oct 2009 20:36:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740514#M389</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2009-10-28T20:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Math function not working in Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740515#M390</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/99850"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; &lt;BR /&gt;Robert,&lt;BR /&gt;&lt;BR /&gt;What is the value of Pi at the time of the error?&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;Real number Pi is just 3.1415... defined at the beginning of the code. Pi is not changed in the program. The same checking sentence will not return an error at the beginning of the code, but it turns wrong in the iteration part after a while. Actually I check any arbitrary input for sine will return 0 in this case.&lt;BR /&gt;&lt;BR /&gt;Robert&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Oct 2009 23:00:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740515#M390</guid>
      <dc:creator>zengsong</dc:creator>
      <dc:date>2009-10-29T23:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Math function not working in Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740516#M391</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Rather than explain what you think is the problem, please show a small but complete program that demonstrates the problem. My experience is that most of the time, when we are shown a single statement and a theory as to what is going wrong, it is actually something else based on code not shown.&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Oct 2009 23:23:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740516#M391</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2009-10-29T23:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Math function not working in Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740517#M392</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Robert,&lt;BR /&gt;&lt;BR /&gt;Literal interpretation of your response is "I did not check the value of Pi" and by inference, you did not specifically check thevalueof Piat the statement where, and more specifically when, use of Pi/4.0D as argument to standard intrinsic function produced invalid results.&lt;BR /&gt;&lt;BR /&gt;Either input value of Pi is wrong (your program stomped on it) or the code/data within the intrinsic function is wrong (it used to be right, did your program stomp on it?), or the code/data near the offending statement was altered. Note this may also include the modification of theliteral value "4.0D".&lt;BR /&gt;&lt;BR /&gt;By testing the value of Pi at the point of error, you would confirm (or not) if the value of Pi was altered. Testing the same 4.0D will be harder to do.&lt;BR /&gt;&lt;BR /&gt;You have identified a location within your program produces bad results.&lt;BR /&gt;&lt;BR /&gt;Examine all the possible causes. Do not assume you know what cannot be a possible cause.&lt;BR /&gt;&lt;BR /&gt;When your test discovers the error, if necessary step back to scope of statement that made the call, then using the debugger, reset the Next Statement to the statement that produced the error (your debugger should have this capability). Examine Pi, verify it is indeed 3.1415.... If it is, look deeper, open a Dissassembly window. Step through assembly statements up to the sin (or call to sin function). What got calculated? did the divide 4.0D work as expected? What gets passed into the sin?&lt;BR /&gt;&lt;BR /&gt;If nothing shows up, you can then step over the sin function and check the result again.&lt;BR /&gt;&lt;BR /&gt;Now, if this time you get the right result then the case may be that your program JUMPED or RETURNED to the assembly code at or preceeding the sin/call to sin function, but at a position after where Pi/4.0D is properly calculated leaving trash (?0.0) as the calling argument. How you got here will be harder to determine. Hopefully examining the stack might lead to a discovery (include potential values representing last call that was poped from stack).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 30 Oct 2009 20:20:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740517#M392</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2009-10-30T20:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Math function not working in Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740518#M393</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Robert,&lt;BR /&gt;Plz note that, if value of pi is not changing, you can define as a parameter, and the full line will give same result in each iteration, irrespective of the activity of what rest of the loop is doing.&lt;BR /&gt;&lt;BR /&gt;And to assure yourself, this will always give the right ans!
&lt;PRE&gt;[cpp]	implicit none
	real(4),parameter::pi=3.14159
	
	write(*,*) pi
	if(sin(real(Pi/4.0d0))==0) write(1,*),'warning' 
	write(*,*) sin(real(Pi/4.0d0))
	

	end
[/cpp]&lt;/PRE&gt;
These math functions are such basic functions that we cant dream of any such bug as you mentioned in here. As Steve suggested, plz reproduce your problem in a smaller code and put it here, so it will be easy to check whats going wrong.&lt;BR /&gt;</description>
      <pubDate>Fri, 30 Oct 2009 23:10:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740518#M393</guid>
      <dc:creator>roddur</dc:creator>
      <dc:date>2009-10-30T23:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Math function not working in Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740519#M394</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/271365"&gt;roddur&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; Robert,&lt;BR /&gt;Plz note that, if value of pi is not changing, you can define as a parameter, and the full line will give same result in each iteration, irrespective of the activity of what rest of the loop is doing.&lt;BR /&gt;&lt;BR /&gt;And to assure yourself, this will always give the right ans!
&lt;/EM&gt;&lt;PRE&gt;&lt;EM&gt;[cpp]	implicit none&lt;BR /&gt;	real(4),parameter::pi=3.14159&lt;BR /&gt;	&lt;BR /&gt;	write(*,*) pi&lt;BR /&gt;	if(sin(real(Pi/4.0d0))==0) write(1,*),'warning' &lt;BR /&gt;	write(*,*) sin(real(Pi/4.0d0))&lt;BR /&gt;	&lt;BR /&gt;&lt;BR /&gt;	end&lt;BR /&gt;[/cpp]&lt;/EM&gt;&lt;/PRE&gt;
These math functions are such basic functions that we cant dream of any such bug as you mentioned in here. As Steve suggested, plz reproduce your problem in a smaller code and put it here, so it will be easy to check whats going wrong.&lt;BR /&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;This is where the code is not working. I use sin(Pi/4.0d0) just to confirm this. I find  Geky(iii) returns 0 all the time because of sin function problem. Note Rphi (real*4) is a random number here. This part used to give correct answers. I am checking other possible causes now for this issue.&lt;BR /&gt;&lt;BR /&gt;call random_number(Rtheta)&lt;BR /&gt;call random_number(Rphi)&lt;BR /&gt;Gekx(iii)=sqrt(1-((2.0d0*Rtheta-1)**2))*cos(2.0d0*pi*Rphi)&lt;BR /&gt;Geky(iii)=sqrt(1-((2.0d0*Rtheta-1)**2))*sin(2.0d0*pi*Rphi)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Nov 2009 15:22:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Math-function-not-working-in-Fortran/m-p/740519#M394</guid>
      <dc:creator>zengsong</dc:creator>
      <dc:date>2009-11-02T15:22:46Z</dc:date>
    </item>
  </channel>
</rss>

