source: LMDZ5/trunk/libf/phy_common/mod_phys_lmdz_omp_data.F90 @ 5456

Last change on this file since 5456 was 2429, checked in by Laurent Fairhead, 9 years ago

Correction on the calculation of the surface of the grid at the poles (problem was introduced
in r2222).
Due to the different distribution of OMP tasks in the dynamics and the physics, had to
introduce 2 new logical variables, is_pole_north_phy and is_pole_south_phy, and so decided
to rename the old is_north_pole/is_south_pole to is_north_pole_dyn/is_south_pole_dyn to
stay coherent and, hopefully, clear things up a bit.
LF

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1!
2!$Id: mod_phys_lmdz_omp_data.F90 2429 2016-01-27 12:43:09Z aborella $
3!
4MODULE 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_using_omp
10  LOGICAL,SAVE :: is_north_pole_phy, is_south_pole_phy
11 
12  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_nb
13  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_begin
14  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_end   
15 
16  INTEGER,SAVE :: klon_omp
17  INTEGER,SAVE :: klon_omp_begin
18  INTEGER,SAVE :: klon_omp_end
19!$OMP  THREADPRIVATE(omp_rank,klon_omp,is_omp_root,klon_omp_begin,klon_omp_end)
20!$OMP  THREADPRIVATE(is_north_pole_phy, is_south_pole_phy)
21
22CONTAINS
23 
24  SUBROUTINE Init_phys_lmdz_omp_data(klon_mpi)
25    USE dimphy
26    USE mod_phys_lmdz_mpi_data, ONLY : is_north_pole_dyn, is_south_pole_dyn
27    IMPLICIT NONE
28    INTEGER, INTENT(in) :: klon_mpi
29
30    INTEGER :: i
31
32    CHARACTER (LEN=20) :: modname='Init_phys_lmdz_omp_data'
33    CHARACTER (LEN=80) :: abort_message
34
35
36#ifdef CPP_OMP   
37    INTEGER :: OMP_GET_NUM_THREADS
38    EXTERNAL OMP_GET_NUM_THREADS
39    INTEGER :: OMP_GET_THREAD_NUM
40    EXTERNAL OMP_GET_THREAD_NUM
41#endif 
42
43#ifdef CPP_OMP
44!$OMP MASTER
45        is_using_omp=.TRUE.
46        omp_size=OMP_GET_NUM_THREADS()
47!$OMP END MASTER
48!$OMP BARRIER
49        omp_rank=OMP_GET_THREAD_NUM()   
50#else   
51    is_using_omp=.FALSE.
52    omp_size=1
53    omp_rank=0
54#endif
55
56   is_omp_root=.FALSE.
57!$OMP MASTER
58   IF (omp_rank==0) THEN
59     is_omp_root=.TRUE.
60   ELSE
61     abort_message = 'ANORMAL : OMP_MASTER /= 0'
62     CALL abort_gcm (modname,abort_message,1)
63   ENDIF
64!$OMP END MASTER
65
66
67!$OMP MASTER
68
69    ALLOCATE(klon_omp_para_nb(0:omp_size-1))
70    ALLOCATE(klon_omp_para_begin(0:omp_size-1))
71    ALLOCATE(klon_omp_para_end(0:omp_size-1))
72   
73    DO i=0,omp_size-1
74      klon_omp_para_nb(i)=klon_mpi/omp_size
75      IF (i<MOD(klon_mpi,omp_size)) klon_omp_para_nb(i)=klon_omp_para_nb(i)+1
76    ENDDO
77   
78    klon_omp_para_begin(0) = 1
79    klon_omp_para_end(0) = klon_omp_para_nb(0)
80   
81    DO i=1,omp_size-1
82      klon_omp_para_begin(i)=klon_omp_para_end(i-1)+1
83      klon_omp_para_end(i)=klon_omp_para_begin(i)+klon_omp_para_nb(i)-1
84    ENDDO
85!$OMP END MASTER
86!$OMP BARRIER
87
88   if ((is_north_pole_dyn) .AND. (omp_rank == 0 )) then
89      is_north_pole_phy = .TRUE.
90    else
91      is_north_pole_phy = .FALSE.
92    endif
93    if ((is_south_pole_dyn) .AND. (omp_rank == omp_size-1)) then
94      is_south_pole_phy = .TRUE.
95    else
96      is_south_pole_phy = .FALSE.
97    endif
98   
99    klon_omp=klon_omp_para_nb(omp_rank)
100    klon_omp_begin=klon_omp_para_begin(omp_rank)
101    klon_omp_end=klon_omp_para_end(omp_rank)
102   
103    CALL Print_module_data
104   
105  END SUBROUTINE Init_phys_lmdz_omp_data
106
107  SUBROUTINE Print_module_data
108  IMPLICIT NONE
109  INCLUDE "iniprint.h"
110
111!$OMP CRITICAL 
112  WRITE(lunout,*)'--------> TASK ',omp_rank
113  WRITE(lunout,*)'omp_size =',omp_size
114  WRITE(lunout,*)'omp_rank =',omp_rank
115  WRITE(lunout,*)'is_omp_root =',is_omp_root
116  WRITE(lunout,*)'klon_omp_para_nb =',klon_omp_para_nb
117  WRITE(lunout,*)'klon_omp_para_begin =',klon_omp_para_begin
118  WRITE(lunout,*)'klon_omp_para_end =',klon_omp_para_end   
119  WRITE(lunout,*)'klon_omp =',klon_omp
120  WRITE(lunout,*)'klon_omp_begin =',klon_omp_begin
121  WRITE(lunout,*)'klon_omp_end =',klon_omp_end   
122!$OMP END CRITICAL
123
124  END SUBROUTINE Print_module_data
125END MODULE mod_phys_lmdz_omp_data
Note: See TracBrowser for help on using the repository browser.