1) Set the maximum number of threads to 12 using environmental variables. Answer: setenv OMP_NUM_THREADS 12 2) Make an OpenMP program that a) prints the maximum number of threads available, b) set the number of threads to 8, c) prints 'Hello, I am thread [thread number]' from every thread. Answer: PROGRAM OMP_PROG USE omp_lib IMPLICIT NONE INTEGER :: TID,OMP_GET_MAX_THREADS,OMP_GET_THREAD_NUM TID = OMP_GET_MAX_THREADS() PRINT *, 'max thread = ', TID CALL omp_set_num_threads(8) !\$OMP PARALLEL PRIVATE(TID) TID = OMP_GET_THREAD_NUM() PRINT *, 'Hello from thread = ', TID !\$OMP END PARALLEL END PROGRAM OMP_PROG 3) Make a simple vector-add program (C(I)=A(I)+B(I) for all I=1,...,N), where * Arrays A, B, C, and variable N will be shared by all threads. * Variable I will be private to each thread; each thread will have its own unique copy. * The iterations of the loop will be distributed dynamically in CHUNK sized pieces. * Threads will not synchronize upon completing their individual pieces of work. Answer: PROGRAM VEC_ADD_DO INTEGER N, CHUNKSIZE, CHUNK, I PARAMETER (N=1000) PARAMETER (CHUNKSIZE=100) REAL A(N), B(N), C(N) ! Some initializations DO I = 1, N A(I) = I * 1.0 B(I) = A(I) ENDDO CHUNK = CHUNKSIZE !\$OMP PARALLEL SHARED(A,B,C,CHUNK) PRIVATE(I) !\$OMP DO SCHEDULE(DYNAMIC,CHUNK) DO I = 1, N C(I) = A(I) + B(I) ENDDO !\$OMP END DO NOWAIT !\$OMP END PARALLEL END 4) Try to utilize OpenMP in your own program.