<?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 &amp;quot;40+int(rand(0)*2)+1&amp;quot; shows 67?  in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744913#M3229</link>
    <description>Thanks - that helps. The problem is -reaL_size 64. Without the USE IFPORT, RAND is not explicitly declared and is "default real" You changed that to REAL(8), but the function returns REAL(4), so the results can be wrong. With the USE IFPORT, RAND is declared and the -real_size 64 won't affect it.</description>
    <pubDate>Wed, 17 Mar 2010 14:23:02 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2010-03-17T14:23:02Z</dc:date>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744901#M3217</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;I have two question about "rand."&lt;/P&gt;
&lt;P&gt;(1) Why the code "40+int(rand(0)*2)+1" shows 67? I expect it shows 41 or 42.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;(2) Why I need modify the code as below to get my results (i.g. 41 or 42)?&lt;/P&gt;
&lt;P&gt;use IFPORT&lt;/P&gt;
&lt;P&gt;idfile = 40+int(rand()*2+1)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks all experts.&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2010 16:03:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744901#M3217</guid>
      <dc:creator>changks888</dc:creator>
      <dc:date>2010-03-15T16:03:39Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744902#M3218</link>
      <description>&lt;P&gt;I get 41 or 42. Can you show a complete program that gets the 67 result?&lt;/P&gt;
&lt;P&gt;If I had to guess, it would be that you have an IMPLICIT typing for the letter R that is not REAL(4).&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2010 16:23:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744902#M3218</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-03-15T16:23:06Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744903#M3219</link>
      <description>&lt;P&gt;Hi Steve,&lt;/P&gt;
&lt;P&gt;You are right. There are several subroutines show r as a real number. For example:&lt;/P&gt;
&lt;P&gt;real fi (ilg), evap (ilg), r (ilg), zpond (ilg), dt (ilg)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I post several codes that I think they might related for your diagnosing.&lt;/P&gt;
&lt;P&gt;program runclass&lt;/P&gt;
&lt;P&gt;:&lt;/P&gt;
&lt;P&gt;!-----pre-running meteorological data&lt;BR /&gt; open(unit=41,file="Met_2003.dat")&lt;BR /&gt; open(unit=42,file="Met_2004.dat")&lt;/P&gt;
&lt;P&gt;:&lt;/P&gt;
&lt;P&gt;!-----randomly choose a pre-run meteorological file in the begining of the year&lt;/P&gt;
&lt;P&gt;idfile = 40+int(rand(0)*2)+1 !open file id = 41 or 42&lt;/P&gt;
&lt;P&gt;rewind(unit=idfile)     !rewinding the file to the first line&lt;BR /&gt; print *,iyear,idfile !for checking purpose&lt;BR /&gt; endif&lt;BR /&gt; read(idfile,*,end=1000) xyear,xday,ihour,imin,fsdown,fdlgrd(i), &amp;amp;&lt;BR /&gt; &amp;amp; pregrd(i),tagrd(i),uvgrd(i),presgrd(i),qagrd(i)&lt;BR /&gt; else&lt;BR /&gt;!-----a CR met data&lt;BR /&gt; read(51,*,end=999) iyear,iday,ihour,imin,fsdown,fdlgrd(i), &amp;amp;&lt;BR /&gt; &amp;amp; pregrd(i),tagrd(i),uvgrd(i),presgrd(i),qagrd(i)&lt;BR /&gt; endif&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I wonder my new modification which is using "use IFPORT"and "idfile = 40+int(rand()*2+1)" will influence the whole calculations, becuase I had some error message showed as below.&lt;/P&gt;
&lt;P&gt;kuo-macbook-pro:src cks$ ./runclass&lt;BR /&gt; 2002 41&lt;BR /&gt; starting year .... 2002&lt;BR /&gt; 1st soil layer energy balance error @ 2002&lt;BR /&gt; 1 0 0&lt;BR /&gt; soil water balance error @ 2002 1&lt;BR /&gt; 0 0&lt;BR /&gt; snow layer energy balance error @ 2002 8&lt;BR /&gt; 14 0&lt;BR /&gt; snow layer energy balance error @ 2002 35&lt;BR /&gt; 0 0&lt;BR /&gt; snow layer energy balance error @ 2002 63&lt;BR /&gt; 15 0&lt;BR /&gt; ground water balance error @ 2002 63&lt;BR /&gt; 15 0&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2010 18:10:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744903#M3219</guid>
      <dc:creator>changks888</dc:creator>
      <dc:date>2010-03-15T18:10:03Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744904#M3220</link>
      <description>Please attach a small (if possible) but complete program that demonstrates the problem. Code fragments don't help.</description>
      <pubDate>Mon, 15 Mar 2010 19:57:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744904#M3220</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-03-15T19:57:20Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744905#M3221</link>
      <description>&lt;P&gt;ALWAYS use "IMPLICIT NONE", except for small "jiffy" code, and also use "-warn declarations" to catch places where you forgot the "IMPLICIT NONE".&lt;/P&gt;
&lt;P&gt;If you want to be extra strict, you can set $IFORTCFG to something like ~/.ifortrc, then put "-warn declarations" in that file to always emit missing declaration errors. These are only warnings, so you can still write jiffies with implicit variables if you want to, and just ignore the warnings.&lt;/P&gt;
&lt;P&gt;Joe Krahn&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2010 22:31:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744905#M3221</guid>
      <dc:creator>joseph-krahn</dc:creator>
      <dc:date>2010-03-15T22:31:23Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744906#M3222</link>
      <description>&lt;P&gt;Hi steve,&lt;/P&gt;
&lt;P&gt;Because it contains several thouthads lines, here is a part of the mian program.&lt;/P&gt;
&lt;P&gt;Please have a look at this attachment: &lt;A onclick="ndownload('http://software.intel.com/file/25797')"&gt;main.F90&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks for your kind advise. Please let me know if I need to post more information for diagnosing.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;BR /&gt;Michael&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2010 23:44:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744906#M3222</guid>
      <dc:creator>changks888</dc:creator>
      <dc:date>2010-03-15T23:44:54Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744907#M3223</link>
      <description>The code you posted has the USE IFPORT, which you say fixes the problem. You should be able to come up with a 10-line program that reproduces the bad value - that's what I want to see. Start cutting down what you have to the minimum. Often during this process you'll find an error that led to the bad behavior.</description>
      <pubDate>Mon, 15 Mar 2010 23:55:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744907#M3223</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-03-15T23:55:22Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744908#M3224</link>
      <description>Hi Steve, The main program just upload (main.F90 in the post # 5) one min ago. Yes, I'm looking at it. Thanks.</description>
      <pubDate>Tue, 16 Mar 2010 00:06:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744908#M3224</guid>
      <dc:creator>changks888</dc:creator>
      <dc:date>2010-03-16T00:06:33Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744909#M3225</link>
      <description>&lt;P&gt;You didn't correctly attach the file. Go back into Add Files, select the file you uploaded and click "Add as attachment".&lt;/P&gt;
&lt;P&gt;What you did was get the URL of the link, which doesn't work.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2010 01:18:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744909#M3225</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-03-16T01:18:16Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744910#M3226</link>
      <description>Done. Please let me know if you cannot download the code. Michael</description>
      <pubDate>Tue, 16 Mar 2010 01:22:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744910#M3226</guid>
      <dc:creator>changks888</dc:creator>
      <dc:date>2010-03-16T01:22:44Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744911#M3227</link>
      <description>This large program depends on a lot of other routines and data files you did not provide. When I strip out all of that and just have the expression, I always get 41 or 42.&lt;BR /&gt;&lt;BR /&gt;Please provide a short (10 line) program that demonstrates the 67 result.</description>
      <pubDate>Tue, 16 Mar 2010 23:36:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744911#M3227</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-03-16T23:36:40Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744912#M3228</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;I upload two files: &lt;A onclick="ndownload('http://software.intel.com/file/25816')"&gt;rand_test.F90&lt;/A&gt; and &lt;A onclick="ndownload('http://software.intel.com/file/25817')"&gt;Makefile&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;It seems my homemade Makefile causes the problems. Can you please have a look? I have already try different flaging in the Makefile, I have no idea about which Flaging doable. Please advise me.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Michael&lt;BR /&gt;&lt;BR /&gt;kuo-macbook-pro:Desktop cks$ ifort -O0 -real_size 64 -integer_size 64 -heap-arrays rand_test.F90 &lt;BR /&gt;kuo-macbook-pro:Desktop cks$ ./a.out &lt;BR /&gt; &lt;B&gt;-9223372036854775768&lt;BR /&gt; 41&lt;BR /&gt; 41&lt;BR /&gt; 41&lt;BR /&gt; 41&lt;BR /&gt; 41&lt;BR /&gt; 41&lt;BR /&gt; 41&lt;BR /&gt; 41&lt;BR /&gt; 41&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Mar 2010 03:13:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744912#M3228</guid>
      <dc:creator>changks888</dc:creator>
      <dc:date>2010-03-17T03:13:21Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744913#M3229</link>
      <description>Thanks - that helps. The problem is -reaL_size 64. Without the USE IFPORT, RAND is not explicitly declared and is "default real" You changed that to REAL(8), but the function returns REAL(4), so the results can be wrong. With the USE IFPORT, RAND is declared and the -real_size 64 won't affect it.</description>
      <pubDate>Wed, 17 Mar 2010 14:23:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744913#M3229</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-03-17T14:23:02Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744914#M3230</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;Are there the other functions particularly I need to concern when I using the -real_size 64? How to you think about my Makefile? Any suggestions?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Mar 2010 01:01:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744914#M3230</guid>
      <dc:creator>changks888</dc:creator>
      <dc:date>2010-03-18T01:01:54Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744915#M3231</link>
      <description>You should always be concerned about calling IFPORT functions without USE IFPORT, or about any subroutine or function calls without interface checks.</description>
      <pubDate>Thu, 18 Mar 2010 12:25:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744915#M3231</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2010-03-18T12:25:04Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744916#M3232</link>
      <description>The best suggestion I can offer you is to add "IMPLICIT NONE" to all your sources, or, failing that, "-warn declarations" which does the same thing. Then you won't be surprised by implicit declarations.&lt;BR /&gt;&lt;BR /&gt;I would recommend the use of the standard intrinsic RANDOM_NUMBER rather than the non-standard RAND, but it is a subroutine and not a function.</description>
      <pubDate>Thu, 18 Mar 2010 13:00:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744916#M3232</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-03-18T13:00:08Z</dc:date>
    </item>
    <item>
      <title>"40+int(rand(0)*2)+1" shows 67?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744917#M3233</link>
      <description>Thank Steve and Tim so much. &lt;BR /&gt;&lt;BR /&gt;Michael</description>
      <pubDate>Thu, 18 Mar 2010 13:48:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/quot-40-int-rand-0-2-1-quot-shows-67/m-p/744917#M3233</guid>
      <dc:creator>changks888</dc:creator>
      <dc:date>2010-03-18T13:48:45Z</dc:date>
    </item>
  </channel>
</rss>

