1 | SUBROUTINE mpp_init2 |
---|
2 | !!---------------------------------------------------------------------- |
---|
3 | !! *** ROUTINE mpp_init2 *** |
---|
4 | !! |
---|
5 | !! * Purpose : Lay out the global domain over processors. |
---|
6 | !! FOR USING THIS VERSION, A PREPROCESSING TRAITMENT IS RECOMMENDED |
---|
7 | !! FOR DEFINING BETTER CUTTING OUT. |
---|
8 | !! This routine is used with a the bathymetry file. |
---|
9 | !! In this version, the land processors are avoided and the adress |
---|
10 | !! processor (nproc, narea,noea, ...) are calculated again. |
---|
11 | !! The jpnij parameter can be lesser than jpni x jpnj |
---|
12 | !! and this jpnij parameter must be calculated before with an |
---|
13 | !! algoritmic preprocessing program. |
---|
14 | !! |
---|
15 | !! ** Method : Global domain is distributed in smaller local domains. |
---|
16 | !! Periodic condition is a function of the local domain position |
---|
17 | !! (global boundary or neighbouring domain) and of the global |
---|
18 | !! periodic |
---|
19 | !! Type : jperio global periodic condition |
---|
20 | !! nperio local periodic condition |
---|
21 | !! |
---|
22 | !! ** Action : nimpp : longitudinal index |
---|
23 | !! njmpp : latitudinal index |
---|
24 | !! nperio : lateral condition type |
---|
25 | !! narea : number for local area |
---|
26 | !! nlci : first dimension |
---|
27 | !! nlcj : second dimension |
---|
28 | !! nproc : number for local processor |
---|
29 | !! noea : number for local neighboring processor |
---|
30 | !! nowe : number for local neighboring processor |
---|
31 | !! noso : number for local neighboring processor |
---|
32 | !! nono : number for local neighboring processor |
---|
33 | !! |
---|
34 | !! History : |
---|
35 | !! ! 94-11 (M. Guyon) Original code |
---|
36 | !! ! 95-04 (J. Escobar, M. Imbard) |
---|
37 | !! ! 98-02 (M. Guyon) FETI method |
---|
38 | !! ! 98-05 (M. Imbard, J. Escobar, L. Colombet ) SHMEM and MPI versions |
---|
39 | !! 9.0 ! 04-01 (G. Madec, J.M Molines) F90 : free form , north fold jpni > 1 |
---|
40 | !!---------------------------------------------------------------------- |
---|
41 | USE in_out_manager ! I/O Manager |
---|
42 | USE iom |
---|
43 | !! |
---|
44 | INTEGER :: ji, jj, jn, jproc, jarea ! dummy loop indices |
---|
45 | INTEGER :: inum ! temporary logical unit |
---|
46 | INTEGER :: idir ! temporary integers |
---|
47 | INTEGER :: ios ! Local integer output status for namelist read |
---|
48 | INTEGER :: & |
---|
49 | ii, ij, ifreq, il1, il2, & ! temporary integers |
---|
50 | icont, ili, ilj, & ! " " |
---|
51 | isurf, ijm1, imil, & ! " " |
---|
52 | iino, ijno, iiso, ijso, & ! " " |
---|
53 | iiea, ijea, iiwe, ijwe, & ! " " |
---|
54 | iinw, ijnw, iine, ijne, & ! " " |
---|
55 | iisw, ijsw, iise, ijse, & ! " " |
---|
56 | iresti, irestj, iproc ! " " |
---|
57 | INTEGER, DIMENSION(jpnij) :: & |
---|
58 | iin, ijn |
---|
59 | INTEGER, DIMENSION(jpni,jpnj) :: & |
---|
60 | iimppt, ijmppt, ilci , ilcj , & ! temporary workspace |
---|
61 | ipproc, ibondj, ibondi, ipolj , & ! " " |
---|
62 | ilei , ilej , ildi , ildj , & ! " " |
---|
63 | ioea , iowe , ioso , iono , & ! " " |
---|
64 | ione , ionw , iose , iosw , & ! " " |
---|
65 | ibne , ibnw , ibse , ibsw ! " " |
---|
66 | INTEGER, DIMENSION(jpiglo,jpjglo) :: & |
---|
67 | imask ! temporary global workspace |
---|
68 | REAL(wp), DIMENSION(jpiglo,jpjglo) :: & |
---|
69 | zdta, zdtaisf ! temporary data workspace |
---|
70 | REAL(wp) :: zidom , zjdom ! temporary scalars |
---|
71 | |
---|
72 | ! read namelist for ln_zco |
---|
73 | NAMELIST/namzgr/ ln_zco, ln_zps, ln_sco, ln_isfcav |
---|
74 | |
---|
75 | !!---------------------------------------------------------------------- |
---|
76 | !! OPA 9.0 , LOCEAN-IPSL (2005) |
---|
77 | !! $Id$ |
---|
78 | !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt |
---|
79 | !!---------------------------------------------------------------------- |
---|
80 | |
---|
81 | REWIND( numnam_ref ) ! Namelist namzgr in reference namelist : Vertical coordinate |
---|
82 | READ ( numnam_ref, namzgr, IOSTAT = ios, ERR = 901) |
---|
83 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzgr in reference namelist', lwp ) |
---|
84 | |
---|
85 | REWIND( numnam_cfg ) ! Namelist namzgr in configuration namelist : Vertical coordinate |
---|
86 | READ ( numnam_cfg, namzgr, IOSTAT = ios, ERR = 902 ) |
---|
87 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzgr in configuration namelist', lwp ) |
---|
88 | IF(lwm) WRITE ( numond, namzgr ) |
---|
89 | |
---|
90 | IF(lwp)WRITE(numout,*) |
---|
91 | IF(lwp)WRITE(numout,*) 'mpp_init : Message Passing MPI' |
---|
92 | IF(lwp)WRITE(numout,*) '~~~~~~~~' |
---|
93 | IF(lwp)WRITE(numout,*) ' ' |
---|
94 | |
---|
95 | IF( jpni*jpnj < jpnij ) CALL ctl_stop( ' jpnij > jpni x jpnj impossible' ) |
---|
96 | |
---|
97 | ! 0. initialisation |
---|
98 | ! ----------------- |
---|
99 | |
---|
100 | ! open the file |
---|
101 | ! Remember that at this level in the code, mpp is not yet initialized, so |
---|
102 | ! the file must be open with jpdom_unknown, and kstart amd kcount forced |
---|
103 | IF ( ln_zco ) THEN |
---|
104 | CALL iom_open ( 'bathy_level.nc', inum ) ! Level bathymetry |
---|
105 | CALL iom_get ( inum, jpdom_unknown, 'Bathy_level', zdta, kstart=(/jpizoom,jpjzoom/), kcount=(/jpiglo,jpjglo/) ) |
---|
106 | ELSE |
---|
107 | CALL iom_open ( 'bathy_meter.nc', inum ) ! Meter bathy in case of partial steps |
---|
108 | CALL iom_get ( inum, jpdom_unknown, 'Bathymetry' , zdta, kstart=(/jpizoom,jpjzoom/), kcount=(/jpiglo,jpjglo/) ) |
---|
109 | ENDIF |
---|
110 | CALL iom_close (inum) |
---|
111 | |
---|
112 | ! used to compute the land processor in case of not masked bathy file. |
---|
113 | zdtaisf(:,:) = 0.0_wp |
---|
114 | IF ( ln_isfcav ) THEN |
---|
115 | CALL iom_open ( 'bathy_meter.nc', inum ) ! Meter bathy in case of partial steps |
---|
116 | CALL iom_get ( inum, jpdom_unknown, 'isf_draft' , zdtaisf, kstart=(/jpizoom,jpjzoom/), kcount=(/jpiglo,jpjglo/) ) |
---|
117 | END IF |
---|
118 | CALL iom_close (inum) |
---|
119 | |
---|
120 | ! land/sea mask over the global/zoom domain |
---|
121 | |
---|
122 | imask(:,:)=1 |
---|
123 | WHERE ( zdta(:,:) - zdtaisf(:,:) <= 0. ) imask = 0 |
---|
124 | |
---|
125 | ! 1. Dimension arrays for subdomains |
---|
126 | ! ----------------------------------- |
---|
127 | |
---|
128 | ! Computation of local domain sizes ilci() ilcj() |
---|
129 | ! These dimensions depend on global sizes jpni,jpnj and jpiglo,jpjglo |
---|
130 | ! The subdomains are squares leeser than or equal to the global |
---|
131 | ! dimensions divided by the number of processors minus the overlap |
---|
132 | ! array. |
---|
133 | |
---|
134 | nreci=2*jpreci |
---|
135 | nrecj=2*jprecj |
---|
136 | iresti = 1 + MOD( jpiglo - nreci -1 , jpni ) |
---|
137 | irestj = 1 + MOD( jpjglo - nrecj -1 , jpnj ) |
---|
138 | |
---|
139 | #if defined key_nemocice_decomp |
---|
140 | ! Change padding to be consistent with CICE |
---|
141 | ilci(1:jpni-1 ,:) = jpi |
---|
142 | ilci(jpni ,:) = jpiglo - (jpni - 1) * (jpi - nreci) |
---|
143 | |
---|
144 | ilcj(:, 1:jpnj-1) = jpj |
---|
145 | ilcj(:, jpnj) = jpjglo - (jpnj - 1) * (jpj - nrecj) |
---|
146 | #else |
---|
147 | ilci(1:iresti ,:) = jpi |
---|
148 | ilci(iresti+1:jpni ,:) = jpi-1 |
---|
149 | |
---|
150 | ilcj(:, 1:irestj) = jpj |
---|
151 | ilcj(:, irestj+1:jpnj) = jpj-1 |
---|
152 | #endif |
---|
153 | |
---|
154 | nfilcit(:,:) = ilci(:,:) |
---|
155 | |
---|
156 | IF(lwp) WRITE(numout,*) |
---|
157 | IF(lwp) WRITE(numout,*) ' mpp_init2: defines mpp subdomains' |
---|
158 | IF(lwp) WRITE(numout,*) ' ~~~~~~ ----------------------' |
---|
159 | IF(lwp) WRITE(numout,*) |
---|
160 | IF(lwp) WRITE(numout,*) 'iresti=',iresti,' irestj=',irestj |
---|
161 | IF(lwp) WRITE(numout,*) |
---|
162 | IF(lwp) WRITE(numout,*) 'jpni=',jpni,' jpnj=',jpnj |
---|
163 | |
---|
164 | zidom = nreci + sum(ilci(:,1) - nreci ) |
---|
165 | IF(lwp) WRITE(numout,*) |
---|
166 | IF(lwp) WRITE(numout,*)' sum ilci(i,1)=',zidom,' jpiglo=',jpiglo |
---|
167 | |
---|
168 | zjdom = nrecj + sum(ilcj(1,:) - nrecj ) |
---|
169 | IF(lwp) WRITE(numout,*) ' sum ilcj(1,j)=',zjdom,' jpjglo=',jpjglo |
---|
170 | IF(lwp) WRITE(numout,*) |
---|
171 | |
---|
172 | |
---|
173 | ! 2. Index arrays for subdomains |
---|
174 | ! ------------------------------- |
---|
175 | |
---|
176 | iimppt(:,:) = 1 |
---|
177 | ijmppt(:,:) = 1 |
---|
178 | ipproc(:,:) = -1 |
---|
179 | |
---|
180 | IF( jpni > 1 )THEN |
---|
181 | DO jj = 1, jpnj |
---|
182 | DO ji = 2, jpni |
---|
183 | iimppt(ji,jj) = iimppt(ji-1,jj) + ilci(ji-1,jj) - nreci |
---|
184 | END DO |
---|
185 | END DO |
---|
186 | ENDIF |
---|
187 | nfiimpp(:,:) = iimppt(:,:) |
---|
188 | |
---|
189 | IF( jpnj > 1 )THEN |
---|
190 | DO jj = 2, jpnj |
---|
191 | DO ji = 1, jpni |
---|
192 | ijmppt(ji,jj) = ijmppt(ji,jj-1) + ilcj(ji,jj-1) - nrecj |
---|
193 | END DO |
---|
194 | END DO |
---|
195 | ENDIF |
---|
196 | |
---|
197 | |
---|
198 | ! 3. Subdomain description in the Regular Case |
---|
199 | ! -------------------------------------------- |
---|
200 | |
---|
201 | nperio = 0 |
---|
202 | icont = -1 |
---|
203 | DO jarea = 1, jpni*jpnj |
---|
204 | ii = 1 + MOD(jarea-1,jpni) |
---|
205 | ij = 1 + (jarea-1)/jpni |
---|
206 | ili = ilci(ii,ij) |
---|
207 | ilj = ilcj(ii,ij) |
---|
208 | ibondj(ii,ij) = -1 |
---|
209 | IF( jarea > jpni ) ibondj(ii,ij) = 0 |
---|
210 | IF( jarea > (jpnj-1)*jpni ) ibondj(ii,ij) = 1 |
---|
211 | IF( jpnj == 1 ) ibondj(ii,ij) = 2 |
---|
212 | ibondi(ii,ij) = 0 |
---|
213 | IF( MOD(jarea,jpni) == 1 ) ibondi(ii,ij) = -1 |
---|
214 | IF( MOD(jarea,jpni) == 0 ) ibondi(ii,ij) = 1 |
---|
215 | IF( jpni == 1 ) ibondi(ii,ij) = 2 |
---|
216 | |
---|
217 | ! 2.4 Subdomain neighbors |
---|
218 | |
---|
219 | iproc = jarea - 1 |
---|
220 | ioso(ii,ij) = iproc - jpni |
---|
221 | iowe(ii,ij) = iproc - 1 |
---|
222 | ioea(ii,ij) = iproc + 1 |
---|
223 | iono(ii,ij) = iproc + jpni |
---|
224 | ildi(ii,ij) = 1 + jpreci |
---|
225 | ilei(ii,ij) = ili -jpreci |
---|
226 | ionw(ii,ij) = iono(ii,ij) - 1 |
---|
227 | ione(ii,ij) = iono(ii,ij) + 1 |
---|
228 | iosw(ii,ij) = ioso(ii,ij) - 1 |
---|
229 | iose(ii,ij) = ioso(ii,ij) + 1 |
---|
230 | ibsw(ii,ij) = 1 |
---|
231 | ibnw(ii,ij) = 1 |
---|
232 | IF( MOD(iproc,jpni) == 0 ) THEN |
---|
233 | ibsw(ii,ij) = 0 |
---|
234 | ibnw(ii,ij) = 0 |
---|
235 | ENDIF |
---|
236 | ibse(ii,ij) = 1 |
---|
237 | ibne(ii,ij) = 1 |
---|
238 | IF( MOD(iproc,jpni) == jpni-1 ) THEN |
---|
239 | ibse(ii,ij) = 0 |
---|
240 | ibne(ii,ij) = 0 |
---|
241 | ENDIF |
---|
242 | IF( iproc < jpni ) THEN |
---|
243 | ibsw(ii,ij) = 0 |
---|
244 | ibse(ii,ij) = 0 |
---|
245 | ENDIF |
---|
246 | IF( iproc >= (jpnj-1)*jpni ) THEN |
---|
247 | ibnw(ii,ij) = 0 |
---|
248 | ibne(ii,ij) = 0 |
---|
249 | ENDIF |
---|
250 | IF( ibondi(ii,ij) == -1 .OR. ibondi(ii,ij) == 2 ) ildi(ii,ij) = 1 |
---|
251 | IF( ibondi(ii,ij) == 1 .OR. ibondi(ii,ij) == 2 ) ilei(ii,ij) = ili |
---|
252 | ildj(ii,ij) = 1 + jprecj |
---|
253 | ilej(ii,ij) = ilj - jprecj |
---|
254 | IF( ibondj(ii,ij) == -1 .OR. ibondj(ii,ij) == 2 ) ildj(ii,ij) = 1 |
---|
255 | IF( ibondj(ii,ij) == 1 .OR. ibondj(ii,ij) == 2 ) ilej(ii,ij) = ilj |
---|
256 | |
---|
257 | ! warning ii*ij (zone) /= nproc (processors)! |
---|
258 | |
---|
259 | IF( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 ) THEN |
---|
260 | IF( jpni == 1 )THEN |
---|
261 | ibondi(ii,ij) = 2 |
---|
262 | nperio = 1 |
---|
263 | ELSE |
---|
264 | ibondi(ii,ij) = 0 |
---|
265 | ENDIF |
---|
266 | IF( MOD(jarea,jpni) == 0 ) THEN |
---|
267 | ioea(ii,ij) = iproc - (jpni-1) |
---|
268 | ione(ii,ij) = ione(ii,ij) - jpni |
---|
269 | iose(ii,ij) = iose(ii,ij) - jpni |
---|
270 | ENDIF |
---|
271 | IF( MOD(jarea,jpni) == 1 ) THEN |
---|
272 | iowe(ii,ij) = iproc + jpni - 1 |
---|
273 | ionw(ii,ij) = ionw(ii,ij) + jpni |
---|
274 | iosw(ii,ij) = iosw(ii,ij) + jpni |
---|
275 | ENDIF |
---|
276 | ibsw(ii,ij) = 1 |
---|
277 | ibnw(ii,ij) = 1 |
---|
278 | ibse(ii,ij) = 1 |
---|
279 | ibne(ii,ij) = 1 |
---|
280 | IF( iproc < jpni ) THEN |
---|
281 | ibsw(ii,ij) = 0 |
---|
282 | ibse(ii,ij) = 0 |
---|
283 | ENDIF |
---|
284 | IF( iproc >= (jpnj-1)*jpni ) THEN |
---|
285 | ibnw(ii,ij) = 0 |
---|
286 | ibne(ii,ij) = 0 |
---|
287 | ENDIF |
---|
288 | ENDIF |
---|
289 | ipolj(ii,ij) = 0 |
---|
290 | IF( jperio == 3 .OR. jperio == 4 ) THEN |
---|
291 | ijm1 = jpni*(jpnj-1) |
---|
292 | imil = ijm1+(jpni+1)/2 |
---|
293 | IF( jarea > ijm1 ) ipolj(ii,ij) = 3 |
---|
294 | IF( MOD(jpni,2) == 1 .AND. jarea == imil ) ipolj(ii,ij) = 4 |
---|
295 | IF( ipolj(ii,ij) == 3 ) iono(ii,ij) = jpni*jpnj-jarea+ijm1 ! MPI rank of northern neighbour |
---|
296 | ENDIF |
---|
297 | IF( jperio == 5 .OR. jperio == 6 ) THEN |
---|
298 | ijm1 = jpni*(jpnj-1) |
---|
299 | imil = ijm1+(jpni+1)/2 |
---|
300 | IF( jarea > ijm1) ipolj(ii,ij) = 5 |
---|
301 | IF( MOD(jpni,2) == 1 .AND. jarea == imil ) ipolj(ii,ij) = 6 |
---|
302 | IF( ipolj(ii,ij) == 5) iono(ii,ij) = jpni*jpnj-jarea+ijm1 ! MPI rank of northern neighbour |
---|
303 | ENDIF |
---|
304 | |
---|
305 | isurf = 0 |
---|
306 | DO jj = 1+jprecj, ilj-jprecj |
---|
307 | DO ji = 1+jpreci, ili-jpreci |
---|
308 | IF( imask(ji+iimppt(ii,ij)-1, jj+ijmppt(ii,ij)-1) == 1) isurf = isurf+1 |
---|
309 | END DO |
---|
310 | END DO |
---|
311 | IF(isurf /= 0) THEN |
---|
312 | icont = icont + 1 |
---|
313 | ipproc(ii,ij) = icont |
---|
314 | iin(icont+1) = ii |
---|
315 | ijn(icont+1) = ij |
---|
316 | ENDIF |
---|
317 | END DO |
---|
318 | |
---|
319 | nfipproc(:,:) = ipproc(:,:) |
---|
320 | |
---|
321 | |
---|
322 | ! Control |
---|
323 | IF(icont+1 /= jpnij) THEN |
---|
324 | WRITE(ctmp1,*) ' jpni =',jpni,' jpnj =',jpnj |
---|
325 | WRITE(ctmp2,*) ' jpnij =',jpnij, '< jpni x jpnj' |
---|
326 | WRITE(ctmp3,*) ' ***********, mpp_init2 finds jpnij=',icont+1 |
---|
327 | CALL ctl_stop( ' Eliminate land processors algorithm', '', ctmp1, ctmp2, '', ctmp3 ) |
---|
328 | ENDIF |
---|
329 | |
---|
330 | ! 4. Subdomain print |
---|
331 | ! ------------------ |
---|
332 | |
---|
333 | IF(lwp) THEN |
---|
334 | ifreq = 4 |
---|
335 | il1 = 1 |
---|
336 | DO jn = 1,(jpni-1)/ifreq+1 |
---|
337 | il2 = MIN(jpni,il1+ifreq-1) |
---|
338 | WRITE(numout,*) |
---|
339 | WRITE(numout,9400) ('***',ji=il1,il2-1) |
---|
340 | DO jj = jpnj, 1, -1 |
---|
341 | WRITE(numout,9403) (' ',ji=il1,il2-1) |
---|
342 | WRITE(numout,9402) jj, (ilci(ji,jj),ilcj(ji,jj),ji=il1,il2) |
---|
343 | WRITE(numout,9404) (ipproc(ji,jj),ji=il1,il2) |
---|
344 | WRITE(numout,9403) (' ',ji=il1,il2-1) |
---|
345 | WRITE(numout,9400) ('***',ji=il1,il2-1) |
---|
346 | END DO |
---|
347 | WRITE(numout,9401) (ji,ji=il1,il2) |
---|
348 | il1 = il1+ifreq |
---|
349 | END DO |
---|
350 | 9400 FORMAT(' ***',20('*************',a3)) |
---|
351 | 9403 FORMAT(' * ',20(' * ',a3)) |
---|
352 | 9401 FORMAT(' ',20(' ',i3,' ')) |
---|
353 | 9402 FORMAT(' ',i3,' * ',20(i3,' x',i3,' * ')) |
---|
354 | 9404 FORMAT(' * ',20(' ',i3,' * ')) |
---|
355 | ENDIF |
---|
356 | |
---|
357 | |
---|
358 | ! 5. neighbour treatment |
---|
359 | ! ---------------------- |
---|
360 | |
---|
361 | DO jarea = 1, jpni*jpnj |
---|
362 | iproc = jarea-1 |
---|
363 | ii = 1 + MOD(jarea-1,jpni) |
---|
364 | ij = 1 + (jarea-1)/jpni |
---|
365 | IF( ipproc(ii,ij) == -1 .AND. iono(ii,ij) >= 0 & |
---|
366 | .AND. iono(ii,ij) <= jpni*jpnj-1 ) THEN |
---|
367 | iino = 1 + MOD(iono(ii,ij),jpni) |
---|
368 | ijno = 1 + (iono(ii,ij))/jpni |
---|
369 | ! Need to reverse the logical direction of communication |
---|
370 | ! for northern neighbours of northern row processors (north-fold) |
---|
371 | ! i.e. need to check that the northern neighbour only communicates |
---|
372 | ! to the SOUTH (or not at all) if this area is land-only (#1057) |
---|
373 | idir = 1 |
---|
374 | IF( ij .eq. jpnj .AND. ijno .eq. jpnj ) idir = -1 |
---|
375 | IF( ibondj(iino,ijno) == idir ) ibondj(iino,ijno)=2 |
---|
376 | IF( ibondj(iino,ijno) == 0 ) ibondj(iino,ijno) = -idir |
---|
377 | ENDIF |
---|
378 | IF( ipproc(ii,ij) == -1 .AND. ioso(ii,ij) >= 0 & |
---|
379 | .AND. ioso(ii,ij) <= jpni*jpnj-1 ) THEN |
---|
380 | iiso = 1 + MOD(ioso(ii,ij),jpni) |
---|
381 | ijso = 1 + (ioso(ii,ij))/jpni |
---|
382 | IF( ibondj(iiso,ijso) == -1 ) ibondj(iiso,ijso) = 2 |
---|
383 | IF( ibondj(iiso,ijso) == 0 ) ibondj(iiso,ijso) = 1 |
---|
384 | ENDIF |
---|
385 | IF( ipproc(ii,ij) == -1 .AND. ioea(ii,ij) >= 0 & |
---|
386 | .AND. ioea(ii,ij) <= jpni*jpnj-1) THEN |
---|
387 | iiea = 1 + MOD(ioea(ii,ij),jpni) |
---|
388 | ijea = 1 + (ioea(ii,ij))/jpni |
---|
389 | IF( ibondi(iiea,ijea) == 1 ) ibondi(iiea,ijea) = 2 |
---|
390 | IF( ibondi(iiea,ijea) == 0 ) ibondi(iiea,ijea) = -1 |
---|
391 | ENDIF |
---|
392 | IF( ipproc(ii,ij) == -1 .AND. iowe(ii,ij) >= 0 & |
---|
393 | .AND. iowe(ii,ij) <= jpni*jpnj-1) THEN |
---|
394 | iiwe = 1 + MOD(iowe(ii,ij),jpni) |
---|
395 | ijwe = 1 + (iowe(ii,ij))/jpni |
---|
396 | IF( ibondi(iiwe,ijwe) == -1 ) ibondi(iiwe,ijwe) = 2 |
---|
397 | IF( ibondi(iiwe,ijwe) == 0 ) ibondi(iiwe,ijwe) = 1 |
---|
398 | ENDIF |
---|
399 | IF( ipproc(ii,ij) == -1 .AND. ibne(ii,ij) == 1 ) THEN |
---|
400 | iine = 1 + MOD(ione(ii,ij),jpni) |
---|
401 | ijne = 1 + (ione(ii,ij))/jpni |
---|
402 | IF( ibsw(iine,ijne) == 1 ) ibsw(iine,ijne) = 0 |
---|
403 | ENDIF |
---|
404 | IF( ipproc(ii,ij) == -1 .AND. ibsw(ii,ij) == 1 ) THEN |
---|
405 | iisw = 1 + MOD(iosw(ii,ij),jpni) |
---|
406 | ijsw = 1 + (iosw(ii,ij))/jpni |
---|
407 | IF( ibne(iisw,ijsw) == 1 ) ibne(iisw,ijsw) = 0 |
---|
408 | ENDIF |
---|
409 | IF( ipproc(ii,ij) == -1 .AND. ibnw(ii,ij) == 1 ) THEN |
---|
410 | iinw = 1 + MOD(ionw(ii,ij),jpni) |
---|
411 | ijnw = 1 + (ionw(ii,ij))/jpni |
---|
412 | IF( ibse(iinw,ijnw) == 1 ) ibse(iinw,ijnw)=0 |
---|
413 | ENDIF |
---|
414 | IF( ipproc(ii,ij) == -1 .AND. ibse(ii,ij) == 1 ) THEN |
---|
415 | iise = 1 + MOD(iose(ii,ij),jpni) |
---|
416 | ijse = 1 + (iose(ii,ij))/jpni |
---|
417 | IF( ibnw(iise,ijse) == 1 ) ibnw(iise,ijse) = 0 |
---|
418 | ENDIF |
---|
419 | END DO |
---|
420 | |
---|
421 | |
---|
422 | ! 6. Change processor name |
---|
423 | ! ------------------------ |
---|
424 | |
---|
425 | nproc = narea-1 |
---|
426 | ii = iin(narea) |
---|
427 | ij = ijn(narea) |
---|
428 | IF( ioso(ii,ij) >= 0 .AND. ioso(ii,ij) <= (jpni*jpnj-1) ) THEN |
---|
429 | iiso = 1 + MOD(ioso(ii,ij),jpni) |
---|
430 | ijso = 1 + (ioso(ii,ij))/jpni |
---|
431 | noso = ipproc(iiso,ijso) |
---|
432 | ENDIF |
---|
433 | IF( iowe(ii,ij) >= 0 .AND. iowe(ii,ij) <= (jpni*jpnj-1) ) THEN |
---|
434 | iiwe = 1 + MOD(iowe(ii,ij),jpni) |
---|
435 | ijwe = 1 + (iowe(ii,ij))/jpni |
---|
436 | nowe = ipproc(iiwe,ijwe) |
---|
437 | ENDIF |
---|
438 | IF( ioea(ii,ij) >= 0 .AND. ioea(ii,ij) <= (jpni*jpnj-1) ) THEN |
---|
439 | iiea = 1 + MOD(ioea(ii,ij),jpni) |
---|
440 | ijea = 1 + (ioea(ii,ij))/jpni |
---|
441 | noea = ipproc(iiea,ijea) |
---|
442 | ENDIF |
---|
443 | IF( iono(ii,ij) >= 0 .AND. iono(ii,ij) <= (jpni*jpnj-1) ) THEN |
---|
444 | iino = 1 + MOD(iono(ii,ij),jpni) |
---|
445 | ijno = 1 + (iono(ii,ij))/jpni |
---|
446 | nono = ipproc(iino,ijno) |
---|
447 | ENDIF |
---|
448 | IF( iose(ii,ij) >= 0 .AND. iose(ii,ij) <= (jpni*jpnj-1) ) THEN |
---|
449 | iise = 1 + MOD(iose(ii,ij),jpni) |
---|
450 | ijse = 1 + (iose(ii,ij))/jpni |
---|
451 | npse = ipproc(iise,ijse) |
---|
452 | ENDIF |
---|
453 | IF( iosw(ii,ij) >= 0 .AND. iosw(ii,ij) <= (jpni*jpnj-1) ) THEN |
---|
454 | iisw = 1 + MOD(iosw(ii,ij),jpni) |
---|
455 | ijsw = 1 + (iosw(ii,ij))/jpni |
---|
456 | npsw = ipproc(iisw,ijsw) |
---|
457 | ENDIF |
---|
458 | IF( ione(ii,ij) >= 0 .AND. ione(ii,ij) <= (jpni*jpnj-1) ) THEN |
---|
459 | iine = 1 + MOD(ione(ii,ij),jpni) |
---|
460 | ijne = 1 + (ione(ii,ij))/jpni |
---|
461 | npne = ipproc(iine,ijne) |
---|
462 | ENDIF |
---|
463 | IF( ionw(ii,ij) >= 0 .AND. ionw(ii,ij) <= (jpni*jpnj-1) ) THEN |
---|
464 | iinw = 1 + MOD(ionw(ii,ij),jpni) |
---|
465 | ijnw = 1 + (ionw(ii,ij))/jpni |
---|
466 | npnw = ipproc(iinw,ijnw) |
---|
467 | ENDIF |
---|
468 | nbnw = ibnw(ii,ij) |
---|
469 | nbne = ibne(ii,ij) |
---|
470 | nbsw = ibsw(ii,ij) |
---|
471 | nbse = ibse(ii,ij) |
---|
472 | nlcj = ilcj(ii,ij) |
---|
473 | nlci = ilci(ii,ij) |
---|
474 | nldi = ildi(ii,ij) |
---|
475 | nlei = ilei(ii,ij) |
---|
476 | nldj = ildj(ii,ij) |
---|
477 | nlej = ilej(ii,ij) |
---|
478 | nbondi = ibondi(ii,ij) |
---|
479 | nbondj = ibondj(ii,ij) |
---|
480 | nimpp = iimppt(ii,ij) |
---|
481 | njmpp = ijmppt(ii,ij) |
---|
482 | DO jproc = 1, jpnij |
---|
483 | ii = iin(jproc) |
---|
484 | ij = ijn(jproc) |
---|
485 | nimppt(jproc) = iimppt(ii,ij) |
---|
486 | njmppt(jproc) = ijmppt(ii,ij) |
---|
487 | nlcjt(jproc) = ilcj(ii,ij) |
---|
488 | nlcit(jproc) = ilci(ii,ij) |
---|
489 | nldit(jproc) = ildi(ii,ij) |
---|
490 | nleit(jproc) = ilei(ii,ij) |
---|
491 | nldjt(jproc) = ildj(ii,ij) |
---|
492 | nlejt(jproc) = ilej(ii,ij) |
---|
493 | END DO |
---|
494 | |
---|
495 | ! Save processor layout in ascii file |
---|
496 | IF (lwp) THEN |
---|
497 | CALL ctl_opn( inum, 'layout.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea ) |
---|
498 | WRITE(inum,'(6i8)') jpnij,jpi,jpj,jpk,jpiglo,jpjglo |
---|
499 | WRITE(inum,'(a)') 'NAREA nlci nlcj nldi nldj nlei nlej nimpp njmpp' |
---|
500 | |
---|
501 | DO jproc = 1, jpnij |
---|
502 | WRITE(inum,'(9i5)') jproc, nlcit(jproc), nlcjt(jproc), & |
---|
503 | nldit(jproc), nldjt(jproc), & |
---|
504 | nleit(jproc), nlejt(jproc), & |
---|
505 | nimppt(jproc), njmppt(jproc) |
---|
506 | END DO |
---|
507 | CLOSE(inum) |
---|
508 | END IF |
---|
509 | |
---|
510 | IF( nperio == 1 .AND.jpni /= 1 ) CALL ctl_stop( ' mpp_init2: error on cyclicity' ) |
---|
511 | |
---|
512 | ! Prepare mpp north fold |
---|
513 | |
---|
514 | IF( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN |
---|
515 | CALL mpp_ini_north |
---|
516 | IF(lwp) WRITE(numout,*) ' mpp_init2 : North fold boundary prepared for jpni >1' |
---|
517 | ENDIF |
---|
518 | |
---|
519 | ! Defined npolj, either 0, 3 , 4 , 5 , 6 |
---|
520 | ! In this case the important thing is that npolj /= 0 |
---|
521 | ! Because if we go through these line it is because jpni >1 and thus |
---|
522 | ! we must use lbcnorthmpp, which tests only npolj =0 or npolj /= 0 |
---|
523 | |
---|
524 | npolj = 0 |
---|
525 | ij = ijn(narea) |
---|
526 | |
---|
527 | IF( jperio == 3 .OR. jperio == 4 ) THEN |
---|
528 | IF( ij == jpnj ) npolj = 3 |
---|
529 | ENDIF |
---|
530 | |
---|
531 | IF( jperio == 5 .OR. jperio == 6 ) THEN |
---|
532 | IF( ij == jpnj ) npolj = 5 |
---|
533 | ENDIF |
---|
534 | |
---|
535 | ! Prepare NetCDF output file (if necessary) |
---|
536 | CALL mpp_init_ioipsl |
---|
537 | |
---|
538 | ! Periodicity : no corner if nbondi = 2 and nperio != 1 |
---|
539 | |
---|
540 | IF(lwp) THEN |
---|
541 | WRITE(numout,*) ' nproc= ',nproc |
---|
542 | WRITE(numout,*) ' nowe= ',nowe |
---|
543 | WRITE(numout,*) ' noea= ',noea |
---|
544 | WRITE(numout,*) ' nono= ',nono |
---|
545 | WRITE(numout,*) ' noso= ',noso |
---|
546 | WRITE(numout,*) ' nbondi= ',nbondi |
---|
547 | WRITE(numout,*) ' nbondj= ',nbondj |
---|
548 | WRITE(numout,*) ' npolj= ',npolj |
---|
549 | WRITE(numout,*) ' nperio= ',nperio |
---|
550 | WRITE(numout,*) ' nlci= ',nlci |
---|
551 | WRITE(numout,*) ' nlcj= ',nlcj |
---|
552 | WRITE(numout,*) ' nimpp= ',nimpp |
---|
553 | WRITE(numout,*) ' njmpp= ',njmpp |
---|
554 | WRITE(numout,*) ' nbse= ',nbse,' npse= ',npse |
---|
555 | WRITE(numout,*) ' nbsw= ',nbsw,' npsw= ',npsw |
---|
556 | WRITE(numout,*) ' nbne= ',nbne,' npne= ',npne |
---|
557 | WRITE(numout,*) ' nbnw= ',nbnw,' npnw= ',npnw |
---|
558 | ENDIF |
---|
559 | |
---|
560 | END SUBROUTINE mpp_init2 |
---|