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

OpenMP and allocatables

Ralf
Beginner
307 Views

Sorry I made a mistake when phrasing the question - it is about private, not shared, allocatable arrays.

When defining a parallel do loop which involves an allocatable *private* array, I had to put the allocation statement inside the parallel region for the construct to work as expected - allocation outside the parallel region lead to an error.

Why does it matter where it is allocated?

Cheers -Ralf
0 Kudos
1 Reply
tom_p
Beginner
307 Views
Outside the parallel region only the initial thread is active. It creates a single allocated array. Within the parallel region a team of threads is active. As the array is private, each of those threads has its own copy, but only the array of the master thread (the former initial thread) has been allocated.

Hence, in order to have the private copy of the array allocated for all threads, it has to be done within the parallel region.
0 Kudos
Reply