variables.F90 731 Bytes
Newer Older
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
program exer1
  implicit none
  integer :: var1, var2
  var1 = 1
  var2 = 2

  !$OMP PARALLEL PRIVATE(VAR1, VAR2)
  print *, 'Region 1:       var1=', var1, 'var2=', var2
  var1 = var1 + 1
  var2 = var2 + 1
  !$OMP END PARALLEL
  print *, 'After region 1: var1=', var1, 'var2=', var2
  print *

  !$OMP PARALLEL FIRSTPRIVATE(VAR1, VAR2)
  print *, 'Region 2:       var1=', var1, 'var2=', var2
  var1 = var1 + 1
  var2 = var2 + 1
  !$OMP END PARALLEL
  print *, 'After region 2: var1=', var1, 'var2=', var2
  print *

  !$OMP PARALLEL
  print *, 'Region 3:       var1=', var1, 'var2=', var2
  var1 = var1 + 1
  var2 = var2 + 1
  !$OMP END PARALLEL
  print *, 'After region 3: var1=', var1, 'var2=', var2
  print *

end program exer1