Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Allocatable array in OpenMP

britz0907
Beginner
260 Views

Hello 

I tried to generate below OpenMP code

INTEGER, ALLOCATABLE :: A(:)

....

C$OMP PARALLEL DEFAULT(SHARED) 

C$OMP DO private(A)

       do i =1,n

      ALLOCATE((A(k)) // k - variable from do-loop procedure

......

However,  error encountered while attempting to allocate a data object.

As I know, this bug was fixed by former patch. But I'm unable to update. (ifort - 11.1.052)

So I tried to next

INTEGER, pointer :: A(:)

....

C$OMP PARALLEL DEFAULT(SHARED) 

C$OMP DO private(A)

       do i =1,n

      nullify(A)

       ALLOCATE((A(k)) // k - variable from do-loop procedure

......

But this generates incorrect values.

What should I do? (Array size should gain from inter do-loop)

0 Kudos
2 Replies
TimP
Honored Contributor III
260 Views

If you were using a recent compiler, I'd suggest filing a problem report with an actual test case, if you can get access via premier.intel.com.  If there is a bug in a compiler which is no longer on support, you don't have much choice beyond finding a work-around or upgrading to a newer compiler which can run your case (which we won't know without an actual example).

A possible work-around might be to put the allocate in a separate procedure, and make that procedure thread safe by declaring it with RECURSIVE or by setting -auto or equivalent (not -openmp).

0 Kudos
jimdempseyatthecove
Honored Contributor III
259 Views

In first example try: change private(A) to firstprivate(A).

In second example try, move nullify(A) to out of parallel region, change private(A) to firstprivate(A).

If all else fails, enclose the contents of the parallel region into a subroutine, then call the subroutine from the parallel region.

Jim Dempsey

0 Kudos
Reply