I know that any variable declared within the parallel pragma is private, but I don't want to re-declare the variables in every iteration of the for loop.
Separate the #pragma omp parallel for into its two separate components #pragma omp parallel and #pragma omp for. Then you can declare the local variables in the parallel but outside the loop. Something like this
int global_result = 0;
#pragma omp parallel reduction(+:global_result)
{
int tid = omp_get_thread_num();
int seed = (((tid*tid + 15) * 3)/7);
// Typo, as commented below
// # pragma omp parallel for schedule(runtime)
// What is intended!
# pragma omp for schedule(runtime)
for(i = 0; i < chunksize; i++){
float x = erand48(&seed);
float y = erand48(&seed);
if ((x*x+y*y)>=1)
this_result++;
}
global_result += this_result;
}
There are better ways to calculate pi, though :-)