This subroutine determines the acceleration due to the horizontal viscosity. A combination of biharmonic and Laplacian forms can be used. The coefficient may either be a constant or a shear-dependent form. The biharmonic is determined by twice taking the divergence of an appropriately defined stress tensor. The Laplacian is determined by doing so once. To work, the following fields must be set outside of the usual is to ie range before this subroutine is called: v[is-2,is-1,ie+1,ie+2], u[is-2,is-1,ie+1,ie+2], and h[is-1,ie+1], with a similarly sized halo in the y-direction.
233 type(verticalgrid_type),
intent(in) :: gv
234 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
236 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)), &
238 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
241 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
244 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)), &
247 type(meke_type),
pointer :: meke
249 type(varmix_cs),
pointer :: varmix
251 type(hor_visc_cs),
pointer :: cs
253 type(ocean_obc_type),
pointer,
optional :: obc
285 real,
dimension(SZIB_(G),SZJ_(G)) :: &
288 real,
dimension(SZI_(G),SZJB_(G)) :: &
292 real,
dimension(SZI_(G),SZJ_(G)) :: &
299 real,
dimension(SZIB_(G),SZJB_(G)) :: &
306 real,
dimension(SZI_(G),SZJB_(G)) :: &
310 real,
dimension(SZIB_(G),SZJ_(G)) :: &
314 real,
dimension(SZIB_(G),SZJB_(G),SZK_(G)) :: &
318 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)) :: &
345 real :: visc_bound_rem
352 logical :: rescale_kh
353 logical :: find_frictwork
354 logical :: apply_obc = .false.
355 logical :: use_meke_ku
356 integer :: is, ie, js, je, isq, ieq, jsq, jeq, nz
357 integer :: i, j, k, n
359 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
360 isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
362 h_neglect = gv%H_subroundoff
363 h_neglect3 = h_neglect**3
365 if (
present(obc))
then ;
if (
associated(obc))
then ;
if (obc%OBC_pe)
then 366 apply_obc = obc%Flather_u_BCs_exist_globally .or. obc%Flather_v_BCs_exist_globally
368 endif ;
endif ;
endif 370 if (.not.
associated(cs))
call mom_error(fatal, &
371 "MOM_hor_visc: Module must be initialized before it is used.")
372 if (.not.(cs%Laplacian .or. cs%biharmonic))
return 374 find_frictwork = (cs%id_FrictWork > 0)
375 if (cs%id_FrictWorkIntz > 0) find_frictwork = .true.
376 if (
associated(meke))
then 377 if (
associated(meke%mom_src)) find_frictwork = .true.
381 if (
associated(varmix))
then 382 rescale_kh = varmix%Resoln_scaled_Kh
383 if (rescale_kh .and. &
384 (.not.
associated(varmix%Res_fn_h) .or. .not.
associated(varmix%Res_fn_q))) &
385 call mom_error(fatal,
"MOM_hor_visc: VarMix%Res_fn_h and " //&
386 "VarMix%Res_fn_q both need to be associated with Resoln_scaled_Kh.")
390 use_meke_ku =
associated(meke%Ku)
417 do j=jsq-1,jeq+2 ;
do i=isq-1,ieq+2
418 sh_xx(i,j) = (cs%DY_dxT(i,j)*(g%IdyCu(i,j) * u(i,j,k) - &
419 g%IdyCu(i-1,j) * u(i-1,j,k)) - &
420 cs%DX_dyT(i,j)*(g%IdxCv(i,j) * v(i,j,k) - &
421 g%IdxCv(i,j-1)*v(i,j-1,k)))
422 div_xx(i,j) = 0.5*((g%dyCu(i,j) * u(i,j,k) * (h(i+1,j,k)+h(i,j,k)) - &
423 g%dyCu(i-1,j) * u(i-1,j,k) * (h(i-1,j,k)+h(i,j,k)) ) + &
424 (g%dxCv(i,j) * v(i,j,k) * (h(i,j,k)+h(i,j+1,k)) - &
425 g%dxCv(i,j-1)*v(i,j-1,k)*(h(i,j,k)+h(i,j-1,k))))*g%IareaT(i,j)/ &
426 (h(i,j,k) + h_neglect)
429 do j=js-2,jeq+1 ;
do i=is-2,ieq+1
430 dvdx(i,j) = cs%DY_dxBu(i,j)*(v(i+1,j,k)*g%IdyCv(i+1,j) - v(i,j,k)*g%IdyCv(i,j))
431 dudy(i,j) = cs%DX_dyBu(i,j)*(u(i,j+1,k)*g%IdxCu(i,j+1) - u(i,j,k)*g%IdxCu(i,j))
439 do j=js-2,je+2 ;
do i=isq-1,ieq+1
440 h_u(i,j) = 0.5 * (h(i,j,k) + h(i+1,j,k))
442 do j=jsq-1,jeq+1 ;
do i=is-2,ie+2
443 h_v(i,j) = 0.5 * (h(i,j,k) + h(i,j+1,k))
448 if (apply_obc)
then ;
do n=1,obc%number_of_segments
449 j = obc%segment(n)%HI%JsdB ; i = obc%segment(n)%HI%IsdB
450 if (obc%zero_strain .or. obc%freeslip_strain)
then 451 if (obc%segment(n)%is_N_or_S .and. (j >= js-2) .and. (j <= jeq+1))
then 452 do i=obc%segment(n)%HI%IsdB,obc%segment(n)%HI%IedB
453 if (obc%zero_strain)
then 454 dvdx(i,j) = 0. ; dudy(i,j) = 0.
455 elseif (obc%freeslip_strain)
then 459 elseif (obc%segment(n)%is_E_or_W .and. (i >= is-2) .and. (i <= ieq+1))
then 460 do j=obc%segment(n)%HI%JsdB,obc%segment(n)%HI%JedB
461 if (obc%zero_strain)
then 462 dvdx(i,j) = 0. ; dudy(i,j) = 0.
463 elseif (obc%freeslip_strain)
then 469 if (obc%segment(n)%direction == obc_direction_n)
then 474 if ((j >= jsq-1) .and. (j <= jeq+1))
then 475 do i = max(is-2,obc%segment(n)%HI%isd), min(ie+2,obc%segment(n)%HI%ied)
479 elseif (obc%segment(n)%direction == obc_direction_s)
then 480 if ((j >= jsq-1) .and. (j <= jeq+1))
then 481 do i = max(is-2,obc%segment(n)%HI%isd), min(ie+2,obc%segment(n)%HI%ied)
482 h_v(i,j) = h(i,j+1,k)
485 elseif (obc%segment(n)%direction == obc_direction_e)
then 486 if ((i >= isq-1) .and. (i <= ieq+1))
then 487 do j = max(js-2,obc%segment(n)%HI%jsd), min(je+2,obc%segment(n)%HI%jed)
491 elseif (obc%segment(n)%direction == obc_direction_w)
then 492 if ((i >= isq-1) .and. (i <= ieq+1))
then 493 do j = max(js-2,obc%segment(n)%HI%jsd), min(je+2,obc%segment(n)%HI%jed)
494 h_u(i,j) = h(i+1,j,k)
500 if (apply_obc)
then ;
do n=1,obc%number_of_segments
501 j = obc%segment(n)%HI%JsdB ; i = obc%segment(n)%HI%IsdB
502 if (obc%segment(n)%direction == obc_direction_n)
then 503 if ((j >= js-2) .and. (j <= je))
then 504 do i = max(isq-1,obc%segment(n)%HI%IsdB), min(ieq+1,obc%segment(n)%HI%IedB)
505 h_u(i,j+1) = h_u(i,j)
508 elseif (obc%segment(n)%direction == obc_direction_s)
then 509 if ((j >= js-1) .and. (j <= je+1))
then 510 do i = max(isq-1,obc%segment(n)%HI%isd), min(ieq+1,obc%segment(n)%HI%ied)
511 h_u(i,j) = h_u(i,j+1)
514 elseif (obc%segment(n)%direction == obc_direction_e)
then 515 if ((i >= is-2) .and. (i <= ie))
then 516 do j = max(jsq-1,obc%segment(n)%HI%jsd), min(jeq+1,obc%segment(n)%HI%jed)
517 h_v(i+1,j) = h_v(i,j)
520 elseif (obc%segment(n)%direction == obc_direction_w)
then 521 if ((i >= is-1) .and. (i <= ie+1))
then 522 do j = max(jsq-1,obc%segment(n)%HI%jsd), min(jeq+1,obc%segment(n)%HI%jed)
523 h_v(i,j) = h_v(i+1,j)
530 do j=js-2,jeq+1 ;
do i=is-2,ieq+1
531 sh_xy(i,j) = (2.0-g%mask2dBu(i,j)) * ( dvdx(i,j) + dudy(i,j) )
534 do j=js-2,jeq+1 ;
do i=is-2,ieq+1
535 sh_xy(i,j) = g%mask2dBu(i,j) * ( dvdx(i,j) + dudy(i,j) )
540 do j=js-2,jeq+1 ;
do i=is-2,ieq+1
541 vort_xy(i,j) = (2.0-g%mask2dBu(i,j)) * ( dvdx(i,j) - dudy(i,j) )
544 do j=js-2,jeq+1 ;
do i=is-2,ieq+1
545 vort_xy(i,j) = g%mask2dBu(i,j) * ( dvdx(i,j) - dudy(i,j) )
550 do j=js-2,jeq+1 ;
do i=is-1,ieq+1
551 vort_xy_dx(i,j) = cs%DY_dxBu(i,j)*(vort_xy(i,j)*g%IdyCu(i,j) - vort_xy(i-1,j)*g%IdyCu(i-1,j))
554 do j=js-1,jeq+1 ;
do i=is-2,ieq+1
555 vort_xy_dy(i,j) = cs%DX_dyBu(i,j)*(vort_xy(i,j)*g%IdxCv(i,j) - vort_xy(i,j-1)*g%IdxCv(i,j-1))
559 do j=jsq-1,jeq+2 ;
do i=is-2,ieq+1
560 div_xx_dx(i,j) = g%IdxCu(i,j)*(div_xx(i+1,j) - div_xx(i,j))
563 do j=js-2,jeq+1 ;
do i=isq-1,ieq+2
564 div_xx_dy(i,j) = g%IdyCv(i,j)*(div_xx(i,j+1) - div_xx(i,j))
568 if (cs%Modified_Leith)
then 575 if (cs%biharmonic)
then 576 do j=js-1,jeq+1 ;
do i=isq-1,ieq+1
577 u0(i,j) = cs%IDXDY2u(i,j)*(cs%DY2h(i+1,j)*sh_xx(i+1,j) - cs%DY2h(i,j)*sh_xx(i,j)) + &
578 cs%IDX2dyCu(i,j)*(cs%DX2q(i,j)*sh_xy(i,j) - cs%DX2q(i,j-1)*sh_xy(i,j-1))
580 do j=jsq-1,jeq+1 ;
do i=is-1,ieq+1
581 v0(i,j) = cs%IDXDY2v(i,j)*(cs%DY2q(i,j)*sh_xy(i,j) - cs%DY2q(i-1,j)*sh_xy(i-1,j)) - &
582 cs%IDX2dyCv(i,j)*(cs%DX2h(i,j+1)*sh_xx(i,j+1) - cs%DX2h(i,j)*sh_xx(i,j))
584 if (apply_obc .and. obc%zero_biharmonic)
then 585 do n=1,obc%number_of_segments
586 i = obc%segment(n)%HI%IsdB ; j = obc%segment(n)%HI%JsdB
587 if (obc%segment(n)%is_N_or_S .and. (j >= jsq-1) .and. (j <= jeq+1))
then 588 do i=obc%segment(n)%HI%isd,obc%segment(n)%HI%ied
591 elseif (obc%segment(n)%is_E_or_W .and. (i >= isq-1) .and. (i <= ieq+1))
then 592 do j=obc%segment(n)%HI%jsd,obc%segment(n)%HI%jed
600 do j=jsq,jeq+1 ;
do i=isq,ieq+1
601 if ((cs%Smagorinsky_Kh) .or. (cs%Smagorinsky_Ah))
then 602 shear_mag = sqrt(sh_xx(i,j)*sh_xx(i,j) + &
603 0.25*((sh_xy(i-1,j-1)*sh_xy(i-1,j-1) + sh_xy(i,j)*sh_xy(i,j)) + &
604 (sh_xy(i-1,j)*sh_xy(i-1,j) + sh_xy(i,j-1)*sh_xy(i,j-1))))
606 if ((cs%Leith_Kh) .or. (cs%Leith_Ah))
then 608 0.5*((vort_xy_dx(i,j-1)*vort_xy_dx(i,j-1) + vort_xy_dx(i,j)*vort_xy_dx(i,j)) + &
609 (vort_xy_dy(i-1,j)*vort_xy_dy(i-1,j) + vort_xy_dy(i,j)*vort_xy_dy(i,j))) + &
610 mod_leith*0.5*((div_xx_dx(i,j)*div_xx_dx(i,j) + div_xx_dx(i-1,j)*div_xx_dx(i-1,j)) + &
611 (div_xx_dy(i,j)*div_xx_dy(i,j) + div_xx_dy(i,j-1)*div_xx_dy(i,j-1))))
613 if (cs%better_bound_Ah .or. cs%better_bound_Kh)
then 614 hrat_min = min(1.0, min(h_u(i,j), h_u(i-1,j), h_v(i,j), h_v(i,j-1)) / &
615 (h(i,j,k) + h_neglect) )
619 if (cs%Laplacian)
then 622 kh_scale = 1.0 ;
if (rescale_kh) kh_scale = varmix%Res_fn_h(i,j)
623 khsm = 0.0; khlth = 0.0
624 if ((cs%Smagorinsky_Kh) .or. (cs%Leith_Kh))
then 625 if (cs%Smagorinsky_Kh) &
626 khsm = cs%LAPLAC_CONST_xx(i,j) * shear_mag
628 khlth = cs%LAPLAC3_CONST_xx(i,j) * vort_mag
629 kh = kh_scale * max(khlth, max(cs%Kh_bg_xx(i,j), khsm))
630 if (cs%bound_Kh .and. .not.cs%better_bound_Kh) &
631 kh = min(kh, cs%Kh_Max_xx(i,j))
633 kh = kh_scale * cs%Kh_bg_xx(i,j)
636 if (use_meke_ku)
then 637 kh = kh + meke%Ku(i,j)
639 if (cs%better_bound_Kh)
then 640 if (kh >= hrat_min*cs%Kh_Max_xx(i,j))
then 642 kh = hrat_min*cs%Kh_Max_xx(i,j)
645 visc_bound_rem = 1.0 - kh / (hrat_min*cs%Kh_Max_xx(i,j))
649 if (cs%id_Kh_h>0) kh_h(i,j,k) = kh
651 str_xx(i,j) = -kh * sh_xx(i,j)
656 if (cs%biharmonic)
then 659 ahsm = 0.0; ahlth = 0.0
660 if ((cs%Smagorinsky_Ah) .or. (cs%Leith_Ah))
then 661 if (cs%Smagorinsky_Ah)
then 662 if (cs%bound_Coriolis)
then 663 ahsm = shear_mag * (cs%BIHARM_CONST_xx(i,j) + &
664 cs%Biharm_Const2_xx(i,j)*shear_mag)
666 ahsm = cs%BIHARM_CONST_xx(i,j) * shear_mag
670 ahlth = vort_mag * (cs%BIHARM_CONST_xx(i,j))
671 ah = max(max(cs%Ah_bg_xx(i,j), ahsm),ahlth)
672 if (cs%bound_Ah .and. .not.cs%better_bound_Ah) &
673 ah = min(ah, cs%Ah_Max_xx(i,j))
675 ah = cs%Ah_bg_xx(i,j)
678 if (cs%better_bound_Ah)
then 679 ah = min(ah, visc_bound_rem*hrat_min*cs%Ah_Max_xx(i,j))
682 if (cs%id_Ah_h>0) ah_h(i,j,k) = ah
684 str_xx(i,j) = str_xx(i,j) + ah * &
685 (cs%DY_dxT(i,j)*(g%IdyCu(i,j)*u0(i,j) - g%IdyCu(i-1,j)*u0(i-1,j)) - &
686 cs%DX_dyT(i,j) *(g%IdxCv(i,j)*v0(i,j) - g%IdxCv(i,j-1)*v0(i,j-1)))
689 bhstr_xx(i,j) = ah * &
690 (cs%DY_dxT(i,j)*(g%IdyCu(i,j)*u0(i,j) - g%IdyCu(i-1,j)*u0(i-1,j)) - &
691 cs%DX_dyT(i,j) *(g%IdxCv(i,j)*v0(i,j) - g%IdxCv(i,j-1)*v0(i,j-1)))
692 bhstr_xx(i,j) = bhstr_xx(i,j) * (h(i,j,k) * cs%reduction_xx(i,j))
696 str_xx(i,j) = str_xx(i,j) * (h(i,j,k) * cs%reduction_xx(i,j))
699 if (cs%biharmonic)
then 701 do j=js-1,jeq ;
do i=is-1,ieq
702 dvdx(i,j) = cs%DY_dxBu(i,j)*(v0(i+1,j)*g%IdyCv(i+1,j) - v0(i,j)*g%IdyCv(i,j))
703 dudy(i,j) = cs%DX_dyBu(i,j)*(u0(i,j+1)*g%IdxCu(i,j+1) - u0(i,j)*g%IdxCu(i,j))
706 if (apply_obc)
then ;
if (obc%zero_strain .or. obc%freeslip_strain)
then 707 do n=1,obc%number_of_segments
708 j = obc%segment(n)%HI%JsdB ; i = obc%segment(n)%HI%IsdB
709 if (obc%segment(n)%is_N_or_S .and. (j >= js-1) .and. (j <= jeq))
then 710 do i=obc%segment(n)%HI%IsdB,obc%segment(n)%HI%IedB
711 if (obc%zero_strain)
then 712 dvdx(i,j) = 0. ; dudy(i,j) = 0.
713 elseif (obc%freeslip_strain)
then 717 elseif (obc%segment(n)%is_E_or_W .and. (i >= is-1) .and. (i <= ieq))
then 718 do j=obc%segment(n)%HI%JsdB,obc%segment(n)%HI%JedB
719 if (obc%zero_strain)
then 720 dvdx(i,j) = 0. ; dudy(i,j) = 0.
721 elseif (obc%freeslip_strain)
then 730 do j=js-1,jeq ;
do i=is-1,ieq
731 if ((cs%Smagorinsky_Kh) .or. (cs%Smagorinsky_Ah))
then 732 shear_mag = sqrt(sh_xy(i,j)*sh_xy(i,j) + &
733 0.25*((sh_xx(i,j)*sh_xx(i,j) + sh_xx(i+1,j+1)*sh_xx(i+1,j+1)) + &
734 (sh_xx(i,j+1)*sh_xx(i,j+1) + sh_xx(i+1,j)*sh_xx(i+1,j))))
736 if ((cs%Leith_Kh) .or. (cs%Leith_Ah)) &
738 0.5*((vort_xy_dx(i,j)*vort_xy_dx(i,j) + vort_xy_dx(i+1,j)*vort_xy_dx(i+1,j)) + &
739 (vort_xy_dy(i,j)*vort_xy_dy(i,j) + vort_xy_dy(i,j+1)*vort_xy_dy(i,j+1))) + &
740 mod_leith*0.5*((div_xx_dx(i,j)*div_xx_dx(i,j) + div_xx_dx(i,j+1)*div_xx_dx(i,j+1)) + &
741 (div_xx_dy(i,j)*div_xx_dy(i,j) + div_xx_dy(i+1,j)*div_xx_dy(i+1,j))))
743 h2uq = 4.0 * h_u(i,j) * h_u(i,j+1)
744 h2vq = 4.0 * h_v(i,j) * h_v(i+1,j)
747 hq = 2.0 * h2uq * h2vq / (h_neglect3 + (h2uq + h2vq) * &
748 ((h_u(i,j) + h_u(i,j+1)) + (h_v(i,j) + h_v(i+1,j))))
750 if (cs%better_bound_Ah .or. cs%better_bound_Kh)
then 751 hrat_min = min(1.0, min(h_u(i,j), h_u(i,j+1), h_v(i,j), h_v(i+1,j)) / &
756 if (cs%no_slip .and. (g%mask2dBu(i,j) < 0.5))
then 757 if ((g%mask2dCu(i,j) + g%mask2dCu(i,j+1)) + &
758 (g%mask2dCv(i,j) + g%mask2dCv(i+1,j)) > 0.0)
then 761 hu = g%mask2dCu(i,j) * h_u(i,j) + g%mask2dCu(i,j+1) * h_u(i,j+1)
762 hv = g%mask2dCv(i,j) * h_v(i,j) + g%mask2dCv(i+1,j) * h_v(i+1,j)
763 if ((g%mask2dCu(i,j) + g%mask2dCu(i,j+1)) * &
764 (g%mask2dCv(i,j) + g%mask2dCv(i+1,j)) == 0.0)
then 770 hq = 2.0 * (hu * hv) / ((hu + hv) + h_neglect)
771 hrat_min = min(1.0, min(hu, hv) / (hq + h_neglect) )
776 if (cs%Laplacian)
then 779 kh_scale = 1.0 ;
if (rescale_kh) kh_scale = varmix%Res_fn_q(i,j)
780 khsm = 0.0; khlth = 0.0
781 if ((cs%Smagorinsky_Kh) .or. (cs%Leith_Kh))
then 782 if (cs%Smagorinsky_Kh) &
783 khsm = cs%LAPLAC_CONST_xy(i,j) * shear_mag
785 khlth = cs%LAPLAC3_CONST_xy(i,j) * vort_mag
786 kh = kh_scale * max(max(cs%Kh_bg_xy(i,j), khsm), khlth)
787 if (cs%bound_Kh .and. .not.cs%better_bound_Kh) &
788 kh = min(kh, cs%Kh_Max_xy(i,j))
790 kh = kh_scale * cs%Kh_bg_xy(i,j)
792 if (use_meke_ku)
then 793 kh = kh + 0.25*( (meke%Ku(i,j)+meke%Ku(i+1,j+1)) &
794 +(meke%Ku(i+1,j)+meke%Ku(i,j+1)) )
797 kh = max(kh,cs%Kh_bg_min)
799 if (cs%better_bound_Kh)
then 800 if (kh >= hrat_min*cs%Kh_Max_xy(i,j))
then 802 kh = hrat_min*cs%Kh_Max_xy(i,j)
803 elseif (cs%Kh_Max_xy(i,j)>0.)
then 805 visc_bound_rem = 1.0 - kh / (hrat_min*cs%Kh_Max_xy(i,j))
809 if (cs%id_Kh_q>0) kh_q(i,j,k) = kh
811 str_xy(i,j) = -kh * sh_xy(i,j)
816 if (cs%biharmonic)
then 819 ahsm = 0.0; ahlth = 0.0
820 if (cs%Smagorinsky_Ah .or. cs%Leith_Ah)
then 821 if (cs%Smagorinsky_Ah)
then 822 if (cs%bound_Coriolis)
then 823 ahsm = shear_mag * (cs%BIHARM_CONST_xy(i,j) + &
824 cs%Biharm_Const2_xy(i,j)*shear_mag)
826 ahsm = cs%BIHARM_CONST_xy(i,j) * shear_mag
830 ahlth = vort_mag * (cs%BIHARM5_CONST_xy(i,j))
831 ah = max(max(cs%Ah_bg_xy(i,j), ahsm),ahlth)
832 if (cs%bound_Ah .and. .not.cs%better_bound_Ah) &
833 ah = min(ah, cs%Ah_Max_xy(i,j))
835 ah = cs%Ah_bg_xy(i,j)
837 if (cs%better_bound_Ah)
then 838 ah = min(ah, visc_bound_rem*hrat_min*cs%Ah_Max_xy(i,j))
841 if (cs%id_Ah_q>0) ah_q(i,j,k) = ah
843 str_xy(i,j) = str_xy(i,j) + ah * ( dvdx(i,j) + dudy(i,j) )
846 bhstr_xy(i,j) = ah * ( dvdx(i,j) + dudy(i,j) ) * &
847 (hq * g%mask2dBu(i,j) * cs%reduction_xy(i,j))
852 str_xy(i,j) = str_xy(i,j) * (hq * cs%reduction_xy(i,j))
854 str_xy(i,j) = str_xy(i,j) * (hq * g%mask2dBu(i,j) * cs%reduction_xy(i,j))
858 do j=js,je ;
do i=isq,ieq
860 diffu(i,j,k) = ((g%IdyCu(i,j)*(cs%DY2h(i,j) *str_xx(i,j) - &
861 cs%DY2h(i+1,j)*str_xx(i+1,j)) + &
862 g%IdxCu(i,j)*(cs%DX2q(i,j-1)*str_xy(i,j-1) - &
863 cs%DX2q(i,j) *str_xy(i,j))) * &
864 g%IareaCu(i,j)) / (h_u(i,j) + h_neglect)
870 do n=1,obc%number_of_segments
871 if (obc%segment(n)%is_E_or_W)
then 872 i = obc%segment(n)%HI%IsdB
873 do j=obc%segment(n)%HI%jsd,obc%segment(n)%HI%jed
881 do j=jsq,jeq ;
do i=is,ie
882 diffv(i,j,k) = ((g%IdyCv(i,j)*(cs%DY2q(i-1,j)*str_xy(i-1,j) - &
883 cs%DY2q(i,j) *str_xy(i,j)) - &
884 g%IdxCv(i,j)*(cs%DX2h(i,j) *str_xx(i,j) - &
885 cs%DX2h(i,j+1)*str_xx(i,j+1))) * &
886 g%IareaCv(i,j)) / (h_v(i,j) + h_neglect)
891 do n=1,obc%number_of_segments
892 if (obc%segment(n)%is_N_or_S)
then 893 j = obc%segment(n)%HI%JsdB
894 do i=obc%segment(n)%HI%isd,obc%segment(n)%HI%ied
901 if (find_frictwork)
then ;
do j=js,je ;
do i=is,ie
903 frictwork(i,j,k) = gv%H_to_kg_m2 * ( &
904 (str_xx(i,j)*(u(i,j,k)-u(i-1,j,k))*g%IdxT(i,j) &
905 -str_xx(i,j)*(v(i,j,k)-v(i,j-1,k))*g%IdyT(i,j)) &
906 +0.25*((str_xy(i,j)*( &
907 (u(i,j+1,k)-u(i,j,k))*g%IdyBu(i,j) &
908 +(v(i+1,j,k)-v(i,j,k))*g%IdxBu(i,j) ) &
910 (u(i-1,j,k)-u(i-1,j-1,k))*g%IdyBu(i-1,j-1) &
911 +(v(i,j-1,k)-v(i-1,j-1,k))*g%IdxBu(i-1,j-1) )) &
913 (u(i-1,j+1,k)-u(i-1,j,k))*g%IdyBu(i-1,j) &
914 +(v(i,j,k)-v(i-1,j,k))*g%IdxBu(i-1,j) ) &
916 (u(i,j,k)-u(i,j-1,k))*g%IdyBu(i,j-1) &
917 +(v(i+1,j-1,k)-v(i,j-1,k))*g%IdxBu(i,j-1) )) ) )
918 enddo ;
enddo ;
endif 923 if (find_frictwork .and.
associated(meke))
then ;
if (
associated(meke%mom_src))
then 925 do j=js,je ;
do i=is,ie
926 meke%mom_src(i,j) = 0.
929 if (meke%backscatter_Ro_c /= 0.)
then 930 do j=js,je ;
do i=is,ie
931 fath = 0.25*( (abs(g%CoriolisBu(i-1,j-1)) + abs(g%CoriolisBu(i,j))) &
932 +(abs(g%CoriolisBu(i-1,j)) + abs(g%CoriolisBu(i,j-1))) )
933 shear_mag = sqrt(sh_xx(i,j)*sh_xx(i,j) + &
934 0.25*((sh_xy(i-1,j-1)*sh_xy(i-1,j-1) + sh_xy(i,j)*sh_xy(i,j)) + &
935 (sh_xy(i-1,j)*sh_xy(i-1,j) + sh_xy(i,j-1)*sh_xy(i,j-1))))
936 fath = fath ** meke%backscatter_Ro_pow
937 shear_mag = ( ( shear_mag ** meke%backscatter_Ro_pow ) + 1.e-30 ) &
938 * meke%backscatter_Ro_c
941 roscl = shear_mag / ( fath + shear_mag )
942 meke%mom_src(i,j) = meke%mom_src(i,j) + gv%H_to_kg_m2 * ( &
943 ((str_xx(i,j)-roscl*bhstr_xx(i,j))*(u(i,j,k)-u(i-1,j,k))*g%IdxT(i,j) &
944 -(str_xx(i,j)-roscl*bhstr_xx(i,j))*(v(i,j,k)-v(i,j-1,k))*g%IdyT(i,j)) &
945 +0.25*(((str_xy(i,j)-roscl*bhstr_xy(i,j))*( &
946 (u(i,j+1,k)-u(i,j,k))*g%IdyBu(i,j) &
947 +(v(i+1,j,k)-v(i,j,k))*g%IdxBu(i,j) ) &
948 +(str_xy(i-1,j-1)-roscl*bhstr_xy(i-1,j-1))*( &
949 (u(i-1,j,k)-u(i-1,j-1,k))*g%IdyBu(i-1,j-1) &
950 +(v(i,j-1,k)-v(i-1,j-1,k))*g%IdxBu(i-1,j-1) )) &
951 +((str_xy(i-1,j)-roscl*bhstr_xy(i-1,j))*( &
952 (u(i-1,j+1,k)-u(i-1,j,k))*g%IdyBu(i-1,j) &
953 +(v(i,j,k)-v(i-1,j,k))*g%IdxBu(i-1,j) ) &
954 +(str_xy(i,j-1)-roscl*bhstr_xy(i,j-1))*( &
955 (u(i,j,k)-u(i,j-1,k))*g%IdyBu(i,j-1) &
956 +(v(i+1,j-1,k)-v(i,j-1,k))*g%IdxBu(i,j-1) )) ) )
959 do j=js,je ;
do i=is,ie
960 meke%mom_src(i,j) = meke%mom_src(i,j) + frictwork(i,j,k)
968 if (cs%id_diffu>0)
call post_data(cs%id_diffu, diffu, cs%diag)
969 if (cs%id_diffv>0)
call post_data(cs%id_diffv, diffv, cs%diag)
970 if (cs%id_FrictWork>0)
call post_data(cs%id_FrictWork, frictwork, cs%diag)
971 if (cs%id_Ah_h>0)
call post_data(cs%id_Ah_h, ah_h, cs%diag)
972 if (cs%id_Ah_q>0)
call post_data(cs%id_Ah_q, ah_q, cs%diag)
973 if (cs%id_Kh_h>0)
call post_data(cs%id_Kh_h, kh_h, cs%diag)
974 if (cs%id_Kh_q>0)
call post_data(cs%id_Kh_q, kh_q, cs%diag)
976 if (cs%id_FrictWorkIntz > 0)
then 978 do i=is,ie ; frictworkintz(i,j) = frictwork(i,j,1) ;
enddo 979 do k=2,nz ;
do i=is,ie
980 frictworkintz(i,j) = frictworkintz(i,j) + frictwork(i,j,k)
983 call post_data(cs%id_FrictWorkIntz, frictworkintz, cs%diag)
Ocean grid type. See mom_grid for details.