GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: phy_common/mod_phys_lmdz_omp_data.F90 Lines: 35 37 94.6 %
Date: 2023-06-30 12:51:15 Branches: 10 18 55.6 %

Line Branch Exec Source
1
!
2
!$Id: mod_phys_lmdz_omp_data.F90 3435 2019-01-22 15:21:59Z fairhead $
3
!
4
MODULE mod_phys_lmdz_omp_data
5
6
  INTEGER,SAVE :: omp_size
7
  INTEGER,SAVE :: omp_rank
8
  LOGICAL,SAVE :: is_omp_root
9
  LOGICAL,SAVE :: is_omp_master  ! alias of is_omp_root
10
  LOGICAL,SAVE :: is_using_omp
11
  LOGICAL,SAVE :: is_north_pole_phy, is_south_pole_phy
12
13
  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_nb
14
  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_begin
15
  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_end
16
17
  INTEGER,SAVE :: klon_omp
18
  INTEGER,SAVE :: klon_omp_begin
19
  INTEGER,SAVE :: klon_omp_end
20
!$OMP  THREADPRIVATE(omp_rank,klon_omp,is_omp_root,is_omp_master,klon_omp_begin,klon_omp_end)
21
!$OMP  THREADPRIVATE(is_north_pole_phy, is_south_pole_phy)
22
23
CONTAINS
24
25
1
  SUBROUTINE Init_phys_lmdz_omp_data(klon_mpi)
26
    USE dimphy
27
    USE mod_phys_lmdz_mpi_data, ONLY : is_north_pole_dyn, is_south_pole_dyn
28
    IMPLICIT NONE
29
    INTEGER, INTENT(in) :: klon_mpi
30
31
    INTEGER :: i
32
33
    CHARACTER (LEN=20) :: modname='Init_phys_lmdz_omp_data'
34
    CHARACTER (LEN=80) :: abort_message
35
36
37
#ifdef CPP_OMP
38
    INTEGER :: OMP_GET_NUM_THREADS
39
    EXTERNAL OMP_GET_NUM_THREADS
40
    INTEGER :: OMP_GET_THREAD_NUM
41
    EXTERNAL OMP_GET_THREAD_NUM
42
#endif
43
44
#ifdef CPP_OMP
45
!$OMP MASTER
46
        is_using_omp=.TRUE.
47
        omp_size=OMP_GET_NUM_THREADS()
48
!$OMP END MASTER
49
!$OMP BARRIER
50
        omp_rank=OMP_GET_THREAD_NUM()
51
#else
52
1
    is_using_omp=.FALSE.
53
1
    omp_size=1
54
1
    omp_rank=0
55
#endif
56
57
   is_omp_root=.FALSE.
58
!$OMP MASTER
59
   IF (omp_rank==0) THEN
60
1
     is_omp_root=.TRUE.
61
   ELSE
62
     abort_message = 'ANORMAL : OMP_MASTER /= 0'
63
     CALL abort_physic (modname,abort_message,1)
64
   ENDIF
65
!$OMP END MASTER
66
1
   is_omp_master=is_omp_root
67
68
!$OMP MASTER
69
70

1
    ALLOCATE(klon_omp_para_nb(0:omp_size-1))
71

1
    ALLOCATE(klon_omp_para_begin(0:omp_size-1))
72

1
    ALLOCATE(klon_omp_para_end(0:omp_size-1))
73
74
2
    DO i=0,omp_size-1
75
1
      klon_omp_para_nb(i)=klon_mpi/omp_size
76
1
      IF (i<MOD(klon_mpi,omp_size)) klon_omp_para_nb(i)=klon_omp_para_nb(i)+1
77
    ENDDO
78
79
1
    klon_omp_para_begin(0) = 1
80
1
    klon_omp_para_end(0) = klon_omp_para_nb(0)
81
82
    DO i=1,omp_size-1
83
      klon_omp_para_begin(i)=klon_omp_para_end(i-1)+1
84
      klon_omp_para_end(i)=klon_omp_para_begin(i)+klon_omp_para_nb(i)-1
85
    ENDDO
86
!$OMP END MASTER
87
!$OMP BARRIER
88
89
1
   if ((is_north_pole_dyn) .AND. (omp_rank == 0 )) then
90
1
      is_north_pole_phy = .TRUE.
91
    else
92
      is_north_pole_phy = .FALSE.
93
    endif
94
1
    if ((is_south_pole_dyn) .AND. (omp_rank == omp_size-1)) then
95
1
      is_south_pole_phy = .TRUE.
96
    else
97
      is_south_pole_phy = .FALSE.
98
    endif
99
100
1
    klon_omp=klon_omp_para_nb(omp_rank)
101
1
    klon_omp_begin=klon_omp_para_begin(omp_rank)
102
1
    klon_omp_end=klon_omp_para_end(omp_rank)
103
104
1
    CALL Print_module_data
105
106
1
  END SUBROUTINE Init_phys_lmdz_omp_data
107
108
1
  SUBROUTINE Print_module_data
109
  USE print_control_mod, ONLY: lunout
110
  IMPLICIT NONE
111
!  INCLUDE "iniprint.h"
112
113
!$OMP CRITICAL
114
1
  WRITE(lunout,*)'--------> TASK ',omp_rank
115
1
  WRITE(lunout,*)'omp_size =',omp_size
116
1
  WRITE(lunout,*)'omp_rank =',omp_rank
117
1
  WRITE(lunout,*)'is_omp_root =',is_omp_root
118
1
  WRITE(lunout,*)'klon_omp_para_nb =',klon_omp_para_nb
119
1
  WRITE(lunout,*)'klon_omp_para_begin =',klon_omp_para_begin
120
1
  WRITE(lunout,*)'klon_omp_para_end =',klon_omp_para_end
121
1
  WRITE(lunout,*)'klon_omp =',klon_omp
122
1
  WRITE(lunout,*)'klon_omp_begin =',klon_omp_begin
123
1
  WRITE(lunout,*)'klon_omp_end =',klon_omp_end
124
!$OMP END CRITICAL
125
126
1
  END SUBROUTINE Print_module_data
127
END MODULE mod_phys_lmdz_omp_data