[3] | 1 | MODULE lbclnk |
---|
| 2 | !!====================================================================== |
---|
[232] | 3 | !! *** MODULE lbclnk *** |
---|
[8170] | 4 | !! NEMO : lateral boundary conditions |
---|
[3] | 5 | !!===================================================================== |
---|
[6140] | 6 | !! History : OPA ! 1997-06 (G. Madec) Original code |
---|
| 7 | !! NEMO 1.0 ! 2002-09 (G. Madec) F90: Free form and module |
---|
[2335] | 8 | !! 3.2 ! 2009-03 (R. Benshila) External north fold treatment |
---|
[8186] | 9 | !! 3.5 ! 2012 (S.Mocavero, I. Epicoco) optimization of BDY comm. via lbc_bdy_lnk and lbc_obc_lnk |
---|
[6140] | 10 | !! 3.4 ! 2012-12 (R. Bourdalle-Badie, G. Reffray) add a C1D case |
---|
[6490] | 11 | !! 3.6 ! 2015-06 (O. Tintó and M. Castrillo) add lbc_lnk_multi |
---|
[8170] | 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) |
---|
[8186] | 14 | !! - ! 2017-05 (G. Madec) create generic.h90 files to generate all lbc and north fold routines |
---|
[1344] | 15 | !!---------------------------------------------------------------------- |
---|
[3764] | 16 | #if defined key_mpp_mpi |
---|
[3] | 17 | !!---------------------------------------------------------------------- |
---|
[2335] | 18 | !! 'key_mpp_mpi' MPI massively parallel processing library |
---|
[3] | 19 | !!---------------------------------------------------------------------- |
---|
[8170] | 20 | !! define the generic interfaces of lib_mpp routines |
---|
[15] | 21 | !!---------------------------------------------------------------------- |
---|
[8170] | 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 | !!---------------------------------------------------------------------- |
---|
[8186] | 26 | USE par_oce ! ocean dynamics and tracers |
---|
[6140] | 27 | USE lib_mpp ! distributed memory computing library |
---|
[8186] | 28 | USE lbcnfd ! north fold |
---|
[3] | 29 | |
---|
| 30 | INTERFACE lbc_lnk |
---|
[8186] | 31 | MODULE PROCEDURE mpp_lnk_2d , mpp_lnk_3d , mpp_lnk_4d |
---|
[3] | 32 | END INTERFACE |
---|
[8186] | 33 | INTERFACE lbc_lnk_ptr |
---|
| 34 | MODULE PROCEDURE mpp_lnk_2d_ptr , mpp_lnk_3d_ptr , mpp_lnk_4d_ptr |
---|
[6140] | 35 | END INTERFACE |
---|
[8186] | 36 | INTERFACE lbc_lnk_multi |
---|
| 37 | MODULE PROCEDURE lbc_lnk_2d_multi, lbc_lnk_3d_multi, lbc_lnk_4d_multi |
---|
| 38 | END INTERFACE |
---|
[6493] | 39 | ! |
---|
[3680] | 40 | INTERFACE lbc_bdy_lnk |
---|
| 41 | MODULE PROCEDURE mpp_lnk_bdy_2d, mpp_lnk_bdy_3d |
---|
| 42 | END INTERFACE |
---|
[6140] | 43 | ! |
---|
[311] | 44 | INTERFACE lbc_lnk_e |
---|
| 45 | MODULE PROCEDURE mpp_lnk_2d_e |
---|
| 46 | END INTERFACE |
---|
[6140] | 47 | ! |
---|
[4990] | 48 | INTERFACE lbc_lnk_icb |
---|
| 49 | MODULE PROCEDURE mpp_lnk_2d_icb |
---|
| 50 | END INTERFACE |
---|
| 51 | |
---|
[8170] | 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 |
---|
[6140] | 55 | PUBLIC lbc_bdy_lnk ! ocean lateral BDY boundary conditions |
---|
[8170] | 56 | PUBLIC lbc_lnk_icb ! iceberg lateral boundary conditions |
---|
[2335] | 57 | |
---|
[3] | 58 | !!---------------------------------------------------------------------- |
---|
[8170] | 59 | !! NEMO/OPA 4.0 , NEMO Consortium (2017) |
---|
[2335] | 60 | !! $Id$ |
---|
| 61 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 62 | !!---------------------------------------------------------------------- |
---|
[8186] | 63 | CONTAINS |
---|
| 64 | |
---|
[3] | 65 | #else |
---|
| 66 | !!---------------------------------------------------------------------- |
---|
| 67 | !! Default option shared memory computing |
---|
| 68 | !!---------------------------------------------------------------------- |
---|
[8170] | 69 | !! routines setting the appropriate values |
---|
| 70 | !! on first and last row and column of the global domain |
---|
| 71 | !!---------------------------------------------------------------------- |
---|
[6140] | 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 |
---|
[3] | 78 | !!---------------------------------------------------------------------- |
---|
[8170] | 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 |
---|
[3] | 83 | |
---|
| 84 | IMPLICIT NONE |
---|
| 85 | PRIVATE |
---|
| 86 | |
---|
| 87 | INTERFACE lbc_lnk |
---|
[8186] | 88 | MODULE PROCEDURE lbc_lnk_2d , lbc_lnk_3d , lbc_lnk_4d |
---|
[3] | 89 | END INTERFACE |
---|
[8186] | 90 | INTERFACE lbc_lnk_ptr |
---|
| 91 | MODULE PROCEDURE lbc_lnk_2d_ptr , lbc_lnk_3d_ptr , lbc_lnk_4d_ptr |
---|
[6140] | 92 | END INTERFACE |
---|
[8186] | 93 | INTERFACE lbc_lnk_multi |
---|
| 94 | MODULE PROCEDURE lbc_lnk_2d_multi, lbc_lnk_3d_multi, lbc_lnk_4d_multi |
---|
| 95 | END INTERFACE |
---|
[8170] | 96 | ! |
---|
[311] | 97 | INTERFACE lbc_lnk_e |
---|
[3609] | 98 | MODULE PROCEDURE lbc_lnk_2d_e |
---|
[311] | 99 | END INTERFACE |
---|
[6140] | 100 | ! |
---|
[3680] | 101 | INTERFACE lbc_bdy_lnk |
---|
| 102 | MODULE PROCEDURE lbc_bdy_lnk_2d, lbc_bdy_lnk_3d |
---|
| 103 | END INTERFACE |
---|
[6140] | 104 | ! |
---|
[4990] | 105 | INTERFACE lbc_lnk_icb |
---|
| 106 | MODULE PROCEDURE lbc_lnk_2d_e |
---|
| 107 | END INTERFACE |
---|
[6490] | 108 | |
---|
[2335] | 109 | PUBLIC lbc_lnk ! ocean/ice lateral boundary conditions |
---|
[8170] | 110 | PUBLIC lbc_lnk_e ! extended ocean/ice lateral boundary conditions |
---|
| 111 | PUBLIC lbc_lnk_multi ! modified ocean/ice lateral boundary conditions |
---|
[3680] | 112 | PUBLIC lbc_bdy_lnk ! ocean lateral BDY boundary conditions |
---|
[8170] | 113 | PUBLIC lbc_lnk_icb ! iceberg lateral boundary conditions |
---|
[2335] | 114 | |
---|
[3] | 115 | !!---------------------------------------------------------------------- |
---|
[8170] | 116 | !! NEMO/OPA 4.0 , NEMO Consortium (2017) |
---|
[2335] | 117 | !! $Id$ |
---|
| 118 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 119 | !!---------------------------------------------------------------------- |
---|
[3] | 120 | CONTAINS |
---|
| 121 | |
---|
[3764] | 122 | # if defined key_c1d |
---|
[8186] | 123 | !!====================================================================== |
---|
[3764] | 124 | !! 'key_c1d' 1D configuration |
---|
[8186] | 125 | !!====================================================================== |
---|
[8170] | 126 | !! central point value replicated over the 8 surrounding points |
---|
| 127 | !!---------------------------------------------------------------------- |
---|
[3764] | 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 | !!---------------------------------------------------------------------- |
---|
[8170] | 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) |
---|
[3764] | 142 | ! |
---|
| 143 | INTEGER :: jk ! dummy loop index |
---|
| 144 | REAL(wp) :: ztab ! local scalar |
---|
| 145 | !!---------------------------------------------------------------------- |
---|
| 146 | ! |
---|
[8170] | 147 | DO jk = 1, SIZE( pt3d, 3 ) |
---|
[3764] | 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 | !!---------------------------------------------------------------------- |
---|
[8170] | 163 | REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pt2d ! 2D array on which the lbc is applied |
---|
[3764] | 164 | CHARACTER(len=1) , INTENT(in ) :: cd_type ! nature of pt3d grid-points |
---|
[8170] | 165 | REAL(wp) , INTENT(in ) :: psgn ! sign used across north fold |
---|
[3764] | 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 |
---|
[6490] | 176 | |
---|
[3764] | 177 | #else |
---|
[8186] | 178 | !!====================================================================== |
---|
[3764] | 179 | !! Default option 3D shared memory computing |
---|
[8186] | 180 | !!====================================================================== |
---|
[8170] | 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 | !!---------------------------------------------------------------------- |
---|
[3764] | 185 | |
---|
[8186] | 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 |
---|
[6490] | 236 | |
---|
[8170] | 237 | #endif |
---|
| 238 | |
---|
[8186] | 239 | !!====================================================================== |
---|
| 240 | !! identical routines in both C1D and shared memory computing |
---|
| 241 | !!====================================================================== |
---|
| 242 | |
---|
[8170] | 243 | !!---------------------------------------------------------------------- |
---|
[8186] | 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 |
---|
[8170] | 248 | !!---------------------------------------------------------------------- |
---|
[8186] | 249 | |
---|
[8170] | 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 |
---|
[6490] | 259 | |
---|
| 260 | |
---|
[8170] | 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 | |
---|
[8186] | 272 | !!gm This routine should be remove with an optional halos size added in orgument of generic routines |
---|
| 273 | |
---|
[8170] | 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 |
---|
[8186] | 283 | !!gm end |
---|
[8170] | 284 | |
---|
[8186] | 285 | #endif |
---|
[8170] | 286 | |
---|
[8186] | 287 | !!====================================================================== |
---|
| 288 | !! identical routines in both distributed and shared memory computing |
---|
| 289 | !!====================================================================== |
---|
[6493] | 290 | |
---|
[8186] | 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 | !!---------------------------------------------------------------------- |
---|
[8170] | 303 | |
---|
[8186] | 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 | !!---------------------------------------------------------------------- |
---|
[6493] | 311 | |
---|
[8186] | 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 |
---|
[4153] | 319 | |
---|
[8186] | 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 | |
---|
[3] | 338 | !!====================================================================== |
---|
| 339 | END MODULE lbclnk |
---|
[6490] | 340 | |
---|