I tried parallelizing the following loop:
#pragma omp parallel for shared(v, g, p)
for (i=1; i<=imax-1; i++) {
for (j=1; j<=jmax-1; j++) { // combined loops
/* only if both adjacent cells are fluid cells */
if ((flag[i][j] & C_F) && (flag[i][j+1] & C_F)) {
v[i][j] = g[i][j]-(p[i][j+1]-p[i][j])*del_t/dely;
}
if ((flag[i][j] & C_F) && (flag[i+1][j] & C_F)) {
u[i][j] = f[i][j]-(p[i+1][j]-p[i][j])*del_t/delx;
}
}
}
But my program does not run as expected, probably because of loop dependencies. Is there a way to parallelize this loop with reductions? Any help will be greatly appreciated.