<?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 ooh, yea, I should have seen in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760348#M15835</link>
    <description>&lt;P&gt;ooh, yea, I should have seen that. I will remember this for next time. FWIW this should be a reminder to NOT initialize the variables in the declaration section when (if) the subroutine or function will ever be used in openmp or recursively.&lt;/P&gt;

&lt;P&gt;Thanks Patrick for explaining this in further detail.&lt;/P&gt;

&lt;P&gt;This would be a good example for one of those "what's wrong with this program" questions.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
    <pubDate>Wed, 12 Nov 2014 22:01:56 GMT</pubDate>
    <dc:creator>jimdempseyatthecove</dc:creator>
    <dc:date>2014-11-12T22:01:56Z</dc:date>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760338#M15825</link>
      <description>&lt;P&gt;&lt;PRE&gt;[fortran]    module MyModule
        type :: MyType
            integer, dimension(:), pointer :: pIntList =&amp;gt; null ()
        end type 
    end module MyModule

    program TestOpenMP_1_AllocationWithinSubroutines

        use MyModule
        use omp_lib
        implicit none

        type(MyType) :: instance
        integer :: threadId 
        integer :: I

!$omp parallel private (instance, threadId, I) 
        threadId = OMP_GET_THREAD_NUM()
        allocate (instance%pIntList(200 + threadId))
        CALL IterateList(instance) 
!$omp end parallel

        read (*,*)

    contains

        subroutine IterateList(aInstance)
            type(MyType) :: aInstance
            integer, dimension(:), pointer :: pTempIntList =&amp;gt; null()
            integer :: threadId
            threadId = OMP_GET_THREAD_NUM()
            allocate (pTempIntList(size(aInstance%pIntList)))
            write (*,*) 'Thread ',threadId, ' - ', 'aInstance%pIntList: ', size(aInstance%pIntList)
            write (*,*) 'Thread ',threadId, ' - ', 'pTempIntListe: ', size(pTempIntList)         
        end subroutine 

    end program TestOpenMP_1_AllocationWithinSubroutines
[/fortran]&lt;/PRE&gt; As the above code sample shows, the main program tries to utilize
 OpenMP to call a subroutine. In that subroutine, a local pointer 
variable is created (allocated). Its size depends on the actual 
argument. The output shows the local pointer variable does NOT have the 
same size as the actual argument, which however should not be the case 
based on the code.&lt;/P&gt;

&lt;P&gt;Could you help to comment why the program gives such behavior? More 
importantly, could you help to comment the correct ways (best practices)
 concerning how to do allocation of pointers in subroutines when using 
OpenMP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H3&gt;The version of Intel Fortran Compiler is:&lt;/H3&gt;

&lt;PRE&gt;&lt;CODE&gt;[root@localhost new]# ifort --version
ifort (IFORT) 12.1.0 20111011
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.
&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;H3&gt;The output using ifort is shown below:
&lt;/H3&gt;&lt;PRE&gt;&lt;CODE&gt;[root@localhost new]# ifort omp.f90 -warn -check -g -trace -openmp -static
[root@localhost new]# ./a.out 
 Thread            5  - aInstance%pIntList:          205
 Thread            5  - pTempIntListe:          207
 Thread            1  - aInstance%pIntList:          201
 Thread            1  - pTempIntListe:          207
 Thread            3  - aInstance%pIntList:          203
 Thread            3  - pTempIntListe:          207
 Thread            0  - aInstance%pIntList:          200
 Thread            0  - pTempIntListe:          207
 Thread            2  - aInstance%pIntList:          202
 Thread            2  - pTempIntListe:          207
 Thread            4  - aInstance%pIntList:          204
 Thread            4  - pTempIntListe:          207
 Thread            7  - aInstance%pIntList:          207
 Thread            7  - pTempIntListe:          207
 Thread            6  - aInstance%pIntList:          206
 Thread            6  - pTempIntListe:          207&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Dec 2011 12:36:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760338#M15825</guid>
      <dc:creator>Xichen_Li</dc:creator>
      <dc:date>2011-12-23T12:36:35Z</dc:date>
    </item>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760339#M15826</link>
      <description>we will investigate this and report back soon.&lt;BR /&gt;&lt;BR /&gt;ron</description>
      <pubDate>Thu, 05 Jan 2012 16:26:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760339#M15826</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2012-01-05T16:26:40Z</dc:date>
    </item>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760340#M15827</link>
      <description>&lt;P&gt;Try using:&lt;BR /&gt;&lt;BR /&gt; recursive &lt;SPAN class="keyword bold"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #006699;"&gt;subroutine&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;IterateList(aInstance)&lt;BR /&gt;&lt;BR /&gt;Compiling with openmp enabled should have effectively done this for you.&lt;BR /&gt;Reason being, you want the array descriptor for pTempIntListe to be on stack as opposed to SAVE.&lt;BR /&gt;&lt;BR /&gt;If this fixes the problem, then the bug is -openmp not making local arrays stack based (i.e. leaving as SAVE)&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2012 16:02:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760340#M15827</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-01-10T16:02:57Z</dc:date>
    </item>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760341#M15828</link>
      <description>Thank you for your comment! Sorry but adding recursive doesn't help. After all, as you already mention, -openmp should make subroutines recursive automatically.</description>
      <pubDate>Wed, 11 Jan 2012 09:48:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760341#M15828</guid>
      <dc:creator>Xichen_Li</dc:creator>
      <dc:date>2012-01-11T09:48:49Z</dc:date>
    </item>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760342#M15829</link>
      <description>Try adding&lt;BR /&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;subroutine IterateList(aInstance)&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;type(MyType) :: aInstance&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;integer, dimension(:), pointer :: pTempIntList =&amp;gt; null()&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;integer :: threadId&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;threadId = OMP_GET_THREAD_NUM()&lt;BR /&gt;!$OMP CRITICAL&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;write(*,*) 'loc(aInstance)', loc(aInstance)&lt;BR /&gt;write(*,*) 'associated(aInstance%pIntList)', associated(aInstance%pIntList)&lt;BR /&gt; &lt;/SPAN&gt;allocate (pTempIntList(size(aInstance%pIntList)))&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&lt;/SPAN&gt;write (*,*) 'Thread ',threadId, ' - ', 'aInstance%pIntList: ', size(aInstance%pIntList)&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;write (*,*) 'Thread ',threadId, ' - ', 'pTempIntListe: ', size(pTempIntList)&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;!$OMP END CRITICAL&lt;BR /&gt; &lt;/SPAN&gt;end subroutine&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;--------------&lt;BR /&gt;If that does not disclose anything, then try&lt;BR /&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: x-small;"&gt;volatile integer :: myTurn&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;myTurn = 0&lt;BR /&gt;!$omp parallel private (instance, threadId, I) &lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;threadId = OMP_GET_THREAD_NUM()&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;do while(myTurn .lt. threadId)&lt;BR /&gt; sleepqq(1)&lt;BR /&gt;end do&lt;BR /&gt; &lt;/SPAN&gt;allocate (instance%pIntList(200 + threadId))&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt; &lt;/SPAN&gt;CALL IterateList(instance) &lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-family: Arial;"&gt;myTurn = myTurn + 1&lt;BR /&gt;!$omp end parallel&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: x-small;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/P&gt;&lt;BR /&gt;The second test will show if the array size is stored in a shared location (if the size printed out follows size expected).&lt;BR /&gt;&lt;BR /&gt;This information may aid in finding the bug (be it in your program or in IVF)&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey</description>
      <pubDate>Wed, 11 Jan 2012 13:58:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760342#M15829</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-01-11T13:58:14Z</dc:date>
    </item>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760343#M15830</link>
      <description>Also, does this issue show up in Debug build (with no optimizations)?&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey</description>
      <pubDate>Wed, 11 Jan 2012 14:02:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760343#M15830</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-01-11T14:02:40Z</dc:date>
    </item>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760344#M15831</link>
      <description>&lt;P&gt;It's not an optimisation bug, nor a bug with -openmp not putting the array descriptor for pTempIntListon the stack. I verified that each thread gets a unique allocation for pTempIntList in the subroutine.&lt;BR /&gt;&lt;BR /&gt;I believe this is a known bug with the Fortran front-end not putting arguments to size() on the private OpenMP list, in this case, aInstance%pIntList and pTempIntList.&lt;BR /&gt;&lt;BR /&gt;Workaround is to put a critical section in the subroutine around the thread-specific code:&lt;/P&gt;&lt;P&gt;!$omp critical&lt;/P&gt;&lt;P&gt; threadId = OMP_GET_THREAD_NUM()&lt;/P&gt;&lt;P&gt; allocate (pTempIntList(size(aInstance%pIntList)))&lt;/P&gt;&lt;P&gt; write (*,*) 'Thread ',threadId, ' - ', 'aInstance%pIntList: ', size(aInstance%pIntList)&lt;/P&gt;&lt;P&gt; write (*,*) 'Thread ',threadId, ' - ', 'pTempIntListe: ', size(pTempIntList) &lt;/P&gt;&lt;P&gt;!$omp end critical&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;ifort -Qopenmp U101975-critical.f90&lt;/P&gt;&lt;P&gt;Intel Visual Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.2.278 Build 20111128&lt;/P&gt;&lt;P&gt;&amp;gt;U101975-critical.exe&lt;/P&gt;&lt;P&gt;Thread 2 - aInstance%pIntList: 202&lt;/P&gt;&lt;P&gt;Thread 2 - pTempIntListe: 202&lt;/P&gt;&lt;P&gt;Thread 0 - aInstance%pIntList: 200&lt;/P&gt;&lt;P&gt;Thread 0 - pTempIntListe: 200&lt;/P&gt;&lt;P&gt;Thread 1 - aInstance%pIntList: 201&lt;/P&gt;&lt;P&gt;Thread 1 - pTempIntListe: 201&lt;/P&gt;&lt;P&gt;Thread 3 - aInstance%pIntList: 203&lt;/P&gt;&lt;P&gt;Thread 3 - pTempIntListe: 203&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;BR /&gt;&lt;BR /&gt;Incidently, gfortran has a similar issue (with your original code); but the reason could be entirely different:&lt;/P&gt;&lt;P&gt;&amp;gt; gfortran --version&lt;/P&gt;&lt;P&gt;GNU Fortran (SUSE Linux) 4.5.0 20100604 [gcc-4_5-branch revision 160292]&lt;/P&gt;&lt;P&gt;Copyright (C) 2010 Free Software Foundation, Inc.&lt;/P&gt;&lt;P&gt;&amp;gt; gfortran -fopenmp U101975_gfortran.f90 &amp;amp;&amp;amp; ./a.out&lt;/P&gt;&lt;P&gt;Thread 0 - aInstance%pIntList: 200&lt;/P&gt;&lt;P&gt;Thread 0 - pTempIntListe: 201&lt;/P&gt;&lt;P&gt;Thread 2 - aInstance%pIntList: 202&lt;/P&gt;&lt;P&gt;Thread 2 - pTempIntListe: 201&lt;/P&gt;&lt;P&gt;Thread 1 - aInstance%pIntList: 201&lt;/P&gt;&lt;P&gt;Thread 1 - pTempIntListe: 201&lt;/P&gt;&lt;P&gt;Thread 3 - aInstance%pIntList: 203&lt;/P&gt;&lt;P&gt;Thread 3 - pTempIntListe: 201&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;Once the developers confirm it's a known bug, I'll update this thread with the tracking number.&lt;BR /&gt;&lt;BR /&gt;Patrick Kennedy&lt;BR /&gt;Intel Developer Support&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2012 16:52:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760344#M15831</guid>
      <dc:creator>pbkenned1</dc:creator>
      <dc:date>2012-01-13T16:52:33Z</dc:date>
    </item>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760345#M15832</link>
      <description>If size(foo) is a Fortran compileroptimization issue relating to private variables then adding a critical section should not affect the code. &lt;BR /&gt;&lt;BR /&gt;However, if the critical section corrects the size(foo) issue, then this is indicative that the ALLOCATE(foo) code is inserting the allocation size into the out of private scope array descriptor allocation size location.&lt;BR /&gt;&lt;BR /&gt;IOW you have two problems: &lt;BR /&gt;&lt;BR /&gt; size(foo)uses allocation sizeof wrong descriptor&lt;BR /&gt; ALLOCATE(foo) is inserting allocation size into wrong descriptor&lt;BR /&gt;&lt;BR /&gt;When looking at one problem, be aware of, and look for, other problem.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Jan 2012 17:37:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760345#M15832</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-01-13T17:37:03Z</dc:date>
    </item>
    <item>
      <title>Allocation of pointers in subroutines when using OpenMP failed.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760346#M15833</link>
      <description>&lt;P&gt;Indeed, therecould be multiple defects in play here. The Fortran developers were unable to confirm if this a known issue, so this has been reported as a new defect, tracking number DPD200177907. I'll keep this thread updated with news from the developers.&lt;BR /&gt;&lt;BR /&gt;Patrick Kennedy&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2012 21:26:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760346#M15833</guid>
      <dc:creator>pbkenned1</dc:creator>
      <dc:date>2012-01-13T21:26:19Z</dc:date>
    </item>
    <item>
      <title>After a long investigation,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760347#M15834</link>
      <description>&lt;P&gt;After a long investigation, it turns out this is a coding error.&amp;nbsp; Jim was on the right track when he said "you want the array descriptor for pTempIntListe to be on stack as opposed to SAVE.".&amp;nbsp; However, it's not the case that "&amp;nbsp;the bug is -openmp not making local arrays stack based (i.e. leaving as SAVE)".&lt;/P&gt;

&lt;P&gt;The explicit initialization of pTempIntList inside routine IterateList to null() forces it to be static, by Fortran language rules:&lt;/P&gt;

&lt;PRE&gt;See 12-007 F2008 section 5.2.3 p3 n[89:12-13]
&lt;/PRE&gt;

&lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Explicit initialization of a variable that is not in a common block&lt;/PRE&gt;

&lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; implies the SAVE attribute, which may be confirmed by explicit&lt;/PRE&gt;

&lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; specification.&lt;/PRE&gt;

&lt;P&gt;But when we're compiling this routine, there is no way that the FE can determine that the routine might be called from inside a parallel region in some other piece of code.&amp;nbsp; As a result, we can't detect the error (i.e. using a static variable inside a parallel region - which is not thread-safe) and give a nice message.&lt;/P&gt;

&lt;P&gt;The fix is simply to remove the initialization:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subroutine IterateList(aInstance)&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; type(MyType) :: aInstance&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; integer, dimension(:), pointer :: pTempIntList&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;P&gt;With that change, all is good:&lt;/P&gt;

&lt;P&gt;[U101975]$ ifort -V&lt;BR /&gt;
	Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.1.133 Build 20141023&lt;BR /&gt;
	Copyright (C) 1985-2014 Intel Corporation.&amp;nbsp; All rights reserved.&lt;/P&gt;

&lt;P&gt;[U101975]$ ifort -openmp U101975.f90 -o U101975.x&lt;BR /&gt;
	[U101975]$ export OMP_NUM_THREADS=4&lt;BR /&gt;
	[U101975]$ ./U101975.x&lt;BR /&gt;
	&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp; - aInstance%pIntList:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;BR /&gt;
	&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp; - pTempIntListe:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;BR /&gt;
	&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp; - aInstance%pIntList:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201&lt;BR /&gt;
	&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp; - pTempIntListe:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201&lt;BR /&gt;
	&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp; - aInstance%pIntList:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 202&lt;BR /&gt;
	&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp; - pTempIntListe:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 202&lt;BR /&gt;
	&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp; - aInstance%pIntList:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 203&lt;BR /&gt;
	&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp; - pTempIntListe:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 203&lt;BR /&gt;
	[U101975]$&lt;/P&gt;

&lt;P&gt;Patrick&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2014 21:00:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760347#M15834</guid>
      <dc:creator>pbkenned1</dc:creator>
      <dc:date>2014-11-12T21:00:17Z</dc:date>
    </item>
    <item>
      <title>ooh, yea, I should have seen</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760348#M15835</link>
      <description>&lt;P&gt;ooh, yea, I should have seen that. I will remember this for next time. FWIW this should be a reminder to NOT initialize the variables in the declaration section when (if) the subroutine or function will ever be used in openmp or recursively.&lt;/P&gt;

&lt;P&gt;Thanks Patrick for explaining this in further detail.&lt;/P&gt;

&lt;P&gt;This would be a good example for one of those "what's wrong with this program" questions.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2014 22:01:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760348#M15835</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-11-12T22:01:56Z</dc:date>
    </item>
    <item>
      <title>The compiler could give a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760349#M15836</link>
      <description>&lt;P&gt;The compiler could give a "usage informational" if it sees local variable initialization when options imply that the routine should be recursive (and in F2015, all routines are recursive by default.)&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2014 22:20:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760349#M15836</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-11-12T22:20:44Z</dc:date>
    </item>
    <item>
      <title>That would be great.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760350#M15837</link>
      <description>&lt;P&gt;That would be great. Especially for those wanting to newer semantics. This diagnostic would be valuable in trying a newer level semantic (2008, 2015, ...) and being notified of statements to be examined for potential problems.&lt;/P&gt;

&lt;P&gt;&amp;gt;&amp;gt;(and in F2015, all routines are recursive by default.)&lt;/P&gt;

&lt;P&gt;Will this change the rule:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;Explicit initialization of a variable that is not in a common block&amp;nbsp;implies the SAVE attribute, which may be confirmed by explicit&amp;nbsp;specification.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2014 13:56:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760350#M15837</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-11-13T13:56:55Z</dc:date>
    </item>
    <item>
      <title>No, it doesn't change that</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760351#M15838</link>
      <description>&lt;P&gt;No, it doesn't change that rule.&lt;/P&gt;

&lt;P&gt;I'll comment that we don't have options to specify "level" of standard semantics. The compiler has a particular level it considers current. What the change will do is cause more incorrect programs with uninitialized variables to show errors.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2014 15:26:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocation-of-pointers-in-subroutines-when-using-OpenMP-failed/m-p/760351#M15838</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-11-13T15:26:53Z</dc:date>
    </item>
  </channel>
</rss>

