1 | ! |
---|
2 | !$Header$ |
---|
3 | ! |
---|
4 | MODULE mod_phys_lmdz_mpi_data |
---|
5 | USE mod_const_mpi |
---|
6 | |
---|
7 | INTEGER,SAVE :: ii_begin |
---|
8 | INTEGER,SAVE :: ii_end |
---|
9 | INTEGER,SAVE :: jj_begin |
---|
10 | INTEGER,SAVE :: jj_end |
---|
11 | INTEGER,SAVE :: jj_nb |
---|
12 | INTEGER,SAVE :: ij_begin |
---|
13 | INTEGER,SAVE :: ij_end |
---|
14 | INTEGER,SAVE :: ij_nb |
---|
15 | INTEGER,SAVE :: klon_mpi_begin |
---|
16 | INTEGER,SAVE :: klon_mpi_end |
---|
17 | INTEGER,SAVE :: klon_mpi |
---|
18 | |
---|
19 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_nb |
---|
20 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_begin |
---|
21 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_end |
---|
22 | |
---|
23 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_begin |
---|
24 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_end |
---|
25 | |
---|
26 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_nb |
---|
27 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_begin |
---|
28 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_end |
---|
29 | |
---|
30 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_nb |
---|
31 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_begin |
---|
32 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_end |
---|
33 | |
---|
34 | |
---|
35 | INTEGER,SAVE :: mpi_rank |
---|
36 | INTEGER,SAVE :: mpi_size |
---|
37 | INTEGER,SAVE :: mpi_root |
---|
38 | LOGICAL,SAVE :: is_mpi_root |
---|
39 | LOGICAL,SAVE :: is_using_mpi |
---|
40 | |
---|
41 | |
---|
42 | LOGICAL,SAVE :: is_north_pole |
---|
43 | LOGICAL,SAVE :: is_south_pole |
---|
44 | INTEGER,SAVE :: COMM_LMDZ_PHY |
---|
45 | |
---|
46 | CONTAINS |
---|
47 | |
---|
48 | SUBROUTINE Init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib) |
---|
49 | USE mod_const_mpi, ONLY : COMM_LMDZ |
---|
50 | IMPLICIT NONE |
---|
51 | INTEGER,INTENT(in) :: iim |
---|
52 | INTEGER,INTENT(in) :: jjp1 |
---|
53 | INTEGER,INTENT(in) :: nb_proc |
---|
54 | INTEGER,INTENT(in) :: distrib(0:nb_proc-1) |
---|
55 | |
---|
56 | INTEGER :: ierr |
---|
57 | INTEGER :: klon_glo |
---|
58 | INTEGER :: i |
---|
59 | |
---|
60 | #ifdef CPP_MPI |
---|
61 | is_using_mpi=.TRUE. |
---|
62 | #else |
---|
63 | is_using_mpi=.FALSE. |
---|
64 | #endif |
---|
65 | |
---|
66 | if (iim.eq.1) then |
---|
67 | klon_glo=1 |
---|
68 | else |
---|
69 | klon_glo=iim*(jjp1-2)+2 |
---|
70 | endif |
---|
71 | |
---|
72 | COMM_LMDZ_PHY=COMM_LMDZ |
---|
73 | |
---|
74 | IF (is_using_mpi) THEN |
---|
75 | #ifdef CPP_MPI |
---|
76 | CALL MPI_COMM_SIZE(COMM_LMDZ_PHY,mpi_size,ierr) |
---|
77 | CALL MPI_COMM_RANK(COMM_LMDZ_PHY,mpi_rank,ierr) |
---|
78 | #endif |
---|
79 | ELSE |
---|
80 | mpi_size=1 |
---|
81 | mpi_rank=0 |
---|
82 | ENDIF |
---|
83 | |
---|
84 | IF (mpi_rank == 0) THEN |
---|
85 | mpi_root = 0 |
---|
86 | is_mpi_root = .true. |
---|
87 | ENDIF |
---|
88 | |
---|
89 | IF (mpi_rank == 0) THEN |
---|
90 | is_north_pole = .TRUE. |
---|
91 | ELSE |
---|
92 | is_north_pole = .FALSE. |
---|
93 | ENDIF |
---|
94 | |
---|
95 | IF (mpi_rank == mpi_size-1) THEN |
---|
96 | is_south_pole = .TRUE. |
---|
97 | ELSE |
---|
98 | is_south_pole = .FALSE. |
---|
99 | ENDIF |
---|
100 | |
---|
101 | ALLOCATE(jj_para_nb(0:mpi_size-1)) |
---|
102 | ALLOCATE(jj_para_begin(0:mpi_size-1)) |
---|
103 | ALLOCATE(jj_para_end(0:mpi_size-1)) |
---|
104 | |
---|
105 | ALLOCATE(ij_para_nb(0:mpi_size-1)) |
---|
106 | ALLOCATE(ij_para_begin(0:mpi_size-1)) |
---|
107 | ALLOCATE(ij_para_end(0:mpi_size-1)) |
---|
108 | |
---|
109 | ALLOCATE(ii_para_begin(0:mpi_size-1)) |
---|
110 | ALLOCATE(ii_para_end(0:mpi_size-1)) |
---|
111 | |
---|
112 | ALLOCATE(klon_mpi_para_nb(0:mpi_size-1)) |
---|
113 | ALLOCATE(klon_mpi_para_begin(0:mpi_size-1)) |
---|
114 | ALLOCATE(klon_mpi_para_end(0:mpi_size-1)) |
---|
115 | |
---|
116 | klon_mpi_para_nb(0:mpi_size-1)=distrib(0:nb_proc-1) |
---|
117 | |
---|
118 | DO i=0,mpi_size-1 |
---|
119 | IF (i==0) THEN |
---|
120 | klon_mpi_para_begin(i)=1 |
---|
121 | ELSE |
---|
122 | klon_mpi_para_begin(i)=klon_mpi_para_end(i-1)+1 |
---|
123 | ENDIF |
---|
124 | klon_mpi_para_end(i)=klon_mpi_para_begin(i)+klon_mpi_para_nb(i)-1 |
---|
125 | ENDDO |
---|
126 | |
---|
127 | |
---|
128 | DO i=0,mpi_size-1 |
---|
129 | |
---|
130 | IF (i==0) THEN |
---|
131 | ij_para_begin(i) = 1 |
---|
132 | ELSE |
---|
133 | ij_para_begin(i) = klon_mpi_para_begin(i)+iim-1 |
---|
134 | ENDIF |
---|
135 | |
---|
136 | jj_para_begin(i) = (ij_para_begin(i)-1)/iim + 1 |
---|
137 | ii_para_begin(i) = MOD(ij_para_begin(i)-1,iim) + 1 |
---|
138 | |
---|
139 | |
---|
140 | ij_para_end(i) = klon_mpi_para_end(i)+iim-1 |
---|
141 | jj_para_end(i) = (ij_para_end(i)-1)/iim + 1 |
---|
142 | ii_para_end(i) = MOD(ij_para_end(i)-1,iim) + 1 |
---|
143 | |
---|
144 | |
---|
145 | ij_para_nb(i) = ij_para_end(i)-ij_para_begin(i)+1 |
---|
146 | jj_para_nb(i) = jj_para_end(i)-jj_para_begin(i)+1 |
---|
147 | |
---|
148 | ENDDO |
---|
149 | PRINT *,' ii_para_begin: ',ii_para_begin |
---|
150 | PRINT *,' ii_para_end: ',ii_para_end |
---|
151 | PRINT *,' jj_para_begin: ',jj_para_begin |
---|
152 | PRINT *,' jj_para_end: ',jj_para_end |
---|
153 | PRINT *,' ij_para_begin: ',ij_para_begin |
---|
154 | PRINT *,' ij_para_end: ',ij_para_end |
---|
155 | PRINT *,' ij_para_nb: ',ij_para_nb |
---|
156 | |
---|
157 | ii_begin = ii_para_begin(mpi_rank) |
---|
158 | ii_end = ii_para_end(mpi_rank) |
---|
159 | jj_begin = jj_para_begin(mpi_rank) |
---|
160 | jj_end = jj_para_end(mpi_rank) |
---|
161 | jj_nb = jj_para_nb(mpi_rank) |
---|
162 | ij_begin = ij_para_begin(mpi_rank) |
---|
163 | ij_end = ij_para_end(mpi_rank) |
---|
164 | ij_nb = ij_para_nb(mpi_rank) |
---|
165 | klon_mpi_begin = klon_mpi_para_begin(mpi_rank) |
---|
166 | klon_mpi_end = klon_mpi_para_end(mpi_rank) |
---|
167 | klon_mpi = klon_mpi_para_nb(mpi_rank) |
---|
168 | |
---|
169 | CALL Print_module_data |
---|
170 | |
---|
171 | END SUBROUTINE Init_phys_lmdz_mpi_data |
---|
172 | |
---|
173 | SUBROUTINE print_module_data |
---|
174 | IMPLICIT NONE |
---|
175 | INCLUDE "iniprint.h" |
---|
176 | |
---|
177 | WRITE(lunout,*) 'ii_begin =', ii_begin |
---|
178 | WRITE(lunout,*) 'ii_end =', ii_end |
---|
179 | WRITE(lunout,*) 'jj_begin =',jj_begin |
---|
180 | WRITE(lunout,*) 'jj_end =', jj_end |
---|
181 | WRITE(lunout,*) 'jj_nb =', jj_nb |
---|
182 | WRITE(lunout,*) 'ij_begin =', ij_begin |
---|
183 | WRITE(lunout,*) 'ij_end =', ij_end |
---|
184 | WRITE(lunout,*) 'ij_nb =', ij_nb |
---|
185 | WRITE(lunout,*) 'klon_mpi_begin =', klon_mpi_begin |
---|
186 | WRITE(lunout,*) 'klon_mpi_end =', klon_mpi_end |
---|
187 | WRITE(lunout,*) 'klon_mpi =', klon_mpi |
---|
188 | WRITE(lunout,*) 'jj_para_nb =', jj_para_nb |
---|
189 | WRITE(lunout,*) 'jj_para_begin =', jj_para_begin |
---|
190 | WRITE(lunout,*) 'jj_para_end =', jj_para_end |
---|
191 | WRITE(lunout,*) 'ii_para_begin =', ii_para_begin |
---|
192 | WRITE(lunout,*) 'ii_para_end =', ii_para_end |
---|
193 | WRITE(lunout,*) 'ij_para_nb =', ij_para_nb |
---|
194 | WRITE(lunout,*) 'ij_para_begin =', ij_para_begin |
---|
195 | WRITE(lunout,*) 'ij_para_end =', ij_para_end |
---|
196 | WRITE(lunout,*) 'klon_mpi_para_nb =', klon_mpi_para_nb |
---|
197 | WRITE(lunout,*) 'klon_mpi_para_begin =', klon_mpi_para_begin |
---|
198 | WRITE(lunout,*) 'klon_mpi_para_end =', klon_mpi_para_end |
---|
199 | WRITE(lunout,*) 'mpi_rank =', mpi_rank |
---|
200 | WRITE(lunout,*) 'mpi_size =', mpi_size |
---|
201 | WRITE(lunout,*) 'mpi_root =', mpi_root |
---|
202 | WRITE(lunout,*) 'is_mpi_root =', is_mpi_root |
---|
203 | WRITE(lunout,*) 'is_north_pole =', is_north_pole |
---|
204 | WRITE(lunout,*) 'is_south_pole =', is_south_pole |
---|
205 | WRITE(lunout,*) 'COMM_LMDZ_PHY =', COMM_LMDZ_PHY |
---|
206 | |
---|
207 | END SUBROUTINE print_module_data |
---|
208 | |
---|
209 | END MODULE mod_phys_lmdz_mpi_data |
---|