1 |
|
|
! |
2 |
|
|
!$Id: mod_phys_lmdz_mpi_data.F90 4127 2022-04-20 09:01:09Z acozic $ |
3 |
|
|
! |
4 |
|
|
MODULE mod_phys_lmdz_mpi_data |
5 |
|
|
|
6 |
|
|
INTEGER,SAVE :: ii_begin |
7 |
|
|
INTEGER,SAVE :: ii_end |
8 |
|
|
INTEGER,SAVE :: jj_begin |
9 |
|
|
INTEGER,SAVE :: jj_end |
10 |
|
|
INTEGER,SAVE :: jj_nb |
11 |
|
|
INTEGER,SAVE :: ij_begin |
12 |
|
|
INTEGER,SAVE :: ij_end |
13 |
|
|
INTEGER,SAVE :: ij_nb |
14 |
|
|
INTEGER,SAVE :: klon_mpi_begin |
15 |
|
|
INTEGER,SAVE :: klon_mpi_end |
16 |
|
|
INTEGER,SAVE :: klon_mpi |
17 |
|
|
|
18 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_nb |
19 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_begin |
20 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_end |
21 |
|
|
|
22 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_begin |
23 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_end |
24 |
|
|
|
25 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_nb |
26 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_begin |
27 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_end |
28 |
|
|
|
29 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_nb |
30 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_begin |
31 |
|
|
INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_end |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
INTEGER,SAVE :: mpi_rank |
35 |
|
|
INTEGER,SAVE :: mpi_size |
36 |
|
|
INTEGER,SAVE :: mpi_master |
37 |
|
|
LOGICAL,SAVE :: is_mpi_root |
38 |
|
|
LOGICAL,SAVE :: is_using_mpi |
39 |
|
|
|
40 |
|
|
|
41 |
|
|
LOGICAL,SAVE :: is_north_pole_dyn |
42 |
|
|
LOGICAL,SAVE :: is_south_pole_dyn |
43 |
|
|
INTEGER,SAVE :: COMM_LMDZ_PHY |
44 |
|
|
INTEGER,SAVE :: MPI_REAL_LMDZ ! MPI_REAL8 |
45 |
|
|
|
46 |
|
|
CONTAINS |
47 |
|
|
|
48 |
|
1 |
SUBROUTINE init_phys_lmdz_mpi_data(nbp, nbp_lon, nbp_lat, nbp_lev, grid_type, nvertex, communicator) |
49 |
|
|
|
50 |
|
|
IMPLICIT NONE |
51 |
|
|
#ifdef CPP_MPI |
52 |
|
|
INCLUDE 'mpif.h' |
53 |
|
|
#endif |
54 |
|
|
INTEGER,INTENT(IN) :: nbp |
55 |
|
|
INTEGER,INTENT(IN) :: nbp_lon |
56 |
|
|
INTEGER,INTENT(IN) :: nbp_lat |
57 |
|
|
INTEGER,INTENT(IN) :: nbp_lev |
58 |
|
|
INTEGER,INTENT(IN) :: communicator |
59 |
|
|
INTEGER,INTENT(IN) :: grid_type |
60 |
|
|
INTEGER,INTENT(IN) :: nvertex |
61 |
|
|
|
62 |
|
|
INTEGER,ALLOCATABLE :: distrib(:) |
63 |
|
|
INTEGER :: ierr |
64 |
|
|
INTEGER :: klon_glo |
65 |
|
|
INTEGER :: i |
66 |
|
|
|
67 |
|
|
#ifdef CPP_MPI |
68 |
|
|
is_using_mpi=.TRUE. |
69 |
|
|
#else |
70 |
|
1 |
is_using_mpi=.FALSE. |
71 |
|
|
#endif |
72 |
|
|
|
73 |
|
1 |
if ((nbp_lon.eq.1).and.(nbp_lat.eq.1)) then ! running 1D column model |
74 |
|
|
klon_glo=1 |
75 |
|
|
else |
76 |
|
|
! The usual global physics grid: 1 point for each pole and nbp_lon points |
77 |
|
|
! for all other latitudes |
78 |
|
|
klon_glo=nbp_lon*(nbp_lat-2)+2 |
79 |
|
|
endif |
80 |
|
|
|
81 |
|
1 |
COMM_LMDZ_PHY=communicator |
82 |
|
|
|
83 |
|
|
IF (is_using_mpi) THEN |
84 |
|
|
#ifdef CPP_MPI |
85 |
|
|
MPI_REAL_LMDZ=MPI_REAL8 |
86 |
|
|
CALL MPI_COMM_SIZE(COMM_LMDZ_PHY,mpi_size,ierr) |
87 |
|
|
CALL MPI_COMM_RANK(COMM_LMDZ_PHY,mpi_rank,ierr) |
88 |
|
|
#endif |
89 |
|
|
ELSE |
90 |
|
1 |
mpi_size=1 |
91 |
|
1 |
mpi_rank=0 |
92 |
|
|
ENDIF |
93 |
|
|
|
94 |
✗✓ |
1 |
ALLOCATE(distrib(0:mpi_size-1)) |
95 |
|
|
|
96 |
|
|
IF (is_using_mpi) THEN |
97 |
|
|
#ifdef CPP_MPI |
98 |
|
|
CALL MPI_ALLGATHER(nbp,1,MPI_INTEGER,distrib,1,MPI_INTEGER,COMM_LMDZ_PHY,ierr) |
99 |
|
|
#endif |
100 |
|
|
ELSE |
101 |
✓✓ |
2 |
distrib(:)=nbp |
102 |
|
|
ENDIF |
103 |
|
|
|
104 |
|
|
|
105 |
|
|
IF (mpi_rank == 0) THEN |
106 |
|
1 |
mpi_master = 0 |
107 |
|
1 |
is_mpi_root = .true. |
108 |
|
|
ENDIF |
109 |
|
|
|
110 |
|
|
IF (mpi_rank == 0) THEN |
111 |
|
1 |
is_north_pole_dyn = .TRUE. |
112 |
|
|
ELSE |
113 |
|
|
is_north_pole_dyn = .FALSE. |
114 |
|
|
ENDIF |
115 |
|
|
|
116 |
|
|
IF (mpi_rank == mpi_size-1) THEN |
117 |
|
1 |
is_south_pole_dyn = .TRUE. |
118 |
|
|
ELSE |
119 |
|
|
is_south_pole_dyn = .FALSE. |
120 |
|
|
ENDIF |
121 |
|
|
|
122 |
✗✓✗✓
|
1 |
ALLOCATE(jj_para_nb(0:mpi_size-1)) |
123 |
✗✓✗✓
|
1 |
ALLOCATE(jj_para_begin(0:mpi_size-1)) |
124 |
✗✓✗✓
|
1 |
ALLOCATE(jj_para_end(0:mpi_size-1)) |
125 |
|
|
|
126 |
✗✓✗✓
|
1 |
ALLOCATE(ij_para_nb(0:mpi_size-1)) |
127 |
✗✓✗✓
|
1 |
ALLOCATE(ij_para_begin(0:mpi_size-1)) |
128 |
✗✓✗✓
|
1 |
ALLOCATE(ij_para_end(0:mpi_size-1)) |
129 |
|
|
|
130 |
✗✓✗✓
|
1 |
ALLOCATE(ii_para_begin(0:mpi_size-1)) |
131 |
✗✓✗✓
|
1 |
ALLOCATE(ii_para_end(0:mpi_size-1)) |
132 |
|
|
|
133 |
✗✓✗✓
|
1 |
ALLOCATE(klon_mpi_para_nb(0:mpi_size-1)) |
134 |
✗✓✗✓
|
1 |
ALLOCATE(klon_mpi_para_begin(0:mpi_size-1)) |
135 |
✗✓✗✓
|
1 |
ALLOCATE(klon_mpi_para_end(0:mpi_size-1)) |
136 |
|
|
|
137 |
|
|
|
138 |
✓✓ |
2 |
klon_mpi_para_nb(0:mpi_size-1)=distrib(0:mpi_size-1) |
139 |
|
|
|
140 |
✓✓ |
2 |
DO i=0,mpi_size-1 |
141 |
|
|
IF (i==0) THEN |
142 |
|
1 |
klon_mpi_para_begin(i)=1 |
143 |
|
|
ELSE |
144 |
|
|
klon_mpi_para_begin(i)=klon_mpi_para_end(i-1)+1 |
145 |
|
|
ENDIF |
146 |
|
2 |
klon_mpi_para_end(i)=klon_mpi_para_begin(i)+klon_mpi_para_nb(i)-1 |
147 |
|
|
ENDDO |
148 |
|
|
|
149 |
|
|
|
150 |
✓✓ |
2 |
DO i=0,mpi_size-1 |
151 |
|
|
|
152 |
|
|
IF (i==0) THEN |
153 |
|
1 |
ij_para_begin(i) = 1 |
154 |
|
|
ELSE |
155 |
|
|
ij_para_begin(i) = klon_mpi_para_begin(i)+nbp_lon-1 |
156 |
|
|
ENDIF |
157 |
|
|
|
158 |
|
1 |
jj_para_begin(i) = (ij_para_begin(i)-1)/nbp_lon + 1 |
159 |
|
1 |
ii_para_begin(i) = MOD(ij_para_begin(i)-1,nbp_lon) + 1 |
160 |
|
|
|
161 |
|
|
|
162 |
|
1 |
ij_para_end(i) = klon_mpi_para_end(i)+nbp_lon-1 |
163 |
|
1 |
jj_para_end(i) = (ij_para_end(i)-1)/nbp_lon + 1 |
164 |
|
1 |
ii_para_end(i) = MOD(ij_para_end(i)-1,nbp_lon) + 1 |
165 |
|
|
|
166 |
|
|
|
167 |
|
1 |
ij_para_nb(i) = ij_para_end(i)-ij_para_begin(i)+1 |
168 |
|
2 |
jj_para_nb(i) = jj_para_end(i)-jj_para_begin(i)+1 |
169 |
|
|
|
170 |
|
|
ENDDO |
171 |
|
|
|
172 |
|
1 |
ii_begin = ii_para_begin(mpi_rank) |
173 |
|
1 |
ii_end = ii_para_end(mpi_rank) |
174 |
|
1 |
jj_begin = jj_para_begin(mpi_rank) |
175 |
|
1 |
jj_end = jj_para_end(mpi_rank) |
176 |
|
1 |
jj_nb = jj_para_nb(mpi_rank) |
177 |
|
1 |
ij_begin = ij_para_begin(mpi_rank) |
178 |
|
1 |
ij_end = ij_para_end(mpi_rank) |
179 |
|
1 |
ij_nb = ij_para_nb(mpi_rank) |
180 |
|
1 |
klon_mpi_begin = klon_mpi_para_begin(mpi_rank) |
181 |
|
1 |
klon_mpi_end = klon_mpi_para_end(mpi_rank) |
182 |
|
1 |
klon_mpi = klon_mpi_para_nb(mpi_rank) |
183 |
|
|
|
184 |
|
1 |
CALL Print_module_data |
185 |
|
|
|
186 |
|
|
#ifdef INCA |
187 |
|
|
CALL init_inca_para( & |
188 |
|
|
nbp_lon,nbp_lat,nbp_lev,klon_glo,mpi_size, & |
189 |
|
|
distrib,nvertex, grid_type,communicator) |
190 |
|
|
#endif |
191 |
|
|
|
192 |
✓✗ |
1 |
END SUBROUTINE Init_phys_lmdz_mpi_data |
193 |
|
|
|
194 |
|
1 |
SUBROUTINE print_module_data |
195 |
|
|
USE print_control_mod, ONLY: lunout |
196 |
|
|
IMPLICIT NONE |
197 |
|
|
! INCLUDE "iniprint.h" |
198 |
|
|
|
199 |
|
1 |
WRITE(lunout,*) 'ii_begin =', ii_begin |
200 |
|
1 |
WRITE(lunout,*) 'ii_end =', ii_end |
201 |
|
1 |
WRITE(lunout,*) 'jj_begin =',jj_begin |
202 |
|
1 |
WRITE(lunout,*) 'jj_end =', jj_end |
203 |
|
1 |
WRITE(lunout,*) 'jj_nb =', jj_nb |
204 |
|
1 |
WRITE(lunout,*) 'ij_begin =', ij_begin |
205 |
|
1 |
WRITE(lunout,*) 'ij_end =', ij_end |
206 |
|
1 |
WRITE(lunout,*) 'ij_nb =', ij_nb |
207 |
|
1 |
WRITE(lunout,*) 'klon_mpi_begin =', klon_mpi_begin |
208 |
|
1 |
WRITE(lunout,*) 'klon_mpi_end =', klon_mpi_end |
209 |
|
1 |
WRITE(lunout,*) 'klon_mpi =', klon_mpi |
210 |
|
1 |
WRITE(lunout,*) 'jj_para_nb =', jj_para_nb |
211 |
|
1 |
WRITE(lunout,*) 'jj_para_begin =', jj_para_begin |
212 |
|
1 |
WRITE(lunout,*) 'jj_para_end =', jj_para_end |
213 |
|
1 |
WRITE(lunout,*) 'ii_para_begin =', ii_para_begin |
214 |
|
1 |
WRITE(lunout,*) 'ii_para_end =', ii_para_end |
215 |
|
1 |
WRITE(lunout,*) 'ij_para_nb =', ij_para_nb |
216 |
|
1 |
WRITE(lunout,*) 'ij_para_begin =', ij_para_begin |
217 |
|
1 |
WRITE(lunout,*) 'ij_para_end =', ij_para_end |
218 |
|
1 |
WRITE(lunout,*) 'klon_mpi_para_nb =', klon_mpi_para_nb |
219 |
|
1 |
WRITE(lunout,*) 'klon_mpi_para_begin =', klon_mpi_para_begin |
220 |
|
1 |
WRITE(lunout,*) 'klon_mpi_para_end =', klon_mpi_para_end |
221 |
|
1 |
WRITE(lunout,*) 'mpi_rank =', mpi_rank |
222 |
|
1 |
WRITE(lunout,*) 'mpi_size =', mpi_size |
223 |
|
1 |
WRITE(lunout,*) 'mpi_master =', mpi_master |
224 |
|
1 |
WRITE(lunout,*) 'is_mpi_root =', is_mpi_root |
225 |
|
1 |
WRITE(lunout,*) 'is_north_pole =', is_north_pole_dyn |
226 |
|
1 |
WRITE(lunout,*) 'is_south_pole =', is_south_pole_dyn |
227 |
|
1 |
WRITE(lunout,*) 'COMM_LMDZ_PHY =', COMM_LMDZ_PHY |
228 |
|
|
|
229 |
|
1 |
END SUBROUTINE print_module_data |
230 |
|
|
|
231 |
|
|
END MODULE mod_phys_lmdz_mpi_data |