I would like to parallelize a loop containing a GSL quadrature. The contain of the loop is the function call

- Code: Select all
`gsl_integration_qag (&F, 0, Pi, 0, 1e-4, 1000, 1, w, &result, &error);`

where F is a gsl_function type (F.function, F.params), i.e., the function to be integrated, and w is the integration workspace.

I am using the openMP directives:

- Code: Select all
`F.function = &f; //function f(x,params) to be integrated`

F.params = &i; //parameter of f(x,params)

#pragma omp parallel default(none) \

private(i) shared(F,w,result,error)

{

#pragma omp for schedule(dynamic)

for(i=0;i<1001;i=i+200)

{

gsl_integration_qag (&F, 0, Pi, 0, 1e-4, 1000, 1, w, &result, &error);

printf ("%d\t %e\t %e\n", i, result, error);

#pragma omp flush(abort)

}

}// end parallel fork

The result is something like:

- Code: Select all
`400 0.000000e+00 0.000000e+00`

200 0.000000e+00 0.000000e+00

0 0.000000e+00 0.000000e+00

600 0.000000e+00 0.000000e+00

1000 0.000000e+00 0.000000e+00

800 0.000000e+00 0.000000e+00

Of course, when compiling without openMP it gives the non-zero results that I expect.

What am I missing?

Thanks,

f