!$OMP parallel Allocate(A(M1,N1)) Allocate(B(M2,N2,L2)) !$OMP do DO I =1, II ..... ENDDO deallocate(A,B) !$OMP end parallel
The total storage for allocations in your original example and in the above will be the same. The number of times you perform allocations will be less.
*** However The allocations are in smaller chunks (i.e. not *number_of_threads) Smaller allocation size has higher probability of being granted as memory fragments.
If A and B are temps .AND. if I represents one of the indexes for both .AND. if the I'th element of both arrays are completely independent from the I'th+x element .AND. if II is relatively large. Then consider breaking the iteration space into smaller pieces, each piece done in parallel.