-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample1.f90
More file actions
41 lines (30 loc) · 818 Bytes
/
Example1.f90
File metadata and controls
41 lines (30 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
! ***************************************************
! OpenMP tutorial
! J. E. Drut
! University of North Carolina
! Chapel Hill
!
! CAP-REU program, July 2015
!
! Example 1: Parallelizing a loop with OpenMP;
! Basic understanding of threads.
! ***************************************************
PROGRAM Example1
USE defs
USE omp_lib
IMPLICIT NONE
INTEGER :: i,j,k
REAL(DP) :: x,y,z
! Get the maximum possible number of threads
print*, OMP_GET_MAX_THREADS()
! Set the number of available threads by hand
!CALL OMP_SET_NUM_THREADS(N_thread)
! Our most basic loop, now parallelized
!$OMP PARALLEL DO
DO i = 1, 100
print*, 'I should not be doing this so many times', i
END DO
!$OMP END PARALLEL DO
! Run this code and notice the order in which the values of
! i are printed to the screen.
END PROGRAM