/*NOTES: // means single line comment in c/C++ $ means right after it the command line starts # to warn the compiler for adding aditional files or special events What is the program for? To show difference between private() and firstprivate() OpenMP clauses. C/C++ allows you to declare a varable and initialize them value. For Example: int moon_distance = 238900; So whenever a function uses the variable moon_distance, it will use it with the value 238900. However, in OpenMP parallel region, private varables are not intialized. (Why good question for OpenMP). So if you wanted to make an initialized variable private to each thread. Then you have to tell it explicitly with the use of firstprivate() clause. Compiling this code on Blue Waters may give you some warning also, telling you to change the moon_distance from private to firstprivate variable. How to Compile: $ cc omp_var_initialization.c -o omp_var_initialization How to Setup Runtime Environment: $ export OMP_NUM_THREADS=4 How to Run: $ aprun -n 1 -d 4 ./omp_var_initialization Output: This value is the when use private() clause thread 1: moon_distance = -22032 thread 0: moon_distance = 0 thread 2: moon_distance = -22032 thread 3: moon_distance = -22032 This is the value using firstprivate() clause thread 0: moon_distance = 238900 thread 1: moon_distance = 238900 thread 2: moon_distance = 238900 thread 3: moon_distance = 238900 Actual initialization is: moon_distance = 238900 */ #include #include int main (void) { int moon_distance = 238900; printf(" \n"); printf("This value is the when use private() clause\n"); #pragma omp parallel private(moon_distance) { printf("thread %d: moon_distance = %d \n", omp_get_thread_num(), moon_distance); } printf(" \n"); printf("This value is the when use firstprivate() clause\n"); #pragma omp parallel firstprivate(moon_distance) { printf("thread %d: moon_distance = %d \n", omp_get_thread_num(), moon_distance); } printf(" \n"); printf("Actual initialization is: moon_distance = %d \n", moon_distance); return 0; }