1 | #if defined MULTI |
---|
2 | # define NAT_IN(k) cd_nat(k) |
---|
3 | # define SGN_IN(k) psgn(k) |
---|
4 | # define F_SIZE(ptab) kfld |
---|
5 | # define OPT_K(k) ,ipf |
---|
6 | # if defined DIM_2d |
---|
7 | # define ARRAY_TYPE(i,j,k,l,f) TYPE(PTR_2D) , INTENT(inout) :: ptab(f) |
---|
8 | # define ARRAY_IN(i,j,k,l,f) ptab(f)%pt2d(i,j) |
---|
9 | # define K_SIZE(ptab) 1 |
---|
10 | # define L_SIZE(ptab) 1 |
---|
11 | # endif |
---|
12 | # if defined DIM_3d |
---|
13 | # define ARRAY_TYPE(i,j,k,l,f) TYPE(PTR_3D) , INTENT(inout) :: ptab(f) |
---|
14 | # define ARRAY_IN(i,j,k,l,f) ptab(f)%pt3d(i,j,k) |
---|
15 | # define K_SIZE(ptab) SIZE(ptab(1)%pt3d,3) |
---|
16 | # define L_SIZE(ptab) 1 |
---|
17 | # endif |
---|
18 | # if defined DIM_4d |
---|
19 | # define ARRAY_TYPE(i,j,k,l,f) TYPE(PTR_4D) , INTENT(inout) :: ptab(f) |
---|
20 | # define ARRAY_IN(i,j,k,l,f) ptab(f)%pt4d(i,j,k,l) |
---|
21 | # define K_SIZE(ptab) SIZE(ptab(1)%pt4d,3) |
---|
22 | # define L_SIZE(ptab) SIZE(ptab(1)%pt4d,4) |
---|
23 | # endif |
---|
24 | #else |
---|
25 | # define ARRAY_TYPE(i,j,k,l,f) REAL(wp) , INTENT(inout) :: ARRAY_IN(i,j,k,l,f) |
---|
26 | # define NAT_IN(k) cd_nat |
---|
27 | # define SGN_IN(k) psgn |
---|
28 | # define F_SIZE(ptab) 1 |
---|
29 | # define OPT_K(k) |
---|
30 | # if defined DIM_2d |
---|
31 | # define ARRAY_IN(i,j,k,l,f) ptab(i,j) |
---|
32 | # define K_SIZE(ptab) 1 |
---|
33 | # define L_SIZE(ptab) 1 |
---|
34 | # endif |
---|
35 | # if defined DIM_3d |
---|
36 | # define ARRAY_IN(i,j,k,l,f) ptab(i,j,k) |
---|
37 | # define K_SIZE(ptab) SIZE(ptab,3) |
---|
38 | # define L_SIZE(ptab) 1 |
---|
39 | # endif |
---|
40 | # if defined DIM_4d |
---|
41 | # define ARRAY_IN(i,j,k,l,f) ptab(i,j,k,l) |
---|
42 | # define K_SIZE(ptab) SIZE(ptab,3) |
---|
43 | # define L_SIZE(ptab) SIZE(ptab,4) |
---|
44 | # endif |
---|
45 | #endif |
---|
46 | |
---|
47 | #if defined MULTI |
---|
48 | SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv ) |
---|
49 | INTEGER , INTENT(in ) :: kfld ! number of pt3d arrays |
---|
50 | #else |
---|
51 | SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn , kfillmode, pfillval, lsend, lrecv ) |
---|
52 | #endif |
---|
53 | ARRAY_TYPE(:,:,:,:,:) ! array or pointer of arrays on which the boundary condition is applied |
---|
54 | CHARACTER(len=*) , INTENT(in ) :: cdname ! name of the calling subroutine |
---|
55 | CHARACTER(len=1) , INTENT(in ) :: NAT_IN(:) ! nature of array grid-points |
---|
56 | REAL(wp) , INTENT(in ) :: SGN_IN(:) ! sign used across the north fold boundary |
---|
57 | INTEGER , OPTIONAL, INTENT(in ) :: kfillmode ! filling method for halo over land (default = constant) |
---|
58 | REAL(wp), OPTIONAL, INTENT(in ) :: pfillval ! background value (used at closed boundaries) |
---|
59 | LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in ) :: lsend, lrecv ! communication with other 4 proc |
---|
60 | ! |
---|
61 | INTEGER :: ji, jj, jk, jl, jf ! dummy loop indices |
---|
62 | INTEGER :: ipi, ipj, ipk, ipl, ipf ! dimension of the input array |
---|
63 | INTEGER :: isize, ishift, ishift2 ! local integers |
---|
64 | INTEGER :: ireq_we, ireq_ea, ireq_so, ireq_no ! mpi_request id |
---|
65 | INTEGER :: ierr |
---|
66 | INTEGER :: ifill_we, ifill_ea, ifill_so, ifill_no |
---|
67 | REAL(wp) :: zland |
---|
68 | INTEGER , DIMENSION(MPI_STATUS_SIZE) :: istat ! for mpi_isend |
---|
69 | REAL(wp), DIMENSION(:,:,:,:,:), ALLOCATABLE :: zsnd_we, zrcv_we, zsnd_ea, zrcv_ea ! east -west & west - east halos |
---|
70 | REAL(wp), DIMENSION(:,:,:,:,:), ALLOCATABLE :: zsnd_so, zrcv_so, zsnd_no, zrcv_no ! north-south & south-north halos |
---|
71 | LOGICAL :: llsend_we, llsend_ea, llsend_no, llsend_so ! communication send |
---|
72 | LOGICAL :: llrecv_we, llrecv_ea, llrecv_no, llrecv_so ! communication receive |
---|
73 | LOGICAL :: lldo_nfd ! do north pole folding |
---|
74 | !!---------------------------------------------------------------------- |
---|
75 | ! |
---|
76 | ! ----------------------------------------- ! |
---|
77 | ! 0. local variables initialization ! |
---|
78 | ! ----------------------------------------- ! |
---|
79 | ! |
---|
80 | ipk = K_SIZE(ptab) ! 3rd dimension |
---|
81 | ipl = L_SIZE(ptab) ! 4th - |
---|
82 | ipf = F_SIZE(ptab) ! 5th - use in "multi" case (array of pointers) |
---|
83 | ! |
---|
84 | IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. ) |
---|
85 | ! |
---|
86 | IF ( PRESENT(lsend) .AND. PRESENT(lrecv) ) THEN |
---|
87 | llsend_we = lsend(1) ; llsend_ea = lsend(2) ; llsend_so = lsend(3) ; llsend_no = lsend(4) |
---|
88 | llrecv_we = lrecv(1) ; llrecv_ea = lrecv(2) ; llrecv_so = lrecv(3) ; llrecv_no = lrecv(4) |
---|
89 | ELSE IF( PRESENT(lsend) .OR. PRESENT(lrecv) ) THEN |
---|
90 | WRITE(ctmp1,*) ' E R R O R : Routine ', cdname, ' is calling lbc_lnk with only one of the two arguments lsend or lrecv' |
---|
91 | WRITE(ctmp2,*) ' ========== ' |
---|
92 | CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' ) |
---|
93 | ELSE ! send and receive with every neighbour |
---|
94 | llsend_we = nbondi == 1 .OR. nbondi == 0 ! keep for compatibility, should be defined in mppini |
---|
95 | llsend_ea = nbondi == -1 .OR. nbondi == 0 ! keep for compatibility, should be defined in mppini |
---|
96 | llsend_so = nbondj == 1 .OR. nbondj == 0 ! keep for compatibility, should be defined in mppini |
---|
97 | llsend_no = nbondj == -1 .OR. nbondj == 0 ! keep for compatibility, should be defined in mppini |
---|
98 | llrecv_we = llsend_we ; llrecv_ea = llsend_ea ; llrecv_so = llsend_so ; llrecv_no = llsend_no |
---|
99 | END IF |
---|
100 | |
---|
101 | |
---|
102 | lldo_nfd = npolj /= 0 ! keep for compatibility, should be defined in mppini |
---|
103 | |
---|
104 | zland = 0._wp ! land filling value: zero by default |
---|
105 | IF( PRESENT( pfillval ) ) zland = pfillval ! set land value |
---|
106 | |
---|
107 | ! define the method we will use to fill the halos in each direction |
---|
108 | IF( llrecv_we ) THEN ; ifill_we = jpfillmpi |
---|
109 | ELSEIF( l_Iperio ) THEN ; ifill_we = jpfillperio |
---|
110 | ELSEIF( PRESENT(kfillmode) ) THEN ; ifill_we = kfillmode |
---|
111 | ELSE ; ifill_we = jpfillcst |
---|
112 | END IF |
---|
113 | ! |
---|
114 | IF( llrecv_ea ) THEN ; ifill_ea = jpfillmpi |
---|
115 | ELSEIF( l_Iperio ) THEN ; ifill_ea = jpfillperio |
---|
116 | ELSEIF( PRESENT(kfillmode) ) THEN ; ifill_ea = kfillmode |
---|
117 | ELSE ; ifill_ea = jpfillcst |
---|
118 | END IF |
---|
119 | ! |
---|
120 | IF( llrecv_so ) THEN ; ifill_so = jpfillmpi |
---|
121 | ELSEIF( l_Jperio ) THEN ; ifill_so = jpfillperio |
---|
122 | ELSEIF( PRESENT(kfillmode) ) THEN ; ifill_so = kfillmode |
---|
123 | ELSE ; ifill_so = jpfillcst |
---|
124 | END IF |
---|
125 | ! |
---|
126 | IF( llrecv_no ) THEN ; ifill_no = jpfillmpi |
---|
127 | ELSEIF( l_Jperio ) THEN ; ifill_no = jpfillperio |
---|
128 | ELSEIF( PRESENT(kfillmode) ) THEN ; ifill_no = kfillmode |
---|
129 | ELSE ; ifill_no = jpfillcst |
---|
130 | END IF |
---|
131 | ! |
---|
132 | #if defined PRINT_CAUTION |
---|
133 | ! |
---|
134 | ! ================================================================================== ! |
---|
135 | ! CAUTION: semi-column notation is often impossible because of the cpp preprocessing ! |
---|
136 | ! ================================================================================== ! |
---|
137 | ! |
---|
138 | #endif |
---|
139 | ! |
---|
140 | ! -------------------------------------------------- ! |
---|
141 | ! 1. Do east and west MPI exchange if needed ! |
---|
142 | ! -------------------------------------------------- ! |
---|
143 | ! |
---|
144 | ! Must exchange the whole column (from 1 to jpj) to get the corners if we have no south/north neighbourg |
---|
145 | isize = nn_hls * jpj * ipk * ipl * ipf |
---|
146 | ! |
---|
147 | ! Allocate local temporary arrays to be sent/received. Fill arrays to be sent |
---|
148 | IF( llsend_we ) ALLOCATE( zsnd_we(nn_hls,jpj,ipk,ipl,ipf) ) |
---|
149 | IF( llsend_ea ) ALLOCATE( zsnd_ea(nn_hls,jpj,ipk,ipl,ipf) ) |
---|
150 | IF( llrecv_we ) ALLOCATE( zrcv_we(nn_hls,jpj,ipk,ipl,ipf) ) |
---|
151 | IF( llrecv_ea ) ALLOCATE( zrcv_ea(nn_hls,jpj,ipk,ipl,ipf) ) |
---|
152 | ! |
---|
153 | IF( llsend_we ) THEN ! copy western side of the inner mpi domain in local temporary array to be sent by MPI |
---|
154 | ishift = nn_hls |
---|
155 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
156 | zsnd_we(ji,jj,jk,jl,jf) = ARRAY_IN(ishift+ji,jj,jk,jl,jf) ! nn_hls + 1 -> 2*nn_hls |
---|
157 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
158 | ENDIF |
---|
159 | ! |
---|
160 | IF(llsend_ea ) THEN ! copy eastern side of the inner mpi domain in local temporary array to be sent by MPI |
---|
161 | ishift = jpi - 2 * nn_hls |
---|
162 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
163 | zsnd_ea(ji,jj,jk,jl,jf) = ARRAY_IN(ishift+ji,jj,jk,jl,jf) ! jpi - 2*nn_hls + 1 -> jpi - nn_hls |
---|
164 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
165 | ENDIF |
---|
166 | ! |
---|
167 | IF( ln_timing ) CALL tic_tac(.TRUE.) |
---|
168 | ! |
---|
169 | ! non-blocking send of the western/eastern side using local temporary arrays |
---|
170 | IF( llsend_we ) CALL mppsend( 1, zsnd_we(1,1,1,1,1), isize, nowe, ireq_we ) |
---|
171 | IF( llsend_ea ) CALL mppsend( 2, zsnd_ea(1,1,1,1,1), isize, noea, ireq_ea ) |
---|
172 | ! blocking receive of the western/eastern halo in local temporary arrays |
---|
173 | IF( llrecv_we ) CALL mpprecv( 2, zrcv_we(1,1,1,1,1), isize, nowe ) |
---|
174 | IF( llrecv_ea ) CALL mpprecv( 1, zrcv_ea(1,1,1,1,1), isize, noea ) |
---|
175 | ! |
---|
176 | IF( ln_timing ) CALL tic_tac(.FALSE.) |
---|
177 | ! |
---|
178 | ! |
---|
179 | ! ----------------------------------- ! |
---|
180 | ! 2. Fill east and west halos ! |
---|
181 | ! ----------------------------------- ! |
---|
182 | ! |
---|
183 | ! 2.1 fill weastern halo |
---|
184 | ! ---------------------- |
---|
185 | ! ishift = 0 ! fill halo from ji = 1 to nn_hls |
---|
186 | SELECT CASE ( ifill_we ) |
---|
187 | CASE ( jpfillnothing ) ! no filling |
---|
188 | CASE ( jpfillmpi ) ! use data received by MPI |
---|
189 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
190 | ARRAY_IN(ji,jj,jk,jl,jf) = zrcv_we(ji,jj,jk,jl,jf) ! 1 -> nn_hls |
---|
191 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
192 | CASE ( jpfillperio ) ! use east-weast periodicity |
---|
193 | ishift2 = jpi - 2 * nn_hls |
---|
194 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
195 | ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf) |
---|
196 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
197 | CASE ( jpfillcopy ) ! filling with inner domain values |
---|
198 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
199 | ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(nn_hls+1,jj,jk,jl,jf) |
---|
200 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
201 | CASE ( jpfillcst ) ! filling with constant value |
---|
202 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
203 | ARRAY_IN(ji,jj,jk,jl,jf) = zland |
---|
204 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
205 | END SELECT |
---|
206 | ! |
---|
207 | ! 2.2 fill eastern halo |
---|
208 | ! --------------------- |
---|
209 | ishift = jpi - nn_hls ! fill halo from ji = jpi-nn_hls+1 to jpi |
---|
210 | SELECT CASE ( ifill_ea ) |
---|
211 | CASE ( jpfillnothing ) ! no filling |
---|
212 | CASE ( jpfillmpi ) ! use data received by MPI |
---|
213 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
214 | ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv_ea(ji,jj,jk,jl,jf) ! jpi - nn_hls + 1 -> jpi |
---|
215 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
216 | CASE ( jpfillperio ) ! use east-weast periodicity |
---|
217 | ishift2 = nn_hls |
---|
218 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
219 | ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf) |
---|
220 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
221 | CASE ( jpfillcopy ) ! filling with inner domain values |
---|
222 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
223 | ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf) |
---|
224 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
225 | CASE ( jpfillcst ) ! filling with constant value |
---|
226 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, nn_hls |
---|
227 | ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland |
---|
228 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
229 | END SELECT |
---|
230 | ! |
---|
231 | ! ------------------------------- ! |
---|
232 | ! 3. north fold treatment ! |
---|
233 | ! ------------------------------- ! |
---|
234 | ! |
---|
235 | ! do it before south directions so concerned processes can do it without waiting for the comm with the sourthern neighbor |
---|
236 | ! |
---|
237 | IF( lldo_nfd .AND. ifill_no /= jpfillnothing ) THEN |
---|
238 | ! |
---|
239 | SELECT CASE ( jpni ) |
---|
240 | CASE ( 1 ) ; CALL lbc_nfd( ptab, NAT_IN(:), SGN_IN(:) OPT_K(:) ) ! only 1 northern proc, no mpp |
---|
241 | CASE DEFAULT ; CALL mpp_nfd( ptab, NAT_IN(:), SGN_IN(:), ifill_no, zland OPT_K(:) ) ! for all northern procs. |
---|
242 | END SELECT |
---|
243 | ! |
---|
244 | ifill_no = jpfillnothing ! force to do nothing for the northern halo as we just done the north pole folding |
---|
245 | ! |
---|
246 | ENDIF |
---|
247 | ! |
---|
248 | ! ---------------------------------------------------- ! |
---|
249 | ! 4. Do north and south MPI exchange if needed ! |
---|
250 | ! ---------------------------------------------------- ! |
---|
251 | ! |
---|
252 | IF( llsend_so ) ALLOCATE( zsnd_so(jpi,nn_hls,ipk,ipl,ipf) ) |
---|
253 | IF( llsend_no ) ALLOCATE( zsnd_no(jpi,nn_hls,ipk,ipl,ipf) ) |
---|
254 | IF( llrecv_so ) ALLOCATE( zrcv_so(jpi,nn_hls,ipk,ipl,ipf) ) |
---|
255 | IF( llrecv_no ) ALLOCATE( zrcv_no(jpi,nn_hls,ipk,ipl,ipf) ) |
---|
256 | ! |
---|
257 | isize = jpi * nn_hls * ipk * ipl * ipf |
---|
258 | |
---|
259 | ! allocate local temporary arrays to be sent/received. Fill arrays to be sent |
---|
260 | IF( llsend_so ) THEN ! copy sourhern side of the inner mpi domain in local temporary array to be sent by MPI |
---|
261 | ishift = nn_hls |
---|
262 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
263 | zsnd_so(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift+jj,jk,jl,jf) ! nn_hls+1 -> 2*nn_hls |
---|
264 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
265 | ENDIF |
---|
266 | ! |
---|
267 | IF( llsend_no ) THEN ! copy eastern side of the inner mpi domain in local temporary array to be sent by MPI |
---|
268 | ishift = jpj - 2 * nn_hls |
---|
269 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
270 | zsnd_no(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift+jj,jk,jl,jf) ! jpj-2*nn_hls+1 -> jpj-nn_hls |
---|
271 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
272 | ENDIF |
---|
273 | ! |
---|
274 | IF( ln_timing ) CALL tic_tac(.TRUE.) |
---|
275 | ! |
---|
276 | ! non-blocking send of the southern/northern side |
---|
277 | IF( llsend_so ) CALL mppsend( 3, zsnd_so(1,1,1,1,1), isize, noso, ireq_so ) |
---|
278 | IF( llsend_no ) CALL mppsend( 4, zsnd_no(1,1,1,1,1), isize, nono, ireq_no ) |
---|
279 | ! blocking receive of the southern/northern halo |
---|
280 | IF( llrecv_so ) CALL mpprecv( 4, zrcv_so(1,1,1,1,1), isize, noso ) |
---|
281 | IF( llrecv_no ) CALL mpprecv( 3, zrcv_no(1,1,1,1,1), isize, nono ) |
---|
282 | ! |
---|
283 | IF( ln_timing ) CALL tic_tac(.FALSE.) |
---|
284 | ! |
---|
285 | ! ------------------------------------- ! |
---|
286 | ! 5. Fill south and north halos ! |
---|
287 | ! ------------------------------------- ! |
---|
288 | ! |
---|
289 | ! 5.1 fill southern halo |
---|
290 | ! ---------------------- |
---|
291 | ! ishift = 0 ! fill halo from jj = 1 to nn_hls |
---|
292 | SELECT CASE ( ifill_so ) |
---|
293 | CASE ( jpfillnothing ) ! no filling |
---|
294 | CASE ( jpfillmpi ) ! use data received by MPI |
---|
295 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
296 | ARRAY_IN(ji,jj,jk,jl,jf) = zrcv_so(ji,jj,jk,jl,jf) ! 1 -> nn_hls |
---|
297 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
298 | CASE ( jpfillperio ) ! use north-south periodicity |
---|
299 | ishift2 = jpj - 2 * nn_hls |
---|
300 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
301 | ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf) |
---|
302 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
303 | CASE ( jpfillcopy ) ! filling with inner domain values |
---|
304 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
305 | ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,nn_hls+1,jk,jl,jf) |
---|
306 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
307 | CASE ( jpfillcst ) ! filling with constant value |
---|
308 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
309 | ARRAY_IN(ji,jj,jk,jl,jf) = zland |
---|
310 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
311 | END SELECT |
---|
312 | ! |
---|
313 | ! 5.2 fill northern halo |
---|
314 | ! ---------------------- |
---|
315 | ishift = jpj - nn_hls ! fill halo from jj = jpj-nn_hls+1 to jpj |
---|
316 | SELECT CASE ( ifill_no ) |
---|
317 | CASE ( jpfillnothing ) ! no filling |
---|
318 | CASE ( jpfillmpi ) ! use data received by MPI |
---|
319 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
320 | ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zrcv_no(ji,jj,jk,jl,jf) ! jpj-nn_hls+1 -> jpj |
---|
321 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
322 | CASE ( jpfillperio ) ! use north-south periodicity |
---|
323 | ishift2 = nn_hls |
---|
324 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
325 | ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf) |
---|
326 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
327 | CASE ( jpfillcopy ) ! filling with inner domain values |
---|
328 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
329 | ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift,jk,jl,jf) |
---|
330 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
331 | CASE ( jpfillcst ) ! filling with constant value |
---|
332 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, nn_hls ; DO ji = 1, jpi |
---|
333 | ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zland |
---|
334 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
335 | END SELECT |
---|
336 | ! |
---|
337 | ! -------------------------------------------- ! |
---|
338 | ! 6. deallocate local temporary arrays ! |
---|
339 | ! -------------------------------------------- ! |
---|
340 | ! |
---|
341 | IF( llsend_we ) THEN |
---|
342 | CALL mpi_wait(ireq_we, istat, ierr ) |
---|
343 | DEALLOCATE( zsnd_we ) |
---|
344 | ENDIF |
---|
345 | IF( llsend_ea ) THEN |
---|
346 | CALL mpi_wait(ireq_ea, istat, ierr ) |
---|
347 | DEALLOCATE( zsnd_ea ) |
---|
348 | ENDIF |
---|
349 | IF( llsend_so ) THEN |
---|
350 | CALL mpi_wait(ireq_so, istat, ierr ) |
---|
351 | DEALLOCATE( zsnd_so ) |
---|
352 | ENDIF |
---|
353 | IF( llsend_no ) THEN |
---|
354 | CALL mpi_wait(ireq_no, istat, ierr ) |
---|
355 | DEALLOCATE( zsnd_no ) |
---|
356 | ENDIF |
---|
357 | ! |
---|
358 | IF( llrecv_we ) DEALLOCATE( zrcv_we ) |
---|
359 | IF( llrecv_ea ) DEALLOCATE( zrcv_ea ) |
---|
360 | IF( llrecv_so ) DEALLOCATE( zrcv_so ) |
---|
361 | IF( llrecv_no ) DEALLOCATE( zrcv_no ) |
---|
362 | ! |
---|
363 | END SUBROUTINE ROUTINE_LNK |
---|
364 | |
---|
365 | #undef ARRAY_TYPE |
---|
366 | #undef NAT_IN |
---|
367 | #undef SGN_IN |
---|
368 | #undef ARRAY_IN |
---|
369 | #undef K_SIZE |
---|
370 | #undef L_SIZE |
---|
371 | #undef F_SIZE |
---|
372 | #undef OPT_K |
---|