/* me-altro.c */ #include #include #include "omp.h" int main() { int const n_threads = 8; omp_set_num_threads( n_threads ); int const DIM_ENSEMBLE = 10; #pragma omp parallel for for(int i = 0; i < DIM_ENSEMBLE; ++i) { gsl_rng* r = gsl_rng_alloc( gsl_rng_mt19937 ); gsl_rng_set( r, omp_get_thread_num() + 1 ); #pragma omp critical std::cout << "hello from thread " << omp_get_thread_num() << " with random number " << gsl_rng_uniform_pos( r ) << std::endl; gsl_rng_free( r ); } return 0; }