[1125] | 1 | MODULE bdyini |
---|
| 2 | !!====================================================================== |
---|
[911] | 3 | !! *** MODULE bdyini *** |
---|
[1125] | 4 | !! Unstructured open boundaries : initialisation |
---|
| 5 | !!====================================================================== |
---|
| 6 | !! History : 1.0 ! 2005-01 (J. Chanut, A. Sellar) Original code |
---|
| 7 | !! - ! 2007-01 (D. Storkey) Update to use IOM module |
---|
| 8 | !! - ! 2007-01 (D. Storkey) Tidal forcing |
---|
| 9 | !! 3.0 ! 2008-04 (NEMO team) add in the reference version |
---|
[2528] | 10 | !! 3.3 ! 2010-09 (E.O'Dea) updates for Shelf configurations |
---|
| 11 | !! 3.3 ! 2010-09 (D.Storkey) add ice boundary conditions |
---|
[1125] | 12 | !!---------------------------------------------------------------------- |
---|
| 13 | #if defined key_bdy |
---|
| 14 | !!---------------------------------------------------------------------- |
---|
| 15 | !! 'key_bdy' Unstructured Open Boundary Conditions |
---|
| 16 | !!---------------------------------------------------------------------- |
---|
[911] | 17 | !! bdy_init : Initialization of unstructured open boundaries |
---|
[1125] | 18 | !!---------------------------------------------------------------------- |
---|
[911] | 19 | USE oce ! ocean dynamics and tracers variables |
---|
| 20 | USE dom_oce ! ocean space and time domain |
---|
[2528] | 21 | USE obc_par ! ocean open boundary conditions |
---|
[911] | 22 | USE bdy_oce ! unstructured open boundary conditions |
---|
[2715] | 23 | USE bdydta, ONLY: bdy_dta_alloc ! open boundary data |
---|
[911] | 24 | USE bdytides ! tides at open boundaries initialization (tide_init routine) |
---|
| 25 | USE in_out_manager ! I/O units |
---|
| 26 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
| 27 | USE lib_mpp ! for mpp_sum |
---|
| 28 | USE iom ! I/O |
---|
| 29 | |
---|
| 30 | IMPLICIT NONE |
---|
| 31 | PRIVATE |
---|
| 32 | |
---|
[1125] | 33 | PUBLIC bdy_init ! routine called by opa.F90 |
---|
[911] | 34 | |
---|
[1125] | 35 | !!---------------------------------------------------------------------- |
---|
[2715] | 36 | !! NEMO/OPA 4.0 , NEMO Consortium (2011) |
---|
[1146] | 37 | !! $Id$ |
---|
[2715] | 38 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[2528] | 39 | !!---------------------------------------------------------------------- |
---|
[911] | 40 | CONTAINS |
---|
| 41 | |
---|
| 42 | SUBROUTINE bdy_init |
---|
| 43 | !!---------------------------------------------------------------------- |
---|
| 44 | !! *** ROUTINE bdy_init *** |
---|
| 45 | !! |
---|
| 46 | !! ** Purpose : Initialization of the dynamics and tracer fields with |
---|
[2715] | 47 | !! unstructured open boundaries. |
---|
[911] | 48 | !! |
---|
[2715] | 49 | !! ** Method : Read initialization arrays (mask, indices) to identify |
---|
| 50 | !! an unstructured open boundary |
---|
[911] | 51 | !! |
---|
| 52 | !! ** Input : bdy_init.nc, input file for unstructured open boundaries |
---|
| 53 | !!---------------------------------------------------------------------- |
---|
[2715] | 54 | INTEGER :: ii, ij, ik, igrd, ib, ir ! dummy loop indices |
---|
| 55 | INTEGER :: icount, icountr, ib_len, ibr_max ! local integers |
---|
| 56 | INTEGER :: iw, ie, is, in, inum, id_dummy ! - - |
---|
| 57 | INTEGER :: igrd_start, igrd_end ! - - |
---|
| 58 | REAL(wp) :: zefl, zwfl, znfl, zsfl ! local scalars |
---|
[1125] | 59 | INTEGER, DIMENSION (2) :: kdimsz |
---|
| 60 | INTEGER, DIMENSION(jpbdta, jpbgrd) :: nbidta, nbjdta ! Index arrays: i and j indices of bdy dta |
---|
| 61 | INTEGER, DIMENSION(jpbdta, jpbgrd) :: nbrdta ! Discrete distance from rim points |
---|
[2715] | 62 | REAL(wp), DIMENSION(jpidta,jpjdta) :: zmask ! global domain mask |
---|
| 63 | REAL(wp), DIMENSION(jpbdta,1) :: zdta ! temporary array |
---|
| 64 | CHARACTER(LEN=80),DIMENSION(6) :: clfile |
---|
[1125] | 65 | !! |
---|
[2715] | 66 | NAMELIST/nambdy/cn_mask, cn_dta_frs_T, cn_dta_frs_U, cn_dta_frs_V, & |
---|
| 67 | & cn_dta_fla_T, cn_dta_fla_U, cn_dta_fla_V, & |
---|
| 68 | & ln_tides, ln_clim, ln_vol, ln_mask, & |
---|
| 69 | & ln_dyn_fla, ln_dyn_frs, ln_tra_frs,ln_ice_frs, & |
---|
[2528] | 70 | & nn_dtactl, nn_rimwidth, nn_volctl |
---|
[911] | 71 | !!---------------------------------------------------------------------- |
---|
| 72 | |
---|
| 73 | IF(lwp) WRITE(numout,*) |
---|
| 74 | IF(lwp) WRITE(numout,*) 'bdy_init : initialization of unstructured open boundaries' |
---|
| 75 | IF(lwp) WRITE(numout,*) '~~~~~~~~' |
---|
[1125] | 76 | ! |
---|
[2715] | 77 | ! ! allocate bdy_oce arrays |
---|
| 78 | IF( bdy_oce_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'bdy_init : unable to allocate oce arrays' ) |
---|
| 79 | IF( bdy_dta_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'bdy_init : unable to allocate dta arrays' ) |
---|
| 80 | |
---|
[2528] | 81 | IF( jperio /= 0 ) CALL ctl_stop( 'Cyclic or symmetric,', & |
---|
| 82 | & ' and unstructured open boundary condition are not compatible' ) |
---|
[911] | 83 | |
---|
[2528] | 84 | IF( lk_obc ) CALL ctl_stop( 'Straight open boundaries,', & |
---|
| 85 | & ' and unstructured open boundaries are not compatible' ) |
---|
[911] | 86 | |
---|
| 87 | ! --------------------------- |
---|
[2528] | 88 | REWIND( numnam ) ! Read namelist parameters |
---|
[911] | 89 | READ ( numnam, nambdy ) |
---|
| 90 | |
---|
[2528] | 91 | ! ! control prints |
---|
[911] | 92 | IF(lwp) WRITE(numout,*) ' nambdy' |
---|
| 93 | |
---|
[2528] | 94 | ! ! check type of data used (nn_dtactl value) |
---|
| 95 | IF(lwp) WRITE(numout,*) 'nn_dtactl =', nn_dtactl |
---|
| 96 | IF(lwp) WRITE(numout,*) |
---|
| 97 | SELECT CASE( nn_dtactl ) ! |
---|
| 98 | CASE( 0 ) ; IF(lwp) WRITE(numout,*) ' initial state used for bdy data' |
---|
| 99 | CASE( 1 ) ; IF(lwp) WRITE(numout,*) ' boundary data taken from file' |
---|
| 100 | CASE DEFAULT ; CALL ctl_stop( 'nn_dtactl must be 0 or 1' ) |
---|
[1125] | 101 | END SELECT |
---|
[911] | 102 | |
---|
[2528] | 103 | IF(lwp) WRITE(numout,*) |
---|
| 104 | IF(lwp) WRITE(numout,*) 'Boundary rim width for the FRS nn_rimwidth = ', nn_rimwidth |
---|
[911] | 105 | |
---|
[2528] | 106 | IF(lwp) WRITE(numout,*) |
---|
| 107 | IF(lwp) WRITE(numout,*) ' nn_volctl = ', nn_volctl |
---|
[1125] | 108 | |
---|
[2528] | 109 | IF( ln_vol ) THEN ! check volume conservation (nn_volctl value) |
---|
| 110 | SELECT CASE ( nn_volctl ) |
---|
| 111 | CASE( 1 ) ; IF(lwp) WRITE(numout,*) ' The total volume will be constant' |
---|
| 112 | CASE( 0 ) ; IF(lwp) WRITE(numout,*) ' The total volume will vary according to the surface E-P flux' |
---|
| 113 | CASE DEFAULT ; CALL ctl_stop( 'nn_volctl must be 0 or 1' ) |
---|
| 114 | END SELECT |
---|
| 115 | IF(lwp) WRITE(numout,*) |
---|
[911] | 116 | ELSE |
---|
[2528] | 117 | IF(lwp) WRITE(numout,*) 'No volume correction with unstructured open boundaries' |
---|
| 118 | IF(lwp) WRITE(numout,*) |
---|
[911] | 119 | ENDIF |
---|
| 120 | |
---|
[2528] | 121 | IF( ln_tides ) THEN |
---|
[1125] | 122 | IF(lwp) WRITE(numout,*) 'Tidal harmonic forcing at unstructured open boundaries' |
---|
[2528] | 123 | IF(lwp) WRITE(numout,*) |
---|
[1125] | 124 | ENDIF |
---|
| 125 | |
---|
[2528] | 126 | IF( ln_dyn_fla ) THEN |
---|
[1125] | 127 | IF(lwp) WRITE(numout,*) 'Flather condition on U, V at unstructured open boundaries' |
---|
[2528] | 128 | IF(lwp) WRITE(numout,*) |
---|
[911] | 129 | ENDIF |
---|
| 130 | |
---|
[2528] | 131 | IF( ln_dyn_frs ) THEN |
---|
[1125] | 132 | IF(lwp) WRITE(numout,*) 'FRS condition on U and V at unstructured open boundaries' |
---|
[2528] | 133 | IF(lwp) WRITE(numout,*) |
---|
[1125] | 134 | ENDIF |
---|
| 135 | |
---|
[2528] | 136 | IF( ln_tra_frs ) THEN |
---|
[1125] | 137 | IF(lwp) WRITE(numout,*) 'FRS condition on T & S fields at unstructured open boundaries' |
---|
[2528] | 138 | IF(lwp) WRITE(numout,*) |
---|
[1125] | 139 | ENDIF |
---|
| 140 | |
---|
[2528] | 141 | IF( ln_ice_frs ) THEN |
---|
| 142 | IF(lwp) WRITE(numout,*) 'FRS condition on ice fields at unstructured open boundaries' |
---|
| 143 | IF(lwp) WRITE(numout,*) |
---|
| 144 | ENDIF |
---|
[911] | 145 | |
---|
[2528] | 146 | IF( ln_tides ) CALL tide_init ! Read tides namelist |
---|
| 147 | |
---|
| 148 | |
---|
[1125] | 149 | ! Read arrays defining unstructured open boundaries |
---|
| 150 | ! ------------------------------------------------- |
---|
[911] | 151 | |
---|
[1125] | 152 | ! Read global 2D mask at T-points: bdytmask |
---|
| 153 | ! ***************************************** |
---|
| 154 | ! bdytmask = 1 on the computational domain AND on open boundaries |
---|
| 155 | ! = 0 elsewhere |
---|
[911] | 156 | |
---|
[2528] | 157 | IF( cp_cfg == "eel" .AND. jp_cfg == 5 ) THEN ! EEL configuration at 5km resolution |
---|
[1125] | 158 | zmask( : ,:) = 0.e0 |
---|
| 159 | zmask(jpizoom+1:jpizoom+jpiglo-2,:) = 1.e0 |
---|
[2528] | 160 | ELSE IF( ln_mask ) THEN |
---|
| 161 | CALL iom_open( cn_mask, inum ) |
---|
[1125] | 162 | CALL iom_get ( inum, jpdom_data, 'bdy_msk', zmask(:,:) ) |
---|
| 163 | CALL iom_close( inum ) |
---|
[911] | 164 | ELSE |
---|
[1125] | 165 | zmask(:,:) = 1.e0 |
---|
[911] | 166 | ENDIF |
---|
| 167 | |
---|
[2528] | 168 | DO ij = 1, nlcj ! Save mask over local domain |
---|
[1125] | 169 | DO ii = 1, nlci |
---|
| 170 | bdytmask(ii,ij) = zmask( mig(ii), mjg(ij) ) |
---|
| 171 | END DO |
---|
[911] | 172 | END DO |
---|
| 173 | |
---|
| 174 | ! Derive mask on U and V grid from mask on T grid |
---|
[1125] | 175 | bdyumask(:,:) = 0.e0 |
---|
| 176 | bdyvmask(:,:) = 0.e0 |
---|
| 177 | DO ij=1, jpjm1 |
---|
| 178 | DO ii=1, jpim1 |
---|
| 179 | bdyumask(ii,ij)=bdytmask(ii,ij)*bdytmask(ii+1, ij ) |
---|
| 180 | bdyvmask(ii,ij)=bdytmask(ii,ij)*bdytmask(ii ,ij+1) |
---|
| 181 | END DO |
---|
[911] | 182 | END DO |
---|
[2528] | 183 | CALL lbc_lnk( bdyumask(:,:), 'U', 1. ) ; CALL lbc_lnk( bdyvmask(:,:), 'V', 1. ) ! Lateral boundary cond. |
---|
[911] | 184 | |
---|
| 185 | |
---|
[1125] | 186 | ! Read discrete distance and mapping indices |
---|
| 187 | ! ****************************************** |
---|
| 188 | nbidta(:,:) = 0.e0 |
---|
| 189 | nbjdta(:,:) = 0.e0 |
---|
| 190 | nbrdta(:,:) = 0.e0 |
---|
[911] | 191 | |
---|
| 192 | IF( cp_cfg == "eel" .AND. jp_cfg == 5 ) THEN |
---|
[1125] | 193 | icount = 0 |
---|
[2528] | 194 | DO ir = 1, nn_rimwidth ! Define west boundary (from ii=2 to ii=1+nn_rimwidth): |
---|
[1125] | 195 | DO ij = 3, jpjglo-2 |
---|
[2528] | 196 | icount = icount + 1 |
---|
[1125] | 197 | nbidta(icount,:) = ir + 1 + (jpizoom-1) |
---|
[2528] | 198 | nbjdta(icount,:) = ij + (jpjzoom-1) |
---|
[1125] | 199 | nbrdta(icount,:) = ir |
---|
| 200 | END DO |
---|
| 201 | END DO |
---|
[2528] | 202 | ! |
---|
| 203 | DO ir = 1, nn_rimwidth ! Define east boundary (from ii=jpiglo-1 to ii=jpiglo-nn_rimwidth): |
---|
[1125] | 204 | DO ij=3,jpjglo-2 |
---|
[2528] | 205 | icount = icount + 1 |
---|
[1125] | 206 | nbidta(icount,:) = jpiglo-ir + (jpizoom-1) |
---|
| 207 | nbidta(icount,2) = jpiglo-ir-1 + (jpizoom-1) ! special case for u points |
---|
| 208 | nbjdta(icount,:) = ij + (jpjzoom-1) |
---|
| 209 | nbrdta(icount,:) = ir |
---|
| 210 | END DO |
---|
| 211 | END DO |
---|
[2528] | 212 | ! |
---|
[1125] | 213 | ELSE ! Read indices and distances in unstructured boundary data files |
---|
[2528] | 214 | ! |
---|
| 215 | IF( ln_tides ) THEN ! Read tides input files for preference in case there are no bdydata files |
---|
| 216 | clfile(4) = TRIM(filtide)//TRIM(tide_cpt(1))//'_grid_T.nc' |
---|
| 217 | clfile(5) = TRIM(filtide)//TRIM(tide_cpt(1))//'_grid_U.nc' |
---|
| 218 | clfile(6) = TRIM(filtide)//TRIM(tide_cpt(1))//'_grid_V.nc' |
---|
| 219 | ENDIF |
---|
| 220 | IF( ln_dyn_fla .AND. .NOT. ln_tides ) THEN |
---|
| 221 | clfile(4) = cn_dta_fla_T |
---|
| 222 | clfile(5) = cn_dta_fla_U |
---|
| 223 | clfile(6) = cn_dta_fla_V |
---|
| 224 | ENDIF |
---|
[911] | 225 | |
---|
[2528] | 226 | IF( ln_tra_frs ) THEN |
---|
| 227 | clfile(1) = cn_dta_frs_T |
---|
| 228 | IF( .NOT. ln_dyn_frs ) THEN |
---|
| 229 | clfile(2) = cn_dta_frs_T ! Dummy read re read T file for sake of 6 files |
---|
| 230 | clfile(3) = cn_dta_frs_T ! |
---|
| 231 | ENDIF |
---|
[1125] | 232 | ENDIF |
---|
[2528] | 233 | IF( ln_dyn_frs ) THEN |
---|
| 234 | IF( .NOT. ln_tra_frs ) clfile(1) = cn_dta_frs_U ! Dummy Read |
---|
| 235 | clfile(2) = cn_dta_frs_U |
---|
| 236 | clfile(3) = cn_dta_frs_V |
---|
| 237 | ENDIF |
---|
[911] | 238 | |
---|
[2528] | 239 | ! ! how many files are we to read in? |
---|
| 240 | IF(ln_tides .OR. ln_dyn_fla) igrd_start = 4 |
---|
| 241 | ! |
---|
| 242 | IF(ln_tra_frs ) THEN ; igrd_start = 1 |
---|
| 243 | ELSEIF(ln_dyn_frs) THEN ; igrd_start = 2 |
---|
[1125] | 244 | ENDIF |
---|
[2528] | 245 | ! |
---|
| 246 | IF( ln_tra_frs ) igrd_end = 1 |
---|
| 247 | ! |
---|
| 248 | IF(ln_dyn_fla .OR. ln_tides) THEN ; igrd_end = 6 |
---|
| 249 | ELSEIF( ln_dyn_frs ) THEN ; igrd_end = 3 |
---|
| 250 | ENDIF |
---|
[911] | 251 | |
---|
[1125] | 252 | DO igrd = igrd_start, igrd_end |
---|
| 253 | CALL iom_open( clfile(igrd), inum ) |
---|
| 254 | id_dummy = iom_varid( inum, 'nbidta', kdimsz=kdimsz ) |
---|
[2528] | 255 | IF(lwp) WRITE(numout,*) 'kdimsz : ',kdimsz |
---|
[1125] | 256 | ib_len = kdimsz(1) |
---|
[2528] | 257 | IF( ib_len > jpbdta) CALL ctl_stop( 'Boundary data array in file too long.', & |
---|
| 258 | & 'File :', TRIM(clfile(igrd)),'increase parameter jpbdta.' ) |
---|
[911] | 259 | |
---|
[1125] | 260 | CALL iom_get( inum, jpdom_unknown, 'nbidta', zdta(1:ib_len,:) ) |
---|
| 261 | DO ii = 1,ib_len |
---|
| 262 | nbidta(ii,igrd) = INT( zdta(ii,1) ) |
---|
| 263 | END DO |
---|
| 264 | CALL iom_get( inum, jpdom_unknown, 'nbjdta', zdta(1:ib_len,:) ) |
---|
| 265 | DO ii = 1,ib_len |
---|
[2528] | 266 | nbjdta(ii,igrd) = INT( zdta(ii,1) ) |
---|
[1125] | 267 | END DO |
---|
[2528] | 268 | CALL iom_get( inum, jpdom_unknown, 'nbrdta', zdta(1:ib_len,:) ) |
---|
[1125] | 269 | DO ii = 1,ib_len |
---|
[2528] | 270 | nbrdta(ii,igrd) = INT( zdta(ii,1) ) |
---|
[1125] | 271 | END DO |
---|
| 272 | CALL iom_close( inum ) |
---|
[911] | 273 | |
---|
[2528] | 274 | IF( igrd < 4) THEN ! Check that rimwidth in file is big enough for Frs case(barotropic is one): |
---|
| 275 | ibr_max = MAXVAL( nbrdta(:,igrd) ) |
---|
| 276 | IF(lwp) WRITE(numout,*) |
---|
| 277 | IF(lwp) WRITE(numout,*) ' Maximum rimwidth in file is ', ibr_max |
---|
| 278 | IF(lwp) WRITE(numout,*) ' nn_rimwidth from namelist is ', nn_rimwidth |
---|
| 279 | IF (ibr_max < nn_rimwidth) CALL ctl_stop( 'nn_rimwidth is larger than maximum rimwidth in file' ) |
---|
| 280 | ENDIF !Check igrd < 4 |
---|
[1125] | 281 | ! |
---|
| 282 | END DO |
---|
| 283 | ! |
---|
| 284 | ENDIF |
---|
[911] | 285 | |
---|
[1125] | 286 | ! Dispatch mapping indices and discrete distances on each processor |
---|
| 287 | ! ***************************************************************** |
---|
[911] | 288 | |
---|
[1125] | 289 | iw = mig(1) + 1 ! if monotasking and no zoom, iw=2 |
---|
| 290 | ie = mig(1) + nlci-1 - 1 ! if monotasking and no zoom, ie=jpim1 |
---|
| 291 | is = mjg(1) + 1 ! if monotasking and no zoom, is=2 |
---|
| 292 | in = mjg(1) + nlcj-1 - 1 ! if monotasking and no zoom, in=jpjm1 |
---|
[911] | 293 | |
---|
[1125] | 294 | DO igrd = igrd_start, igrd_end |
---|
[2528] | 295 | icount = 0 |
---|
| 296 | icountr = 0 |
---|
| 297 | nblen (igrd) = 0 |
---|
| 298 | nblenrim(igrd) = 0 |
---|
| 299 | nblendta(igrd) = 0 |
---|
| 300 | DO ir=1, nn_rimwidth |
---|
| 301 | DO ib = 1, jpbdta |
---|
| 302 | ! check if point is in local domain and equals ir |
---|
| 303 | IF( nbidta(ib,igrd) >= iw .AND. nbidta(ib,igrd) <= ie .AND. & |
---|
| 304 | & nbjdta(ib,igrd) >= is .AND. nbjdta(ib,igrd) <= in .AND. & |
---|
| 305 | & nbrdta(ib,igrd) == ir ) THEN |
---|
| 306 | ! |
---|
| 307 | icount = icount + 1 |
---|
| 308 | ! |
---|
| 309 | IF( ir == 1 ) icountr = icountr+1 |
---|
[1125] | 310 | IF (icount > jpbdim) THEN |
---|
| 311 | IF(lwp) WRITE(numout,*) 'bdy_ini: jpbdim too small' |
---|
| 312 | nstop = nstop + 1 |
---|
| 313 | ELSE |
---|
| 314 | nbi(icount, igrd) = nbidta(ib,igrd)- mig(1)+1 |
---|
| 315 | nbj(icount, igrd) = nbjdta(ib,igrd)- mjg(1)+1 |
---|
| 316 | nbr(icount, igrd) = nbrdta(ib,igrd) |
---|
| 317 | nbmap(icount,igrd) = ib |
---|
| 318 | ENDIF |
---|
| 319 | ENDIF |
---|
| 320 | END DO |
---|
| 321 | END DO |
---|
| 322 | nblenrim(igrd) = icountr !: length of rim boundary data on each proc |
---|
| 323 | nblen (igrd) = icount !: length of boundary data on each proc |
---|
[911] | 324 | END DO |
---|
| 325 | |
---|
[1125] | 326 | ! Compute rim weights |
---|
| 327 | ! ------------------- |
---|
| 328 | DO igrd = igrd_start, igrd_end |
---|
| 329 | DO ib = 1, nblen(igrd) |
---|
[2528] | 330 | nbw(ib,igrd) = 1.- TANH( FLOAT( nbr(ib,igrd) - 1 ) *0.5 ) ! tanh formulation |
---|
| 331 | ! nbw(ib,igrd) = (FLOAT(nn_rimwidth+1-nbr(ib,igrd))/FLOAT(nn_rimwidth))**2 ! quadratic |
---|
| 332 | ! nbw(ib,igrd) = FLOAT(nn_rimwidth+1-nbr(ib,igrd))/FLOAT(nn_rimwidth) ! linear |
---|
[1125] | 333 | END DO |
---|
[911] | 334 | END DO |
---|
| 335 | |
---|
[1125] | 336 | ! Mask corrections |
---|
| 337 | ! ---------------- |
---|
| 338 | DO ik = 1, jpkm1 |
---|
| 339 | DO ij = 1, jpj |
---|
| 340 | DO ii = 1, jpi |
---|
| 341 | tmask(ii,ij,ik) = tmask(ii,ij,ik) * bdytmask(ii,ij) |
---|
| 342 | umask(ii,ij,ik) = umask(ii,ij,ik) * bdyumask(ii,ij) |
---|
| 343 | vmask(ii,ij,ik) = vmask(ii,ij,ik) * bdyvmask(ii,ij) |
---|
| 344 | bmask(ii,ij) = bmask(ii,ij) * bdytmask(ii,ij) |
---|
| 345 | END DO |
---|
| 346 | END DO |
---|
[911] | 347 | END DO |
---|
| 348 | |
---|
[1125] | 349 | DO ik = 1, jpkm1 |
---|
| 350 | DO ij = 2, jpjm1 |
---|
| 351 | DO ii = 2, jpim1 |
---|
| 352 | fmask(ii,ij,ik) = fmask(ii,ij,ik) * bdytmask(ii,ij ) * bdytmask(ii+1,ij ) & |
---|
| 353 | & * bdytmask(ii,ij+1) * bdytmask(ii+1,ij+1) |
---|
| 354 | END DO |
---|
| 355 | END DO |
---|
[911] | 356 | END DO |
---|
| 357 | |
---|
[1125] | 358 | tmask_i (:,:) = tmask(:,:,1) * tmask_i(:,:) |
---|
| 359 | bdytmask(:,:) = tmask(:,:,1) |
---|
[911] | 360 | |
---|
| 361 | ! bdy masks and bmask are now set to zero on boundary points: |
---|
[1125] | 362 | igrd = 1 ! In the free surface case, bmask is at T-points |
---|
| 363 | DO ib = 1, nblenrim(igrd) |
---|
| 364 | bmask(nbi(ib,igrd), nbj(ib,igrd)) = 0.e0 |
---|
[911] | 365 | END DO |
---|
[1125] | 366 | ! |
---|
| 367 | igrd = 1 |
---|
| 368 | DO ib = 1, nblenrim(igrd) |
---|
| 369 | bdytmask(nbi(ib,igrd), nbj(ib,igrd)) = 0.e0 |
---|
[911] | 370 | END DO |
---|
[1125] | 371 | ! |
---|
| 372 | igrd = 2 |
---|
| 373 | DO ib = 1, nblenrim(igrd) |
---|
| 374 | bdyumask(nbi(ib,igrd), nbj(ib,igrd)) = 0.e0 |
---|
[911] | 375 | END DO |
---|
[1125] | 376 | ! |
---|
| 377 | igrd = 3 |
---|
| 378 | DO ib = 1, nblenrim(igrd) |
---|
| 379 | bdyvmask(nbi(ib,igrd), nbj(ib,igrd)) = 0.e0 |
---|
[911] | 380 | END DO |
---|
| 381 | |
---|
[1125] | 382 | ! Lateral boundary conditions |
---|
[2528] | 383 | CALL lbc_lnk( fmask , 'F', 1. ) ; CALL lbc_lnk( bdytmask(:,:), 'T', 1. ) |
---|
| 384 | CALL lbc_lnk( bdyumask(:,:), 'U', 1. ) ; CALL lbc_lnk( bdyvmask(:,:), 'V', 1. ) |
---|
[911] | 385 | |
---|
[2528] | 386 | IF( ln_vol .OR. ln_dyn_fla ) THEN ! Indices and directions of rim velocity components |
---|
[1125] | 387 | ! |
---|
| 388 | !flagu = -1 : u component is normal to the dynamical boundary but its direction is outward |
---|
| 389 | !flagu = 0 : u is tangential |
---|
| 390 | !flagu = 1 : u is normal to the boundary and is direction is inward |
---|
| 391 | icount = 0 |
---|
| 392 | flagu(:) = 0.e0 |
---|
[911] | 393 | |
---|
[1125] | 394 | igrd = 2 ! u-component |
---|
| 395 | DO ib = 1, nblenrim(igrd) |
---|
| 396 | zefl=bdytmask(nbi(ib,igrd) , nbj(ib,igrd)) |
---|
| 397 | zwfl=bdytmask(nbi(ib,igrd)+1, nbj(ib,igrd)) |
---|
| 398 | IF( zefl + zwfl ==2 ) THEN |
---|
| 399 | icount = icount +1 |
---|
| 400 | ELSE |
---|
| 401 | flagu(ib)=-zefl+zwfl |
---|
| 402 | ENDIF |
---|
| 403 | END DO |
---|
[911] | 404 | |
---|
[1125] | 405 | !flagv = -1 : u component is normal to the dynamical boundary but its direction is outward |
---|
| 406 | !flagv = 0 : u is tangential |
---|
| 407 | !flagv = 1 : u is normal to the boundary and is direction is inward |
---|
| 408 | flagv(:) = 0.e0 |
---|
[911] | 409 | |
---|
[1125] | 410 | igrd = 3 ! v-component |
---|
| 411 | DO ib = 1, nblenrim(igrd) |
---|
| 412 | znfl = bdytmask(nbi(ib,igrd), nbj(ib,igrd)) |
---|
| 413 | zsfl = bdytmask(nbi(ib,igrd), nbj(ib,igrd)+1) |
---|
| 414 | IF( znfl + zsfl ==2 ) THEN |
---|
| 415 | icount = icount + 1 |
---|
| 416 | ELSE |
---|
| 417 | flagv(ib) = -znfl + zsfl |
---|
| 418 | END IF |
---|
| 419 | END DO |
---|
[911] | 420 | |
---|
[1125] | 421 | IF( icount /= 0 ) THEN |
---|
| 422 | IF(lwp) WRITE(numout,*) |
---|
| 423 | IF(lwp) WRITE(numout,*) ' E R R O R : Some data velocity points,', & |
---|
| 424 | ' are not boundary points. Check nbi, nbj, indices.' |
---|
| 425 | IF(lwp) WRITE(numout,*) ' ========== ' |
---|
| 426 | IF(lwp) WRITE(numout,*) |
---|
| 427 | nstop = nstop + 1 |
---|
| 428 | ENDIF |
---|
[911] | 429 | |
---|
[1125] | 430 | ENDIF |
---|
[911] | 431 | |
---|
[1125] | 432 | ! Compute total lateral surface for volume correction: |
---|
| 433 | ! ---------------------------------------------------- |
---|
[911] | 434 | bdysurftot = 0.e0 |
---|
[2528] | 435 | IF( ln_vol ) THEN |
---|
[1125] | 436 | igrd = 2 ! Lateral surface at U-points |
---|
| 437 | DO ib = 1, nblenrim(igrd) |
---|
| 438 | bdysurftot = bdysurftot + hu (nbi(ib,igrd) ,nbj(ib,igrd)) & |
---|
| 439 | & * e2u (nbi(ib,igrd) ,nbj(ib,igrd)) * ABS( flagu(ib) ) & |
---|
| 440 | & * tmask_i(nbi(ib,igrd) ,nbj(ib,igrd)) & |
---|
| 441 | & * tmask_i(nbi(ib,igrd)+1,nbj(ib,igrd)) |
---|
| 442 | END DO |
---|
[911] | 443 | |
---|
[1125] | 444 | igrd=3 ! Add lateral surface at V-points |
---|
| 445 | DO ib = 1, nblenrim(igrd) |
---|
| 446 | bdysurftot = bdysurftot + hv (nbi(ib,igrd),nbj(ib,igrd) ) & |
---|
| 447 | & * e1v (nbi(ib,igrd),nbj(ib,igrd) ) * ABS( flagv(ib) ) & |
---|
| 448 | & * tmask_i(nbi(ib,igrd),nbj(ib,igrd) ) & |
---|
| 449 | & * tmask_i(nbi(ib,igrd),nbj(ib,igrd)+1) |
---|
| 450 | END DO |
---|
[2528] | 451 | ! |
---|
[1125] | 452 | IF( lk_mpp ) CALL mpp_sum( bdysurftot ) ! sum over the global domain |
---|
[911] | 453 | END IF |
---|
| 454 | |
---|
[1125] | 455 | ! Initialise bdy data arrays |
---|
| 456 | ! -------------------------- |
---|
[911] | 457 | tbdy(:,:) = 0.e0 |
---|
| 458 | sbdy(:,:) = 0.e0 |
---|
| 459 | ubdy(:,:) = 0.e0 |
---|
| 460 | vbdy(:,:) = 0.e0 |
---|
| 461 | sshbdy(:) = 0.e0 |
---|
| 462 | ubtbdy(:) = 0.e0 |
---|
| 463 | vbtbdy(:) = 0.e0 |
---|
[2528] | 464 | #if defined key_lim2 |
---|
| 465 | frld_bdy(:) = 0.e0 |
---|
| 466 | hicif_bdy(:) = 0.e0 |
---|
| 467 | hsnif_bdy(:) = 0.e0 |
---|
| 468 | #endif |
---|
[911] | 469 | |
---|
[1125] | 470 | ! Read in tidal constituents and adjust for model start time |
---|
| 471 | ! ---------------------------------------------------------- |
---|
[2528] | 472 | IF( ln_tides ) CALL tide_data |
---|
[1125] | 473 | ! |
---|
[911] | 474 | END SUBROUTINE bdy_init |
---|
| 475 | |
---|
| 476 | #else |
---|
| 477 | !!--------------------------------------------------------------------------------- |
---|
| 478 | !! Dummy module NO unstructured open boundaries |
---|
| 479 | !!--------------------------------------------------------------------------------- |
---|
| 480 | CONTAINS |
---|
| 481 | SUBROUTINE bdy_init ! Dummy routine |
---|
| 482 | END SUBROUTINE bdy_init |
---|
| 483 | #endif |
---|
| 484 | |
---|
| 485 | !!================================================================================= |
---|
| 486 | END MODULE bdyini |
---|