1 | MODULE lbclnk |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE lbclnk *** |
---|
4 | !! NEMO : lateral boundary conditions |
---|
5 | !!===================================================================== |
---|
6 | !! History : OPA ! 1997-06 (G. Madec) Original code |
---|
7 | !! NEMO 1.0 ! 2002-09 (G. Madec) F90: Free form and module |
---|
8 | !! 3.2 ! 2009-03 (R. Benshila) External north fold treatment |
---|
9 | !! 3.5 ! 2012 (S.Mocavero, I. Epicoco) optimization of BDY comm. via lbc_bdy_lnk and lbc_obc_lnk |
---|
10 | !! 3.4 ! 2012-12 (R. Bourdalle-Badie, G. Reffray) add a C1D case |
---|
11 | !! 3.6 ! 2015-06 (O. Tintó and M. Castrillo) add lbc_lnk_multi |
---|
12 | !! 4.0 ! 2017-03 (G. Madec) automatique allocation of array size (use with any 3rd dim size) |
---|
13 | !! - ! 2017-04 (G. Madec) remove duplicated routines (lbc_lnk_2d_9, lbc_lnk_2d_multiple, lbc_lnk_3d_gather) |
---|
14 | !! - ! 2017-05 (G. Madec) create generic.h90 files to generate all lbc and north fold routines |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | #if defined key_mpp_mpi |
---|
17 | !!---------------------------------------------------------------------- |
---|
18 | !! 'key_mpp_mpi' MPI massively parallel processing library |
---|
19 | !!---------------------------------------------------------------------- |
---|
20 | !! define the generic interfaces of lib_mpp routines |
---|
21 | !!---------------------------------------------------------------------- |
---|
22 | !! lbc_lnk : generic interface for mpp_lnk_3d and mpp_lnk_2d routines defined in lib_mpp |
---|
23 | !! lbc_lnk_e : generic interface for mpp_lnk_2d_e routine defined in lib_mpp |
---|
24 | !! lbc_bdy_lnk : generic interface for mpp_lnk_bdy_2d and mpp_lnk_bdy_3d routines defined in lib_mpp |
---|
25 | !!---------------------------------------------------------------------- |
---|
26 | USE par_oce ! ocean dynamics and tracers |
---|
27 | USE lib_mpp ! distributed memory computing library |
---|
28 | USE lbcnfd ! north fold |
---|
29 | |
---|
30 | INTERFACE lbc_lnk |
---|
31 | MODULE PROCEDURE mpp_lnk_2d , mpp_lnk_3d , mpp_lnk_4d |
---|
32 | END INTERFACE |
---|
33 | INTERFACE lbc_lnk_ptr |
---|
34 | MODULE PROCEDURE mpp_lnk_2d_ptr , mpp_lnk_3d_ptr , mpp_lnk_4d_ptr |
---|
35 | END INTERFACE |
---|
36 | INTERFACE lbc_lnk_multi |
---|
37 | MODULE PROCEDURE lbc_lnk_2d_multi, lbc_lnk_3d_multi, lbc_lnk_4d_multi |
---|
38 | END INTERFACE |
---|
39 | ! |
---|
40 | INTERFACE lbc_bdy_lnk |
---|
41 | MODULE PROCEDURE mpp_lnk_bdy_2d, mpp_lnk_bdy_3d |
---|
42 | END INTERFACE |
---|
43 | ! |
---|
44 | INTERFACE lbc_lnk_e |
---|
45 | MODULE PROCEDURE mpp_lnk_2d_e |
---|
46 | END INTERFACE |
---|
47 | ! |
---|
48 | INTERFACE lbc_lnk_icb |
---|
49 | MODULE PROCEDURE mpp_lnk_2d_icb |
---|
50 | END INTERFACE |
---|
51 | |
---|
52 | PUBLIC lbc_lnk ! ocean/ice lateral boundary conditions |
---|
53 | PUBLIC lbc_lnk_multi ! modified ocean/ice lateral boundary conditions |
---|
54 | PUBLIC lbc_lnk_e ! extended ocean/ice lateral boundary conditions |
---|
55 | PUBLIC lbc_bdy_lnk ! ocean lateral BDY boundary conditions |
---|
56 | PUBLIC lbc_lnk_icb ! iceberg lateral boundary conditions |
---|
57 | |
---|
58 | !!---------------------------------------------------------------------- |
---|
59 | !! NEMO/OPA 4.0 , NEMO Consortium (2017) |
---|
60 | !! $Id$ |
---|
61 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
62 | !!---------------------------------------------------------------------- |
---|
63 | CONTAINS |
---|
64 | |
---|
65 | #else |
---|
66 | !!---------------------------------------------------------------------- |
---|
67 | !! Default option shared memory computing |
---|
68 | !!---------------------------------------------------------------------- |
---|
69 | !! routines setting the appropriate values |
---|
70 | !! on first and last row and column of the global domain |
---|
71 | !!---------------------------------------------------------------------- |
---|
72 | !! lbc_lnk_sum_3d: compute sum over the halos on a 3D variable on ocean mesh |
---|
73 | !! lbc_lnk_sum_3d: compute sum over the halos on a 2D variable on ocean mesh |
---|
74 | !! lbc_lnk : generic interface for lbc_lnk_3d and lbc_lnk_2d |
---|
75 | !! lbc_lnk_3d : set the lateral boundary condition on a 3D variable on ocean mesh |
---|
76 | !! lbc_lnk_2d : set the lateral boundary condition on a 2D variable on ocean mesh |
---|
77 | !! lbc_bdy_lnk : set the lateral BDY boundary condition |
---|
78 | !!---------------------------------------------------------------------- |
---|
79 | USE oce ! ocean dynamics and tracers |
---|
80 | USE dom_oce ! ocean space and time domain |
---|
81 | USE in_out_manager ! I/O manager |
---|
82 | USE lbcnfd ! north fold |
---|
83 | |
---|
84 | IMPLICIT NONE |
---|
85 | PRIVATE |
---|
86 | |
---|
87 | INTERFACE lbc_lnk |
---|
88 | MODULE PROCEDURE lbc_lnk_2d , lbc_lnk_3d , lbc_lnk_4d |
---|
89 | END INTERFACE |
---|
90 | INTERFACE lbc_lnk_ptr |
---|
91 | MODULE PROCEDURE lbc_lnk_2d_ptr , lbc_lnk_3d_ptr , lbc_lnk_4d_ptr |
---|
92 | END INTERFACE |
---|
93 | INTERFACE lbc_lnk_multi |
---|
94 | MODULE PROCEDURE lbc_lnk_2d_multi, lbc_lnk_3d_multi, lbc_lnk_4d_multi |
---|
95 | END INTERFACE |
---|
96 | ! |
---|
97 | INTERFACE lbc_lnk_e |
---|
98 | MODULE PROCEDURE lbc_lnk_2d_e |
---|
99 | END INTERFACE |
---|
100 | ! |
---|
101 | INTERFACE lbc_bdy_lnk |
---|
102 | MODULE PROCEDURE lbc_bdy_lnk_2d, lbc_bdy_lnk_3d |
---|
103 | END INTERFACE |
---|
104 | ! |
---|
105 | INTERFACE lbc_lnk_icb |
---|
106 | MODULE PROCEDURE lbc_lnk_2d_e |
---|
107 | END INTERFACE |
---|
108 | |
---|
109 | PUBLIC lbc_lnk ! ocean/ice lateral boundary conditions |
---|
110 | PUBLIC lbc_lnk_e ! extended ocean/ice lateral boundary conditions |
---|
111 | PUBLIC lbc_lnk_multi ! modified ocean/ice lateral boundary conditions |
---|
112 | PUBLIC lbc_bdy_lnk ! ocean lateral BDY boundary conditions |
---|
113 | PUBLIC lbc_lnk_icb ! iceberg lateral boundary conditions |
---|
114 | |
---|
115 | !!---------------------------------------------------------------------- |
---|
116 | !! NEMO/OPA 4.0 , NEMO Consortium (2017) |
---|
117 | !! $Id$ |
---|
118 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
119 | !!---------------------------------------------------------------------- |
---|
120 | CONTAINS |
---|
121 | |
---|
122 | # if defined key_c1d |
---|
123 | !!====================================================================== |
---|
124 | !! 'key_c1d' 1D configuration |
---|
125 | !!====================================================================== |
---|
126 | !! central point value replicated over the 8 surrounding points |
---|
127 | !!---------------------------------------------------------------------- |
---|
128 | |
---|
129 | SUBROUTINE lbc_lnk_3d( pt3d, cd_type, psgn, cd_mpp, pval ) |
---|
130 | !!--------------------------------------------------------------------- |
---|
131 | !! *** ROUTINE lbc_lnk_3d *** |
---|
132 | !! |
---|
133 | !! ** Purpose : set lateral boundary conditions on a 3D array (C1D case) |
---|
134 | !! |
---|
135 | !! ** Method : 1D case, the central water column is set everywhere |
---|
136 | !!---------------------------------------------------------------------- |
---|
137 | REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: pt3d ! 3D array on which the lbc is applied |
---|
138 | CHARACTER(len=1) , INTENT(in ) :: cd_type ! nature of pt3d grid-points |
---|
139 | REAL(wp) , INTENT(in ) :: psgn ! sign used across north fold |
---|
140 | CHARACTER(len=3) , INTENT(in ), OPTIONAL :: cd_mpp ! MPP only (here do nothing) |
---|
141 | REAL(wp) , INTENT(in ), OPTIONAL :: pval ! background value (for closed boundaries) |
---|
142 | ! |
---|
143 | INTEGER :: jk ! dummy loop index |
---|
144 | REAL(wp) :: ztab ! local scalar |
---|
145 | !!---------------------------------------------------------------------- |
---|
146 | ! |
---|
147 | DO jk = 1, SIZE( pt3d, 3 ) |
---|
148 | ztab = pt3d(2,2,jk) |
---|
149 | pt3d(:,:,jk) = ztab |
---|
150 | END DO |
---|
151 | ! |
---|
152 | END SUBROUTINE lbc_lnk_3d |
---|
153 | |
---|
154 | |
---|
155 | SUBROUTINE lbc_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval ) |
---|
156 | !!--------------------------------------------------------------------- |
---|
157 | !! *** ROUTINE lbc_lnk_2d *** |
---|
158 | !! |
---|
159 | !! ** Purpose : set lateral boundary conditions on a 2D array (non mpp case) |
---|
160 | !! |
---|
161 | !! ** Method : 1D case, the central water column is set everywhere |
---|
162 | !!---------------------------------------------------------------------- |
---|
163 | REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pt2d ! 2D array on which the lbc is applied |
---|
164 | CHARACTER(len=1) , INTENT(in ) :: cd_type ! nature of pt3d grid-points |
---|
165 | REAL(wp) , INTENT(in ) :: psgn ! sign used across north fold |
---|
166 | CHARACTER(len=3) , INTENT(in ), OPTIONAL :: cd_mpp ! MPP only (here do nothing) |
---|
167 | REAL(wp) , INTENT(in ), OPTIONAL :: pval ! background value (for closed boundaries) |
---|
168 | ! |
---|
169 | REAL(wp) :: ztab ! local scalar |
---|
170 | !!---------------------------------------------------------------------- |
---|
171 | ! |
---|
172 | ztab = pt2d(2,2) |
---|
173 | pt2d(:,:) = ztab |
---|
174 | ! |
---|
175 | END SUBROUTINE lbc_lnk_2d |
---|
176 | |
---|
177 | #else |
---|
178 | !!====================================================================== |
---|
179 | !! Default option 3D shared memory computing |
---|
180 | !!====================================================================== |
---|
181 | !! routines setting land point, or east-west cyclic, |
---|
182 | !! or north-south cyclic, or north fold values |
---|
183 | !! on first and last row and column of the global domain |
---|
184 | !!---------------------------------------------------------------------- |
---|
185 | |
---|
186 | !!---------------------------------------------------------------------- |
---|
187 | !! *** routine lbc_lnk_(2,3,4)d *** |
---|
188 | !! |
---|
189 | !! * Argument : dummy argument use in lbc_lnk_... routines |
---|
190 | !! ptab : array or pointer of arrays on which the boundary condition is applied |
---|
191 | !! cd_nat : nature of array grid-points |
---|
192 | !! psgn : sign used across the north fold boundary |
---|
193 | !! kfld : optional, number of pt3d arrays |
---|
194 | !! cd_mpp : optional, fill the overlap area only |
---|
195 | !! pval : optional, background value (used at closed boundaries) |
---|
196 | !!---------------------------------------------------------------------- |
---|
197 | ! |
---|
198 | ! !== 2D array and array of 2D pointer ==! |
---|
199 | ! |
---|
200 | # define DIM_2d |
---|
201 | # define ROUTINE_LNK lbc_lnk_2d |
---|
202 | # include "lbc_lnk_generic.h90" |
---|
203 | # undef ROUTINE_LNK |
---|
204 | # define MULTI |
---|
205 | # define ROUTINE_LNK lbc_lnk_2d_ptr |
---|
206 | # include "lbc_lnk_generic.h90" |
---|
207 | # undef ROUTINE_LNK |
---|
208 | # undef MULTI |
---|
209 | # undef DIM_2d |
---|
210 | ! |
---|
211 | ! !== 3D array and array of 3D pointer ==! |
---|
212 | ! |
---|
213 | # define DIM_3d |
---|
214 | # define ROUTINE_LNK lbc_lnk_3d |
---|
215 | # include "lbc_lnk_generic.h90" |
---|
216 | # undef ROUTINE_LNK |
---|
217 | # define MULTI |
---|
218 | # define ROUTINE_LNK lbc_lnk_3d_ptr |
---|
219 | # include "lbc_lnk_generic.h90" |
---|
220 | # undef ROUTINE_LNK |
---|
221 | # undef MULTI |
---|
222 | # undef DIM_3d |
---|
223 | ! |
---|
224 | ! !== 4D array and array of 4D pointer ==! |
---|
225 | ! |
---|
226 | # define DIM_4d |
---|
227 | # define ROUTINE_LNK lbc_lnk_4d |
---|
228 | # include "lbc_lnk_generic.h90" |
---|
229 | # undef ROUTINE_LNK |
---|
230 | # define MULTI |
---|
231 | # define ROUTINE_LNK lbc_lnk_4d_ptr |
---|
232 | # include "lbc_lnk_generic.h90" |
---|
233 | # undef ROUTINE_LNK |
---|
234 | # undef MULTI |
---|
235 | # undef DIM_4d |
---|
236 | |
---|
237 | #endif |
---|
238 | |
---|
239 | !!====================================================================== |
---|
240 | !! identical routines in both C1D and shared memory computing |
---|
241 | !!====================================================================== |
---|
242 | |
---|
243 | !!---------------------------------------------------------------------- |
---|
244 | !! *** routine lbc_bdy_lnk_(2,3)d *** |
---|
245 | !! |
---|
246 | !! wrapper rountine to 'lbc_lnk_3d'. This wrapper is used |
---|
247 | !! to maintain the same interface with regards to the mpp case |
---|
248 | !!---------------------------------------------------------------------- |
---|
249 | |
---|
250 | SUBROUTINE lbc_bdy_lnk_3d( pt3d, cd_type, psgn, ib_bdy ) |
---|
251 | !!---------------------------------------------------------------------- |
---|
252 | REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: pt3d ! 3D array on which the lbc is applied |
---|
253 | CHARACTER(len=1) , INTENT(in ) :: cd_type ! nature of pt3d grid-points |
---|
254 | REAL(wp) , INTENT(in ) :: psgn ! sign used across north fold |
---|
255 | INTEGER , INTENT(in ) :: ib_bdy ! BDY boundary set |
---|
256 | !!---------------------------------------------------------------------- |
---|
257 | CALL lbc_lnk_3d( pt3d, cd_type, psgn) |
---|
258 | END SUBROUTINE lbc_bdy_lnk_3d |
---|
259 | |
---|
260 | |
---|
261 | SUBROUTINE lbc_bdy_lnk_2d( pt2d, cd_type, psgn, ib_bdy ) |
---|
262 | !!---------------------------------------------------------------------- |
---|
263 | REAL(wp), DIMENSION(:,:), INTENT(inout) :: pt2d ! 3D array on which the lbc is applied |
---|
264 | CHARACTER(len=1) , INTENT(in ) :: cd_type ! nature of pt3d grid-points |
---|
265 | REAL(wp) , INTENT(in ) :: psgn ! sign used across north fold |
---|
266 | INTEGER , INTENT(in ) :: ib_bdy ! BDY boundary set |
---|
267 | !!---------------------------------------------------------------------- |
---|
268 | CALL lbc_lnk_2d( pt2d, cd_type, psgn) |
---|
269 | END SUBROUTINE lbc_bdy_lnk_2d |
---|
270 | |
---|
271 | |
---|
272 | !!gm This routine should be remove with an optional halos size added in orgument of generic routines |
---|
273 | |
---|
274 | SUBROUTINE lbc_lnk_2d_e( pt2d, cd_type, psgn, ki, kj ) |
---|
275 | !!---------------------------------------------------------------------- |
---|
276 | REAL(wp), DIMENSION(:,:), INTENT(inout) :: pt2d ! 2D array on which the lbc is applied |
---|
277 | CHARACTER(len=1) , INTENT(in ) :: cd_type ! nature of pt3d grid-points |
---|
278 | REAL(wp) , INTENT(in ) :: psgn ! sign used across north fold |
---|
279 | INTEGER , INTENT(in ) :: ki, kj ! sizes of extra halo (not needed in non-mpp) |
---|
280 | !!---------------------------------------------------------------------- |
---|
281 | CALL lbc_lnk_2d( pt2d, cd_type, psgn ) |
---|
282 | END SUBROUTINE lbc_lnk_2d_e |
---|
283 | !!gm end |
---|
284 | |
---|
285 | #endif |
---|
286 | |
---|
287 | !!====================================================================== |
---|
288 | !! identical routines in both distributed and shared memory computing |
---|
289 | !!====================================================================== |
---|
290 | |
---|
291 | !!---------------------------------------------------------------------- |
---|
292 | !! *** load_ptr_(2,3,4)d *** |
---|
293 | !! |
---|
294 | !! * Dummy Argument : |
---|
295 | !! in ==> ptab ! array to be loaded (2D, 3D or 4D) |
---|
296 | !! cd_nat ! nature of pt2d array grid-points |
---|
297 | !! psgn ! sign used across the north fold boundary |
---|
298 | !! inout <=> ptab_ptr ! array of 2D, 3D or 4D pointers |
---|
299 | !! cdna_ptr ! nature of ptab array grid-points |
---|
300 | !! psgn_ptr ! sign used across the north fold boundary |
---|
301 | !! kfld ! number of elements that has been attributed |
---|
302 | !!---------------------------------------------------------------------- |
---|
303 | |
---|
304 | !!---------------------------------------------------------------------- |
---|
305 | !! *** lbc_lnk_(2,3,4)d_multi *** |
---|
306 | !! *** load_ptr_(2,3,4)d *** |
---|
307 | !! |
---|
308 | !! * Argument : dummy argument use in lbc_lnk_multi_... routines |
---|
309 | !! |
---|
310 | !!---------------------------------------------------------------------- |
---|
311 | |
---|
312 | # define DIM_2d |
---|
313 | # define ROUTINE_MULTI lbc_lnk_2d_multi |
---|
314 | # define ROUTINE_LOAD load_ptr_2d |
---|
315 | # include "lbc_lnk_multi_generic.h90" |
---|
316 | # undef ROUTINE_MULTI |
---|
317 | # undef ROUTINE_LOAD |
---|
318 | # undef DIM_2d |
---|
319 | |
---|
320 | |
---|
321 | # define DIM_3d |
---|
322 | # define ROUTINE_MULTI lbc_lnk_3d_multi |
---|
323 | # define ROUTINE_LOAD load_ptr_3d |
---|
324 | # include "lbc_lnk_multi_generic.h90" |
---|
325 | # undef ROUTINE_MULTI |
---|
326 | # undef ROUTINE_LOAD |
---|
327 | # undef DIM_3d |
---|
328 | |
---|
329 | |
---|
330 | # define DIM_4d |
---|
331 | # define ROUTINE_MULTI lbc_lnk_4d_multi |
---|
332 | # define ROUTINE_LOAD load_ptr_4d |
---|
333 | # include "lbc_lnk_multi_generic.h90" |
---|
334 | # undef ROUTINE_MULTI |
---|
335 | # undef ROUTINE_LOAD |
---|
336 | # undef DIM_4d |
---|
337 | |
---|
338 | !!====================================================================== |
---|
339 | END MODULE lbclnk |
---|
340 | |
---|