<?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: OpenMP newbie ask for help in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883187#M75897</link>
    <description>&lt;P&gt;If you search the Fortran help for run-time errors you will find that error 151 means :&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hcp2"&gt;&lt;STRONG&gt;severe (151): Allocatable array is already allocated &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hcp2"&gt;&lt;STRONG&gt;Les&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Sep 2008 16:32:21 GMT</pubDate>
    <dc:creator>Les_Neilson</dc:creator>
    <dc:date>2008-09-24T16:32:21Z</dc:date>
    <item>
      <title>OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883179#M75889</link>
      <description>&lt;P&gt;&lt;FONT color="#0000ff"&gt;Using someone's program but changed a little to simulate my case. I want to do parallel in the main code, and call a subroutine inside the loop. The subroutine may also call other complicate subroutines. In this case, how can I define the variables as shared/private, such as i,j inside subroutine serial().&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;If I only use one thread, it runs okay. However, if I use more thanone thread, thereis alway error such as index of W goes to 100001 etc.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;program smp&lt;BR /&gt;use &lt;/FONT&gt;&lt;FONT color="#000000"&gt;dflib&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;implicit none&lt;BR /&gt;integer, parameter&lt;/FONT&gt; :: &lt;FONT color="#000000"&gt;&lt;B&gt;sz &lt;/B&gt;&lt;/FONT&gt;=100000&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;real(8), dimension(sz)&lt;/FONT&gt; :: X,W&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;integer&lt;/FONT&gt; :: i, IT,NT=50000,iflag =1, n =1&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;real(8)&lt;/FONT&gt;    :: res, runtime, begtime, endtime,timef&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;real(8), parameter&lt;/FONT&gt; :: mlt = 1.0D+02&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;interface&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff"&gt; subroutine&lt;/FONT&gt; Serial(X,W,sz)&lt;BR /&gt; &lt;FONT color="#0000ff"&gt;integer,intent(in)&lt;/FONT&gt; :: sz&lt;BR /&gt;&lt;FONT color="#0000ff"&gt; integer&lt;/FONT&gt; :: i,j&lt;BR /&gt; &lt;FONT color="#0000ff"&gt;real(8),intent( in),dimension(sz)&lt;/FONT&gt; :: X&lt;BR /&gt; &lt;FONT color="#0000ff"&gt;real(8),intent(out),dimension(sz)&lt;/FONT&gt; :: W&lt;BR /&gt; &lt;FONT color="#0000ff"&gt;end subroutine&lt;/FONT&gt; Serial&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;end interface&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;do&lt;/FONT&gt; i = 1, sz&lt;BR /&gt; res = ran(iflag); X(i)= mlt*res*n; n=-n&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;enddo&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;write(*,*)&lt;/FONT&gt;"
Program started......
"C&lt;BR /&gt;begtime = timef()&lt;BR /&gt;&lt;FONT color="#008000"&gt;!$OMP PARALLEL&lt;/FONT&gt; DO &lt;/P&gt;
&lt;P&gt;DOIT=1,NT&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;call&lt;/FONT&gt; Serial(X,W,sz,IT)&lt;/P&gt;
&lt;P&gt;ENDDO&lt;BR /&gt;&lt;FONT color="#008000"&gt;!$OMP END PARALLEL DO&lt;/FONT&gt;&lt;BR /&gt;endtime = timef(); runtime=endtime-begtime&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;write&lt;/FONT&gt;(*,'(A20,F9.4)')"
Execution time is :"C,runtime&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;write&lt;/FONT&gt;(*,*)"
Program terminated..."C&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;end program&lt;/FONT&gt; smp&lt;BR /&gt;!&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;subroutine Serial&lt;/FONT&gt;(X,W,sz,IT)&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;integer,intent(in)&lt;/FONT&gt; :: sz&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;integer&lt;/FONT&gt;&amp;amp;nb
sp; :: i,j&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;real(8),intent( in),dimension(sz)&lt;/FONT&gt; :: X&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;real(8),intent(out),dimension(sz)&lt;/FONT&gt; :: W&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;do&lt;/FONT&gt; i=1,sz&lt;BR /&gt; W(i)=0.D0&lt;/P&gt;
&lt;P&gt; call subroutinework(W)&lt;BR /&gt; &lt;FONT color="#0000ff"&gt;do&lt;/FONT&gt; j=1,sz&lt;BR /&gt; W(i)=W(i)+&lt;FONT color="#0000ff"&gt;DABS&lt;/FONT&gt;(x(i)+x(j))&lt;BR /&gt; &lt;FONT color="#0000ff"&gt;enddo&lt;BR /&gt;enddo&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;end subroutine Serial&lt;BR /&gt;&lt;BR /&gt;subroutine work(W)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;integer i&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;real W(sz)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;do i=1,sz&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;W(i)=works(i)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;enddo&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;endsubroutine&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2008 20:26:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883179#M75889</guid>
      <dc:creator>joey_hylton</dc:creator>
      <dc:date>2008-09-19T20:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883180#M75890</link>
      <description>&lt;P&gt;Joey,&lt;/P&gt;
&lt;P&gt;Add "implicit none" to all of your subroutines and see what happens.&lt;/P&gt;
&lt;P&gt;Also, your subroutine Serial is being called from the parallel loop and is passed the iterator IT however IT is not used?&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Mon, 22 Sep 2008 20:43:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883180#M75890</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2008-09-22T20:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883181#M75891</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;
&lt;P&gt; Thanks for reply.&lt;/P&gt;
&lt;P&gt; Actually, this is not my real code. I real code ismuch morecomplicated than this one. I use this code to simulate my case. In my real code, I have lots of global variables in the modules, and many of them are big arrays/matrices, and will be initialized before the parallelization sections, and will not be changed ( I suppose these variables will be set as shared). Some of them will be initialized and will be changed inside the parallelization section ( I suppose these variables will be set as threadprivate and copy in at the beginning). The loop variable (as IT in this code) is private. But how about other varialbes such i,j in subroutine serial()? &lt;/P&gt;
&lt;P&gt;In my code, I did like this:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" size="1"&gt;!$OMP PARALLEL DO default(shared) private(IT) copyin(....)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" size="1"&gt;DOIT=1,NT&lt;BR /&gt;call Serial(X,W,sz,IT)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" size="1"&gt;ENDDO&lt;BR /&gt;!$OMP END PARALLEL DO&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" size="1"&gt;&lt;FONT color="#000000"&gt;Here, I am trying to parallelize my code in the most highest level. I don't if it is possible or not.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2008 17:54:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883181#M75891</guid>
      <dc:creator>joey_hylton</dc:creator>
      <dc:date>2008-09-23T17:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883182#M75892</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;
&lt;P&gt;Will "IMPLICIT NONE" and "INTEGER I, J" automatically make I,J to be private in side each subroutine? My code have lots of subroutines having something like "implicit IMPLICIT REAL*8 (a-h,o-z)",and some of the variables are directly used without declairation.(Sorry, the original code is mot mine, I am try to modify it). Thanks, Joey&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2008 18:01:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883182#M75892</guid>
      <dc:creator>joey_hylton</dc:creator>
      <dc:date>2008-09-23T18:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883183#M75893</link>
      <description>&lt;DIV class="content"&gt;After changed the "implicit none"&lt;/DIV&gt;
&lt;DIV class="content"&gt;&lt;/DIV&gt;
&lt;DIV class="content"&gt;I got new problem.&lt;BR /&gt;&lt;BR /&gt;In one of my subroutines, I have to allocate some (many) arrays, and the sizes of these arrays are very large. If I defined them as this way&lt;BR /&gt;&lt;BR /&gt;subroutine works(N)&lt;BR /&gt;&lt;BR /&gt;implicit none&lt;BR /&gt;&lt;BR /&gt;integer,intent(in)::N&lt;BR /&gt;&lt;BR /&gt;real a(N),b(N),c(N)&lt;BR /&gt;&lt;BR /&gt;a=0d0&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this OpenMP process always give me a stack overflow error even I changed both the heap reserve and stack reserve sizes to large number, say 800,000,000&lt;BR /&gt;&lt;BR /&gt;Acording to someone's suggestions, I changed the definition as&lt;BR /&gt;&lt;BR /&gt;subroutine works(N)&lt;BR /&gt;&lt;BR /&gt;implicit none&lt;BR /&gt;&lt;BR /&gt;integer,intent(in)::N&lt;BR /&gt;&lt;BR /&gt;real,save,allocatable,dimension(:) a,b,c&lt;BR /&gt;&lt;BR /&gt;allocate(a(N),b(n),c(N))&lt;BR /&gt;&lt;BR /&gt;a=0d0&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;I got an error as "attempt to fetch from allocatable variable a when it is not allocated" at the line of "a=0d0". (It is possibly for the second thread, i have not figure it out yet).&lt;/DIV&gt;
&lt;DL class="postprofile" id="profile1192"&gt;
&lt;DT&gt;&lt;A href="http://www.openmp.org/forum/memberlist.php?mode=viewprofile&amp;amp;u=418"&gt;Toey_Hylton&lt;/A&gt; 
&lt;/DT&gt;&lt;DD&gt; 
&lt;/DD&gt;&lt;DD&gt;&lt;STRONG&gt;Posts:&lt;/STRONG&gt; 3 
&lt;/DD&gt;&lt;DD&gt;&lt;STRONG&gt;Joined:&lt;/STRONG&gt; Mon Sep 22, 2008 2:32 pm 
&lt;/DD&gt;&lt;DD&gt;
&lt;UL class="profile-icons"&gt;
&lt;LI class="pm-icon"&gt;&lt;A title="Private message" href="http://www.openmp.org/forum/ucp.php?i=pm&amp;amp;mode=compose&amp;amp;action=quotepost&amp;amp;p=1192"&gt;&lt;SPAN&gt;Private message&lt;/SPAN&gt;&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;/DD&gt;&lt;/DL&gt;</description>
      <pubDate>Tue, 23 Sep 2008 21:08:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883183#M75893</guid>
      <dc:creator>joey_hylton</dc:creator>
      <dc:date>2008-09-23T21:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883184#M75894</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;IMG src="https://community.intel.com/file/6745" /&gt; &lt;STRONG&gt;Joey_Hylton:&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;
&lt;P&gt;Jim,&lt;/P&gt;
&lt;P&gt;Will "IMPLICIT NONE" and "INTEGER I, J" automatically make I,J to be private in side each subroutine? My code have lots of subroutines having something like "implicit IMPLICIT REAL*8 (a-h,o-z)",and some of the variables are directly used without declairation.(Sorry, the original code is mot mine, I am try to modify it). Thanks, Joey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The "IMPLICIT REAL*8 (a-h,o-z)" means that all variable names that _begin_ with a letter "A" through to "H" or "O" through to "Z" declare variables that are, by default, double precision, unlessthe variable is explicitly declared as something else eg COMPLEX W&lt;/P&gt;
&lt;P&gt;It also means that variable names that begin with any other letter "I" through "N" declare variables that are INTEGER by default, unless explicitly declared as something else.&lt;/P&gt;
&lt;P&gt;The "scope" of the "IMPLICIT" declaration is the subroutine or function containing it.&lt;/P&gt;
&lt;P&gt;The "scope" of the variables is also limited to the subroutine in which they are declared - that is they are local (private as you call them) variables;UNLESS they are exposed tootherpartsof the system by, for example, a COMMON block, MODULE orby being passed as actual arguments in a CALL to another subroutine.&lt;/P&gt;
&lt;P&gt;Les&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2008 08:04:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883184#M75894</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2008-09-24T08:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883185#M75895</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;IMG src="https://community.intel.com/file/6745" /&gt; &lt;STRONG&gt;Joey_Hylton:&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;
&lt;DIV class="content"&gt;&lt;BR /&gt;&lt;BR /&gt;allocate(a(N),b(n),c(N))&lt;BR /&gt;&lt;BR /&gt;I got an error as "attempt to fetch from allocatable variable a when it is not allocated" at the line of "a=0d0". (It is possibly for the second thread, i have not figure it out yet).&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Insituations such as this where you have lots of arrays, it is usually a good idea to (a) allocate the arrays one at a time and (b) test the status of the allocation in casea problem occurred:&lt;/P&gt;
&lt;P&gt;integer istat&lt;BR /&gt;allocate(a(N), stat=istat)&lt;BR /&gt;if (istat /= 0) then&lt;BR /&gt;! error allocating the array; do something&lt;BR /&gt;endif&lt;/P&gt;
&lt;P&gt;Les&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2008 08:18:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883185#M75895</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2008-09-24T08:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883186#M75896</link>
      <description>I did this and found istat=151 when I use two threads, and istat=0 for one thread</description>
      <pubDate>Wed, 24 Sep 2008 14:38:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883186#M75896</guid>
      <dc:creator>joey_hylton</dc:creator>
      <dc:date>2008-09-24T14:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883187#M75897</link>
      <description>&lt;P&gt;If you search the Fortran help for run-time errors you will find that error 151 means :&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hcp2"&gt;&lt;STRONG&gt;severe (151): Allocatable array is already allocated &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hcp2"&gt;&lt;STRONG&gt;Les&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2008 16:32:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883187#M75897</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2008-09-24T16:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883188#M75898</link>
      <description>&lt;P&gt;Les,&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;Yes, I found it out. However, how can I deal with the allocatable variables in parallelization section with OpenMP? &lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2008 17:17:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883188#M75898</guid>
      <dc:creator>joey_hylton</dc:creator>
      <dc:date>2008-09-24T17:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP newbie ask for help</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883189#M75899</link>
      <description>Regarding the stack limit problem: with OpenMP, the each thread gets its own stack. The size of the stack is determined by the KMP_STACKSIZE environment variable which you can read about in the documentation.&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Sep 2008 17:41:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-newbie-ask-for-help/m-p/883189#M75899</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-09-24T17:41:48Z</dc:date>
    </item>
  </channel>
</rss>

