#include #include int main(int argc, char** argv) { int Nx1 = 20; int rank; int Nx1min; int Nx1max; int tnot; int i; double *T = (double*)malloc(Nx1 * sizeof(double)); double *U; #pragma omp parallel shared(T) private(i,U,rank,tnot,Nx1min,Nx1max) { rank = omp_get_thread_num(); tnot = omp_get_num_threads(); Nx1min = rank * (Nx1 / tnot); Nx1max = (rank +1) * (Nx1 / tnot) -1; printf("rank : %d tnot : %d min and max %d %d\n", rank, tnot, Nx1min, Nx1max); U = (double*)malloc(Nx1 * sizeof(double)); for(i = 0; i < Nx1 / tnot; i++) U[i] = rank + 10; for(i = Nx1min; i < Nx1max; i++) T[i] = U[i-Nx1min]; free(U); } for(i = 0; i < Nx1; i++) printf("%lf\n", T[i]); free(T); return 0; }