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