136
137
143
144# ifdef DISTRIBUTE
146# endif
148# ifdef DISTRIBUTE
150# endif
151
152
153
154 integer, intent(in) :: ng, tile
155 integer, intent(in) :: LBi, UBi, LBj, UBj
156 integer, intent(in) :: IminS, ImaxS, JminS, JmaxS
157 integer, intent(in) :: NTC
158
159# ifdef ASSUMED_SHAPE
160 real(r8), intent(in) :: angler(LBi:,LBj:)
161# ifdef MASKING
162 real(r8), intent(in) :: rmask(LBi:,LBj:)
163 real(r8), intent(in) :: umask(LBi:,LBj:)
164 real(r8), intent(in) :: vmask(LBi:,LBj:)
165# endif
166 real(r8), intent(in) :: Tperiod(MTC)
167# ifdef SSH_TIDES
168 real(r8), intent(in) :: SSH_Tamp(LBi:,LBj:,:)
169 real(r8), intent(in) :: SSH_Tphase(LBi:,LBj:,:)
170# endif
171# ifdef UV_TIDES
172 real(r8), intent(in) :: UV_Tangle(LBi:,LBj:,:)
173 real(r8), intent(in) :: UV_Tmajor(LBi:,LBj:,:)
174 real(r8), intent(in) :: UV_Tminor(LBi:,LBj:,:)
175 real(r8), intent(in) :: UV_Tphase(LBi:,LBj:,:)
176# endif
177# if defined AVERAGES && defined AVERAGES_DETIDE && \
178 (defined ssh_tides || defined uv_tides)
179 real(r8), intent(inout) :: SinOmega(:)
180 real(r8), intent(inout) :: CosOmega(:)
181# endif
182# else
183 real(r8), intent(in) :: angler(LBi:UBi,LBj:UBj)
184# ifdef MASKING
185 real(r8), intent(in) :: rmask(LBi:UBi,LBj:UBj)
186 real(r8), intent(in) :: umask(LBi:UBi,LBj:UBj)
187 real(r8), intent(in) :: vmask(LBi:UBi,LBj:UBj)
188# endif
189 real(r8), intent(in) :: Tperiod(MTC)
190# ifdef SSH_TIDES
191 real(r8), intent(in) :: SSH_Tamp(LBi:UBi,LBj:UBj,MTC)
192 real(r8), intent(in) :: SSH_Tphase(LBi:UBi,LBj:UBj,MTC)
193# endif
194# ifdef UV_TIDES
195 real(r8), intent(in) :: UV_Tangle(LBi:UBi,LBj:UBj,MTC)
196 real(r8), intent(in) :: UV_Tmajor(LBi:UBi,LBj:UBj,MTC)
197 real(r8), intent(in) :: UV_Tminor(LBi:UBi,LBj:UBj,MTC)
198 real(r8), intent(in) :: UV_Tphase(LBi:UBi,LBj:UBj,MTC)
199# endif
200# if defined AVERAGES && defined AVERAGES_DETIDE && \
201 (defined ssh_tides || defined uv_tides)
202 real(r8), intent(inout) :: SinOmega(MTC)
203 real(r8), intent(inout) :: CosOmega(MTC)
204# endif
205# endif
206
207
208
209 logical :: update
210
211# ifdef DISTRIBUTE
212 integer :: ILB, IUB, JLB, JUB
213# endif
214 integer :: i, itide, j
215
216 real(r8) :: Cangle, Cphase, Sangle, Sphase
217 real(r8) :: angle, cff, phase, omega, ramp
218 real(r8) :: bry_cor, bry_pgr, bry_str, bry_val
219
220 real(r8), dimension(IminS:ImaxS,JminS:JmaxS) :: Etide
221 real(r8), dimension(IminS:ImaxS,JminS:JmaxS) :: Utide
222 real(r8), dimension(IminS:ImaxS,JminS:JmaxS) :: Uwrk
223 real(r8), dimension(IminS:ImaxS,JminS:JmaxS) :: Vtide
224 real(r8), dimension(IminS:ImaxS,JminS:JmaxS) :: Vwrk
225
226# include "set_bounds.h"
227
228# ifdef DISTRIBUTE
229
230
231
236# endif
237
238
239
240
241
242
243
244
246
247
248
249# ifdef RAMP_TIDES
251# else
252 ramp=1.0_r8
253# endif
254# if defined AVERAGES && defined AVERAGES_DETIDE && \
255 (defined ssh_tides || defined uv_tides)
256
257
258
259
260
262 DO itide=1,ntc
263 IF (tperiod(itide).gt.0.0_r8) THEN
264 omega=cff/tperiod(itide)
265 sinomega(itide)=sin(omega)
266 cosomega(itide)=cos(omega)
267 ELSE
268 sinomega(itide)=0.0_r8
269 cosomega(itide)=0.0_r8
270 END IF
271 END DO
272# endif
273# ifdef SSH_TIDES
274
275
276
277
278
279 etide(:,:)=0.0_r8
281 DO itide=1,ntc
282 IF (tperiod(itide).gt.0.0_r8) THEN
283 omega=cff/tperiod(itide)
284 DO j=jstrr,jendr
285 DO i=istrr,iendr
286 etide(i,j)=etide(i,j)+ &
287 & ramp*ssh_tamp(i,j,itide)* &
288 & cos(omega-ssh_tphase(i,j,itide))
289# ifdef MASKING
290 etide(i,j)=etide(i,j)*rmask(i,j)
291# endif
292 END DO
293 END DO
294 END IF
295 END DO
296
297# ifdef ADD_FSOBC
298
299
300
302 DO j=jstrr,jendr
303 DO i=istrr,iendr
304 clima(ng)%ssh(i,j)=
clima(ng)%ssh(i,j)+etide(i,j)
305 END DO
306 END DO
309 & lbi, ubi, lbj, ubj, &
311 END IF
312# ifdef DISTRIBUTE
314 & lbi, ubi, lbj, ubj, &
318# endif
319 END IF
320# endif
321
322
323
324
325
326
327
328
329
330
331
335 update=.false.
336 IF (
domain(ng)%Western_Edge(tile))
THEN
337 DO j=jstrr,jendr
338# ifdef ADD_FSOBC
340 & 0.5_r8*(etide(istr-1,j)+ &
341 & etide(istr ,j))
342# else
343 boundary(ng)%zeta_west(j)=0.5_r8*(etide(istr-1,j)+ &
344 & etide(istr ,j))
345# endif
346 END DO
347 update=.true.
348 END IF
349# ifdef DISTRIBUTE
351 & jlb, jub, 1, 1, update, &
353# endif
354 END IF
355
359 update=.false.
360 IF (
domain(ng)%Eastern_Edge(tile))
THEN
361 DO j=jstrr,jendr
362# ifdef ADD_FSOBC
364 & 0.5_r8*(etide(iend ,j)+ &
365 & etide(iend+1,j))
366# else
367 boundary(ng)%zeta_east(j)=0.5_r8*(etide(iend ,j)+ &
368 & etide(iend+1,j))
369# endif
370 END DO
371 update=.true.
372 END IF
373# ifdef DISTRIBUTE
375 & jlb, jub, 1, 1, update, &
377# endif
378 END IF
379
383 update=.false.
384 IF (
domain(ng)%Southern_Edge(tile))
THEN
385 DO i=istrr,iendr
386# ifdef ADD_FSOBC
388 & 0.5_r8*(etide(i,jstr-1)+ &
389 & etide(i,jstr ))
390# else
391 boundary(ng)%zeta_south(i)=0.5_r8*(etide(i,jstr-1)+ &
392 & etide(i,jstr ))
393# endif
394 END DO
395 update=.true.
396 END IF
397# ifdef DISTRIBUTE
399 & ilb, iub, 1, 1, update, &
401# endif
402 END IF
403
407 update=.false.
408 IF (
domain(ng)%Northern_Edge(tile))
THEN
409 DO i=istrr,iendr
410# ifdef ADD_FSOBC
412 & 0.5_r8*(etide(i,jend )+ &
413 & etide(i,jend+1))
414# else
415 boundary(ng)%zeta_north(i)=0.5_r8*(etide(i,jend )+ &
416 & etide(i,jend+1))
417# endif
418 END DO
419 update=.true.
420 END IF
421# ifdef DISTRIBUTE
423 & ilb, iub, 1, 1, update, &
425# endif
426 END IF
427# endif
428
429# if defined UV_TIDES
430
431
432
433
434
435 utide(:,:)=0.0_r8
436 vtide(:,:)=0.0_r8
438 DO itide=1,ntc
439 IF (tperiod(itide).gt.0.0_r8) THEN
440 omega=cff/tperiod(itide)
441 DO j=min(jstrr,jstr-1),jendr
442 DO i=min(istrr,istr-1),iendr
443 angle=uv_tangle(i,j,itide)-angler(i,j)
444 cangle=cos(angle)
445 sangle=sin(angle)
446 phase=omega-uv_tphase(i,j,itide)
447 cphase=cos(phase)
448 sphase=sin(phase)
449 uwrk(i,j)=uv_tmajor(i,j,itide)*cangle*cphase- &
450 & uv_tminor(i,j,itide)*sangle*sphase
451 vwrk(i,j)=uv_tmajor(i,j,itide)*sangle*cphase+ &
452 & uv_tminor(i,j,itide)*cangle*sphase
453 END DO
454 END DO
455 DO j=jstrr,jendr
456 DO i=istr,iendr
457 utide(i,j)=utide(i,j)+ &
458 & ramp*0.5_r8*(uwrk(i-1,j)+uwrk(i,j))
459# ifdef MASKING
460 utide(i,j)=utide(i,j)*umask(i,j)
461# endif
462 END DO
463 END DO
464 DO j=jstr,jendr
465 DO i=istrr,iendr
466 vtide(i,j)=(vtide(i,j)+ &
467 & ramp*0.5_r8*(vwrk(i,j-1)+vwrk(i,j)))
468# ifdef MASKING
469 vtide(i,j)=vtide(i,j)*vmask(i,j)
470# endif
471 END DO
472 END DO
473 END IF
474 END DO
475
476# ifdef ADD_M2OBC
477
478
479
481 DO j=jstrr,jendr
482 DO i=istr,iendr
483 clima(ng)%ubarclm(i,j)=
clima(ng)%ubarclm(i,j)+utide(i,j)
484 END DO
485 END DO
486 DO j=jstr,jendr
487 DO i=istrr,iendr
488 clima(ng)%vbarclm(i,j)=
clima(ng)%vbarclm(i,j)+vtide(i,j)
489 END DO
490 END DO
493 & lbi, ubi, lbj, ubj, &
496 & lbi, ubi, lbj, ubj, &
498 END IF
499# ifdef DISTRIBUTE
501 & lbi, ubi, lbj, ubj, &
504 &
clima(ng)%ubarclm, &
506# endif
507 END IF
508# endif
509
510
511
514 update=.false.
515 IF (
domain(ng)%Western_Edge(tile))
THEN
516 DO j=jstrr,jendr
517# ifdef ADD_M2OBC
519 & utide(istr,j)
520# else
521 boundary(ng)%ubar_west(j)=utide(istr,j)
522# endif
523 END DO
524 DO j=jstr,jendr
525# ifdef ADD_M2OBC
527 & vtide(istr-1,j)
528# else
529 boundary(ng)%vbar_west(j)=vtide(istr-1,j)
530# endif
531 END DO
532 update=.true.
533 END IF
534# ifdef DISTRIBUTE
536 & jlb, jub, 1, 1, update, &
539 & jlb, jub, 1, 1, update, &
541# endif
542 END IF
543
546 update=.false.
547 IF (
domain(ng)%Eastern_Edge(tile))
THEN
548 DO j=jstrr,jendr
549# ifdef ADD_M2OBC
551 & utide(iend+1,j)
552# else
553 boundary(ng)%ubar_east(j)=utide(iend+1,j)
554# endif
555 END DO
556 DO j=jstr,jendr
557# ifdef ADD_M2OBC
559 & vtide(iend+1,j)
560# else
561 boundary(ng)%vbar_east(j)=vtide(iend+1,j)
562# endif
563 END DO
564 update=.true.
565 END IF
566# ifdef DISTRIBUTE
568 & jlb, jub, 1, 1, update, &
571 & jlb, jub, 1, 1, update, &
573# endif
574 END IF
575
578 update=.false.
579 IF (
domain(ng)%Southern_Edge(tile))
THEN
580 DO i=istr,iendr
581# ifdef ADD_M2OBC
583 & utide(i,jstr-1)
584# else
585 boundary(ng)%ubar_south(i)=utide(i,jstr-1)
586# endif
587 END DO
588 DO i=istrr,iendr
589# ifdef ADD_M2OBC
591 & vtide(i,jstr)
592# else
593 boundary(ng)%vbar_south(i)=vtide(i,jstr)
594# endif
595 END DO
596 update=.true.
597 END IF
598# ifdef DISTRIBUTE
600 & ilb, iub, 1, 1, update, &
603 & ilb, iub, 1, 1, update, &
605# endif
606 END IF
607
610 update=.false.
611 IF (
domain(ng)%Northern_Edge(tile))
THEN
612 DO i=istr,iendr
613# ifdef ADD_M2OBC
615 & utide(i,jend+1)
616# else
617 boundary(ng)%ubar_north(i)=utide(i,jend+1)
618# endif
619 END DO
620 DO i=istrr,iendr
621# ifdef ADD_M2OBC
623 & vtide(i,jend+1)
624# else
625 boundary(ng)%vbar_north(i)=vtide(i,jend+1)
626# endif
627 END DO
628 update=.true.
629 END IF
630# ifdef DISTRIBUTE
632 & ilb, iub, 1, 1, update, &
635 & ilb, iub, 1, 1, update, &
637# endif
638 END IF
639# endif
640 END IF needed
641
642 RETURN
subroutine mp_boundary(ng, model, imin, imax, lbi, ubi, lbk, ubk, update, a)
subroutine exchange_r2d_tile(ng, tile, lbi, ubi, lbj, ubj, a)
subroutine exchange_u2d_tile(ng, tile, lbi, ubi, lbj, ubj, a)
subroutine exchange_v2d_tile(ng, tile, lbi, ubi, lbj, ubj, a)
type(t_boundary), dimension(:), allocatable boundary
type(t_clima), dimension(:), allocatable clima
type(t_bounds), dimension(:), allocatable bounds
type(t_lbc), dimension(:,:,:), allocatable lbc
type(t_domain), dimension(:), allocatable domain
real(dp), parameter day2sec
logical, dimension(:), allocatable ewperiodic
logical, dimension(:), allocatable nsperiodic
logical, dimension(:), allocatable lsshclm
real(dp), dimension(:), allocatable tdays
integer, parameter isouth
logical, dimension(:), allocatable lm2clm
real(dp), dimension(:), allocatable time
integer, parameter inorth
subroutine mp_exchange2d(ng, tile, model, nvar, lbi, ubi, lbj, ubj, nghost, ew_periodic, ns_periodic, a, b, c, d)