Hi,
I have a question on the omp parallelization in the nested loop. I want to parallelize the outer loop by omp while in the inner loop a loop-dependent array "temp" is used. Without the omp inplementation, this serial of codes work well. But when I set "temp" to be private, and run it, it complains "Segmentation fault!". I guess there must be a mismatch in the dimension of "temp" and "phinew" due to the parallelization. But I don't know how to fix it. Obviously, "temp" cannot be shared by all the threads. Can anyone tell me why and show me a solution?
FYI, the original code is listed here:
#pragma omp parallel shared(phinew, chunk) private(temp)
{
#pragma omp for schedule(static, chunk)
for(j = 0; j <= J; j++){
for(i = 0; i <= I; i++){
temp[i] = phinew[i][j];
}
cosft1(temp - 1, I);
for(i = 0; i <= I; i++){
phinew[i][j] = 2.0 / (I + 0.0) * temp[i]; // don't forget this coefficient 2/I for the inverse transform
}
}
}



