0

I am using OpenMP with Fortran.

Within an OpenMP parallel region private variables are allocated on the stack. I have some variables that are 1000x1000 arrays and this is causing some problems. I can get round it but I seem to have to do ulimit -s unlimited as well as setting OMP_STACKSIZE environment variable. This is OK for me, but not great for other users of my code.

At the moment I have arrays passed in the old fashioned way:

integer, intent(in) :: N
real(c_double) :: private_var(N,N)

!$omp parallel do default(shared) private(private_var)
...

Is there a better way to declare these arrays that avoids users having to manually set the stack size on their machine? I don't want to allocate within the loop, but perhaps I can open the parallel region first, have each worker allocate their own private work array, the have the do loop?

robince
  • 10,826
  • 3
  • 35
  • 48

0 Answers0