Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
lloce(2,iny) = lloce(2,iny-2) ! here we have 1 halo (even if nn_hls>1)
DO ji = 3,inx-1
lloce(ji,iny ) = lloce(inx-ji+2,iny-2) ! ok, we have at least 3 lines
END DO
DO ji = inx/2+2,inx-1
lloce(ji,iny-1) = lloce(inx-ji+2,iny-1)
END DO
ELSEIF( c_NFtype == 'F' ) THEN ! north-pole folding F-pivot, T-point, 1 halo
lloce(inx/2+1,iny-1) = lloce(inx/2,iny-1) ! here we have 1 halo (even if nn_hls>1)
lloce(inx -1,iny-1) = lloce(2 ,iny-1)
DO ji = 2,inx-1
lloce(ji,iny) = lloce(inx-ji+1,iny-1)
END DO
ELSE ! closed boundary
lloce(2:inx-1,iny) = .FALSE.
ENDIF
ENDIF
! ! first and last column were not read
IF( l_Iperio ) THEN
lloce(1,:) = lloce(inx-1,:) ; lloce(inx,:) = lloce(2,:) ! east-west periodocity
ELSE
lloce(1,:) = .FALSE. ; lloce(inx,:) = .FALSE. ! closed boundary
ENDIF
!
DO ji = 1, inbi
inboce(ji,iarea) = COUNT( lloce(iimppt(ji,1):iimppt(ji,1)+ijpi(ji,1)+1,:) ) ! lloce as 2 points more than Ni0glo
END DO
!
DEALLOCATE(lloce)
DEALLOCATE(iimppt, ijmppt, ijpi, ijpj)
!
ENDIF
END DO
inboce_1d = RESHAPE(inboce, (/ inbi*inbj /))
CALL mpp_sum( 'mppini', inboce_1d )
inboce = RESHAPE(inboce_1d, (/inbi, inbj/))
ldIsOce(:,:) = inboce(:,:) /= 0
DEALLOCATE(inboce, inboce_1d)
!
END SUBROUTINE mpp_is_ocean
SUBROUTINE read_mask( kistr, kjstr, kicnt, kjcnt, ldoce )
!!----------------------------------------------------------------------
!! *** ROUTINE read_mask ***
!!
!! ** Purpose : Read relevant bathymetric information in order to
!! provide a land/sea mask used for the elimination
!! of land domains, in an mpp computation.
!!
!! ** Method : read stipe of size (Ni0glo,...)
!!----------------------------------------------------------------------
INTEGER , INTENT(in ) :: kistr, kjstr ! starting i and j position of the reading
INTEGER , INTENT(in ) :: kicnt, kjcnt ! number of points to read in i and j directions
LOGICAL, DIMENSION(kicnt,kjcnt), INTENT( out) :: ldoce ! ldoce(i,j) = .true. if the point (i,j) is ocean
!
INTEGER :: inumsave ! local logical unit
REAL(wp), DIMENSION(kicnt,kjcnt) :: zbot, zbdy
!!----------------------------------------------------------------------
!
inumsave = numout ; numout = numnul ! redirect all print to /dev/null
!
IF( numbot /= -1 ) THEN
CALL iom_get( numbot, jpdom_unknown, 'bottom_level', zbot, kstart = (/kistr,kjstr/), kcount = (/kicnt, kjcnt/) )
ELSE
zbot(:,:) = 1._wp ! put a non-null value
ENDIF
!
IF( numbdy /= -1 ) THEN ! Adjust with bdy_msk if it exists
CALL iom_get ( numbdy, jpdom_unknown, 'bdy_msk', zbdy, kstart = (/kistr,kjstr/), kcount = (/kicnt, kjcnt/) )
zbot(:,:) = zbot(:,:) * zbdy(:,:)
ENDIF
!
ldoce(:,:) = NINT(zbot(:,:)) > 0
numout = inumsave
!
END SUBROUTINE read_mask
SUBROUTINE mpp_getnum( ldIsOce, kproc, kipos, kjpos )
!!----------------------------------------------------------------------
!! *** ROUTINE mpp_getnum ***
!!
!! ** Purpose : give a number to each MPI subdomains (starting at 0)
!!
!! ** Method : start from bottom left. First skip land subdomain, and finally use them if needed
!!----------------------------------------------------------------------
LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldIsOce ! F if land process
INTEGER, DIMENSION(:,:), INTENT( out) :: kproc ! subdomain number (-1 if not existing, starting at 0)
INTEGER, DIMENSION( :), INTENT( out) :: kipos ! i-position of the subdomain (from 1 to jpni)
INTEGER, DIMENSION( :), INTENT( out) :: kjpos ! j-position of the subdomain (from 1 to jpnj)
!
INTEGER :: ii, ij, jarea, iarea0
INTEGER :: icont, i2add , ini, inj, inij
!!----------------------------------------------------------------------
!
ini = SIZE(ldIsOce, dim = 1)
inj = SIZE(ldIsOce, dim = 2)
inij = SIZE(kipos)
!
! specify which subdomains are oce subdomains; other are land subdomains
kproc(:,:) = -1
icont = -1
DO jarea = 1, ini*inj
iarea0 = jarea - 1
ii = 1 + MOD(iarea0,ini)
ij = 1 + iarea0/ini
IF( ldIsOce(ii,ij) ) THEN
icont = icont + 1
kproc(ii,ij) = icont
kipos(icont+1) = ii
kjpos(icont+1) = ij
ENDIF
END DO
! if needed add some land subdomains to reach inij active subdomains
i2add = inij - COUNT( ldIsOce )
DO jarea = 1, ini*inj
iarea0 = jarea - 1
ii = 1 + MOD(iarea0,ini)
ij = 1 + iarea0/ini
IF( .NOT. ldIsOce(ii,ij) .AND. i2add > 0 ) THEN
icont = icont + 1
kproc(ii,ij) = icont
kipos(icont+1) = ii
kjpos(icont+1) = ij
i2add = i2add - 1
ENDIF
END DO
!
END SUBROUTINE mpp_getnum
SUBROUTINE init_excl_landpt
!!----------------------------------------------------------------------
!! *** ROUTINE ***
!!
!! ** Purpose : exclude exchanges which contain only land points
!!
!! ** Method : if a send or receive buffer constains only land point we
!! flag off the corresponding communication
!! Warning: this selection depend on the halo size -> loop on halo size
!!
!!----------------------------------------------------------------------
INTEGER :: inumsave
INTEGER :: jh
INTEGER :: ipi, ipj
INTEGER :: iiwe, iiea, iist, iisz
INTEGER :: ijso, ijno, ijst, ijsz
REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zmsk
LOGICAL , DIMENSION(Ni_0,Nj_0,1) :: lloce
!!----------------------------------------------------------------------
!
! read the land-sea mask on the inner domain
CALL read_mask( nimpp, njmpp, Ni_0, Nj_0, lloce(:,:,1) )
!
! Here we look only at communications excluding the NP folding.
! --> we switch off lbcnfd at this stage (init_nfdcom called after init_excl_landpt)...
l_IdoNFold = .FALSE.
!
! WARNING, see also bestpartition: minimum subdomain size defined in bestpartition according to nn_hls.
! If, one day, we want to use local halos largers than nn_hls, we must replace nn_hls by n_hlsmax in bestpartition
!
DO jh = 1, MIN(nn_hls, n_hlsmax) ! different halo size
!
ipi = Ni_0 + 2*jh ! local domain size
ipj = Nj_0 + 2*jh
!
ALLOCATE( zmsk(ipi,ipj) )
zmsk(jh+1:jh+Ni_0,jh+1:jh+Nj_0) = REAL(COUNT(lloce, dim = 3), wp) ! define inner domain -> need REAL to use lbclnk
CALL lbc_lnk('mppini', zmsk, 'T', 1._wp, khls = jh) ! fill halos
! Beware, coastal F points can be used in the code -> we may need communications for these points F points even if tmask = 0
! -> the mask we must use here is equal to 1 as soon as one of the 4 neighbours is oce (sum of the mask, not multiplication)
zmsk(jh+1:jh+Ni_0,jh+1:jh+Nj_0) = zmsk(jh+1:jh+Ni_0,jh+1 :jh+Nj_0 ) + zmsk(jh+1+1:jh+Ni_0+1,jh+1 :jh+Nj_0 ) &
& + zmsk(jh+1:jh+Ni_0,jh+1+1:jh+Nj_0+1) + zmsk(jh+1+1:jh+Ni_0+1,jh+1+1:jh+Nj_0+1)
CALL lbc_lnk('mppini', zmsk, 'T', 1._wp, khls = jh) ! fill halos again!
!
iiwe = jh ; iiea = Ni_0 ! bottom-left corner - 1 of the sent data
ijso = jh ; ijno = Nj_0
IF( nn_comm == 1 ) THEN
iist = 0 ; iisz = ipi
ijst = jh ; ijsz = Nj_0
ELSE
iist = jh ; iisz = Ni_0
ijst = jh ; ijsz = Nj_0
ENDIF
IF( nn_comm == 1 ) THEN ! SM: NOT WORKING FOR NEIGHBOURHOOD COLLECTIVE COMMUNICATIONS, I DON'T KNOW WHY...
! do not send if we send only land points
IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh ,ijst+1:ijst+ijsz) )) == 0 ) mpiSnei(jh,jpwe) = -1
IF( NINT(SUM( zmsk(iiea+1:iiea+jh ,ijst+1:ijst+ijsz) )) == 0 ) mpiSnei(jh,jpea) = -1
IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijso+1:ijso+jh ) )) == 0 ) mpiSnei(jh,jpso) = -1
IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijno+1:ijno+jh ) )) == 0 ) mpiSnei(jh,jpno) = -1
IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh ,ijso+1:ijso+jh ) )) == 0 ) mpiSnei(jh,jpsw) = -1
IF( NINT(SUM( zmsk(iiea+1:iiea+jh ,ijso+1:ijso+jh ) )) == 0 ) mpiSnei(jh,jpse) = -1
IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh ,ijno+1:ijno+jh ) )) == 0 ) mpiSnei(jh,jpnw) = -1
IF( NINT(SUM( zmsk(iiea+1:iiea+jh ,ijno+1:ijno+jh ) )) == 0 ) mpiSnei(jh,jpne) = -1
!
iiwe = iiwe-jh ; iiea = iiea+jh ! bottom-left corner - 1 of the received data
ijso = ijso-jh ; ijno = ijno+jh
! do not send if we send only land points
IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh ,ijst+1:ijst+ijsz) )) == 0 ) mpiRnei(jh,jpwe) = -1
IF( NINT(SUM( zmsk(iiea+1:iiea+jh ,ijst+1:ijst+ijsz) )) == 0 ) mpiRnei(jh,jpea) = -1
IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijso+1:ijso+jh ) )) == 0 ) mpiRnei(jh,jpso) = -1
IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijno+1:ijno+jh ) )) == 0 ) mpiRnei(jh,jpno) = -1
IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh ,ijso+1:ijso+jh ) )) == 0 ) mpiRnei(jh,jpsw) = -1
IF( NINT(SUM( zmsk(iiea+1:iiea+jh ,ijso+1:ijso+jh ) )) == 0 ) mpiRnei(jh,jpse) = -1
IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh ,ijno+1:ijno+jh ) )) == 0 ) mpiRnei(jh,jpnw) = -1
IF( NINT(SUM( zmsk(iiea+1:iiea+jh ,ijno+1:ijno+jh ) )) == 0 ) mpiRnei(jh,jpne) = -1
ENDIF
!
! Specific (and rare) problem in corner treatment because we do 1st West-East comm, next South-North comm
IF( nn_comm == 1 ) THEN
IF( mpiSnei(jh,jpwe) > -1 ) mpiSnei(jh, (/jpsw,jpnw/) ) = -1 ! SW and NW corners already sent through West nei
IF( mpiSnei(jh,jpea) > -1 ) mpiSnei(jh, (/jpse,jpne/) ) = -1 ! SE and NE corners already sent through East nei
IF( mpiRnei(jh,jpso) > -1 ) mpiRnei(jh, (/jpsw,jpse/) ) = -1 ! SW and SE corners will be received through South nei
IF( mpiRnei(jh,jpno) > -1 ) mpiRnei(jh, (/jpnw,jpne/) ) = -1 ! NW and NE corners will be received through North nei
ENDIF
!
DEALLOCATE( zmsk )
!
CALL mpp_ini_nc(jh) ! Initialize/Update communicator for neighbourhood collective communications
!
END DO
END SUBROUTINE init_excl_landpt
SUBROUTINE init_ioipsl
!!----------------------------------------------------------------------
!! *** ROUTINE init_ioipsl ***
!!
!! ** Purpose :
!!
!! ** Method :
!!
!! History :
!! 9.0 ! 04-03 (G. Madec ) MPP-IOIPSL
!! " " ! 08-12 (A. Coward) addition in case of jpni*jpnj < jpnij
!!----------------------------------------------------------------------
INTEGER, DIMENSION(2) :: iglo, iloc, iabsf, iabsl, ihals, ihale, idid
!!----------------------------------------------------------------------
! The domain is split only horizontally along i- or/and j- direction
! So we need at the most only 1D arrays with 2 elements.
! Set idompar values equivalent to the jpdom_local_noextra definition
! used in IOM. This works even if jpnij .ne. jpni*jpnj.
iglo( :) = (/ Ni0glo, Nj0glo /)
iloc( :) = (/ Ni_0 , Nj_0 /)
iabsf(:) = (/ Nis0 , Njs0 /) + (/ nimpp, njmpp /) - 1 - nn_hls ! corresponds to mig0(Nis0) but mig0 is not yet defined!
iabsl(:) = iabsf(:) + iloc(:) - 1
ihals(:) = (/ 0 , 0 /)
ihale(:) = (/ 0 , 0 /)
idid( :) = (/ 1 , 2 /)
IF(lwp) THEN
WRITE(numout,*)
WRITE(numout,*) 'mpp init_ioipsl : iloc = ', iloc
WRITE(numout,*) '~~~~~~~~~~~~~~~ iabsf = ', iabsf
WRITE(numout,*) ' ihals = ', ihals
WRITE(numout,*) ' ihale = ', ihale
ENDIF
!
CALL flio_dom_set ( jpnij, narea-1, idid, iglo, iloc, iabsf, iabsl, ihals, ihale, 'BOX', nidom)
!
END SUBROUTINE init_ioipsl
SUBROUTINE init_nfdcom( ldwrtlay, knum )
!!----------------------------------------------------------------------
!! *** ROUTINE init_nfdcom ***
!! ** Purpose : Setup for north fold exchanges with explicit
!! point-to-point messaging
!!
!! ** Method : Initialization of the northern neighbours lists.
!!----------------------------------------------------------------------
!! 1.0 ! 2011-10 (A. C. Coward, NOCS & J. Donners, PRACE)
!! 2.0 ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S. Mocavero, CMCC)
!! 3.0 ! 2021-09 complete rewrite using informations from gather north fold
!!----------------------------------------------------------------------
LOGICAL, INTENT(in ) :: ldwrtlay ! true if additional prints in layout.dat
INTEGER, INTENT(in ) :: knum ! layout.dat unit
!
REAL(wp), DIMENSION(jpi,jpj,2,4) :: zinfo
INTEGER , DIMENSION(10) :: irknei ! too many elements but safe...
INTEGER :: ji, jj, jg, jn ! dummy loop indices
LOGICAL :: lnew
!!----------------------------------------------------------------------
!
IF (lwp) THEN
WRITE(numout,*)
WRITE(numout,*) ' ==>>> North fold boundary prepared for jpni >1'
ENDIF
!
CALL mpp_ini_northgather ! we need to init the nfd with gathering in all cases as it is used to define the no-gather case
!
IF(ldwrtlay) THEN ! additional prints in layout.dat
WRITE(knum,*)
WRITE(knum,*)
WRITE(knum,*) 'Number of subdomains located along the north fold : ', ndim_rank_north
WRITE(knum,*) 'Rank of the subdomains located along the north fold : ', ndim_rank_north
DO jn = 1, ndim_rank_north, 5
WRITE(knum,*) nrank_north( jn:MINVAL( (/jn+4,ndim_rank_north/) ) )
END DO
ENDIF
nfd_nbnei = 0 ! defaul def (useless?)
IF( ln_nnogather ) THEN
!
! Use the "gather nfd" to know how to do the nfd: for ji point, which process send data from which of its ji-index?
! Note that nfd is perfectly symetric: I receive data from X <=> I send data to X (-> no deadlock)
!
zinfo(:,:,:,:) = HUGE(0._wp) ! default def to make sure we don't use the halos
DO jg = 1, 4 ! grid type: T, U, V, F
DO jj = nn_hls+1, jpj-nn_hls ! inner domain (warning do_loop_substitute not yet defined)
DO ji = nn_hls+1, jpi-nn_hls ! inner domain (warning do_loop_substitute not yet defined)
zinfo(ji,jj,1,jg) = REAL(narea, wp) ! mpi_rank + 1 (as default lbc_lnk fill is 0
zinfo(ji,jj,2,jg) = REAL(ji, wp) ! ji of this proc
END DO
END DO
END DO
!
ln_nnogather = .FALSE. ! force "classical" North pole folding to fill all halos -> should be no more HUGE values...
CALL lbc_lnk( 'mppini', zinfo(:,:,:,1), 'T', 1._wp ) ! Do 4 calls instead of 1 to save memory as the nogather version
CALL lbc_lnk( 'mppini', zinfo(:,:,:,2), 'U', 1._wp ) ! creates buffer arrays with jpiglo as the first dimension
CALL lbc_lnk( 'mppini', zinfo(:,:,:,3), 'V', 1._wp ) !
CALL lbc_lnk( 'mppini', zinfo(:,:,:,4), 'F', 1._wp ) !
ln_nnogather = .TRUE.
IF( l_IdoNFold ) THEN ! only the procs involed in the NFD must take care of this
ALLOCATE( nfd_rksnd(jpi,4), nfd_jisnd(jpi,4) ) ! neighbour rand and remote ji-index for each grid (T, U, V, F)
nfd_rksnd(:,:) = NINT( zinfo(:, jpj, 1, :) ) - 1 ! neighbour MPI rank
nfd_jisnd(:,:) = NINT( zinfo(:, jpj, 2, :) ) - nn_hls ! neighbour ji index (shifted as we don't send the halos)
WHERE( nfd_rksnd == -1 ) nfd_jisnd = 1 ! use ji=1 if no neighbour, see mpp_nfd_generic.h90
nfd_nbnei = 1 ! Number of neighbour sending data for the nfd. We have at least 1 neighbour!
irknei(1) = nfd_rksnd(1,1) ! which is the 1st one (I can be neighbour of myself, exclude land-proc are also ok)
DO jg = 1, 4
DO ji = 1, jpi ! we must be able to fill the full line including halos
lnew = .TRUE. ! new neighbour?
DO jn = 1, nfd_nbnei
IF( irknei(jn) == nfd_rksnd(ji,jg) ) lnew = .FALSE. ! already found
END DO
IF( lnew ) THEN
jn = nfd_nbnei + 1
nfd_nbnei = jn
irknei(jn) = nfd_rksnd(ji,jg)
ENDIF
END DO
END DO
ALLOCATE( nfd_rknei(nfd_nbnei) )
nfd_rknei(:) = irknei(1:nfd_nbnei)
! re-number nfd_rksnd according to the indexes of nfd_rknei
DO jn = 1, nfd_nbnei
WHERE( nfd_rksnd == nfd_rknei(jn) ) nfd_rksnd = jn
END DO
IF( ldwrtlay ) THEN
WRITE(knum,*)
WRITE(knum,*) 'north fold exchanges with explicit point-to-point messaging :'
WRITE(knum,*) ' number of neighbours for the NF: nfd_nbnei : ', nfd_nbnei
IF( nfd_nbnei > 0 ) WRITE(knum,*) ' neighbours MPI ranks : ', nfd_rknei
ENDIF
ENDIF ! l_IdoNFold
!
ENDIF ! ln_nnogather
!
END SUBROUTINE init_nfdcom
SUBROUTINE init_doloop
!!----------------------------------------------------------------------
!! *** ROUTINE init_doloop ***
!!
!! ** Purpose : set the starting/ending indices of DO-loop
!! These indices are used in do_loop_substitute.h90
!!----------------------------------------------------------------------
!
Nis0 = 1+nn_hls
Njs0 = 1+nn_hls
Nie0 = jpi-nn_hls
Nje0 = jpj-nn_hls
!
Ni_0 = Nie0 - Nis0 + 1
Nj_0 = Nje0 - Njs0 + 1
!
jpkm1 = jpk-1 ! " "
!
END SUBROUTINE init_doloop
SUBROUTINE init_locglo
!!----------------------------------------------------------------------
!! *** ROUTINE init_locglo ***
!!
!! ** Purpose : initialization of global domain <--> local domain indices
!!
!! ** Method :
!!
!! ** Action : - mig , mjg : local domain indices ==> global domain, including halos, indices
!! - mig0, mjg0: local domain indices ==> global domain, excluding halos, indices
!! - mi0 , mi1 : global domain indices ==> local domain indices
!! - mj0 , mj1 (if global point not in the local domain ==> mi0>mi1 and/or mj0>mj1)
!!----------------------------------------------------------------------
INTEGER :: ji, jj ! dummy loop argument
!!----------------------------------------------------------------------
!
ALLOCATE( mig(jpi), mjg(jpj), mig0(jpi), mjg0(jpj) )
ALLOCATE( mi0(jpiglo), mi1(jpiglo), mj0(jpjglo), mj1(jpjglo) )
!
DO ji = 1, jpi ! local domain indices ==> global domain indices, including halos
mig(ji) = ji + nimpp - 1
END DO
DO jj = 1, jpj
mjg(jj) = jj + njmpp - 1
END DO
! ! local domain indices ==> global domain indices, excluding halos
!
mig0(:) = mig(:) - nn_hls
mjg0(:) = mjg(:) - nn_hls
! ! global domain, including halos, indices ==> local domain indices
! ! (return (m.0,m.1)=(1,0) if data domain gridpoint is to the west/south of the
! ! local domain, or (m.0,m.1)=(jp.+1,jp.) to the east/north of local domain.
DO ji = 1, jpiglo
mi0(ji) = MAX( 1 , MIN( ji - nimpp + 1, jpi+1 ) )
mi1(ji) = MAX( 0 , MIN( ji - nimpp + 1, jpi ) )
END DO
DO jj = 1, jpjglo
mj0(jj) = MAX( 1 , MIN( jj - njmpp + 1, jpj+1 ) )
mj1(jj) = MAX( 0 , MIN( jj - njmpp + 1, jpj ) )
END DO
!
END SUBROUTINE init_locglo
!!======================================================================
END MODULE mppini