Calculates the heights of all interfaces between layers, using the appropriate form for consistency with the calculation of the pressure gradient forces. Additionally, these height may be dilated for consistency with the corresponding time-average quantity from the barotropic calculation.
32 type(ocean_grid_type),
intent(in) :: G
33 type(verticalGrid_type),
intent(in) :: GV
34 type(unit_scale_type),
intent(in) :: US
35 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)),
intent(in) :: h
36 type(thermo_var_ptrs),
intent(in) :: tv
38 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)+1),
intent(out) :: eta
40 real,
dimension(SZI_(G),SZJ_(G)),
optional,
intent(in) :: eta_bt
44 integer,
optional,
intent(in) :: halo_size
46 real,
optional,
intent(in) :: eta_to_m
50 real :: p(SZI_(G),SZJ_(G),SZK_(G)+1)
51 real :: dz_geo(SZI_(G),SZJ_(G),SZK_(G))
53 real :: dilate(SZI_(G))
56 real :: Z_to_eta, H_to_eta, H_to_rho_eta
57 integer i, j, k, isv, iev, jsv, jev, nz, halo
59 halo = 0 ;
if (
present(halo_size)) halo = max(0,halo_size)
61 isv = g%isc-halo ; iev = g%iec+halo ; jsv = g%jsc-halo ; jev = g%jec+halo
64 if ((isv<g%isd) .or. (iev>g%ied) .or. (jsv<g%jsd) .or. (jev>g%jed)) &
65 call mom_error(fatal,
"find_eta called with an overly large halo_size.")
67 z_to_eta = 1.0 ;
if (
present(eta_to_m)) z_to_eta = us%Z_to_m / eta_to_m
68 h_to_eta = gv%H_to_Z * z_to_eta
69 h_to_rho_eta = gv%H_to_RZ * z_to_eta
70 i_gearth = z_to_eta / (us%Z_to_m * gv%mks_g_Earth)
74 do j=jsv,jev ;
do i=isv,iev ; eta(i,j,nz+1) = -z_to_eta*g%bathyT(i,j) ;
enddo ;
enddo
76 if (gv%Boussinesq)
then
78 do j=jsv,jev ;
do k=nz,1,-1;
do i=isv,iev
79 eta(i,j,k) = eta(i,j,k+1) + h(i,j,k)*h_to_eta
81 if (
present(eta_bt))
then
87 dilate(i) = (eta_bt(i,j)*h_to_eta + z_to_eta*g%bathyT(i,j)) / &
88 (eta(i,j,1) + z_to_eta*g%bathyT(i,j))
90 do k=1,nz ;
do i=isv,iev
91 eta(i,j,k) = dilate(i) * (eta(i,j,k) + z_to_eta*g%bathyT(i,j)) - z_to_eta*g%bathyT(i,j)
96 if (
associated(tv%eqn_of_state))
then
100 do i=isv,iev ; p(i,j,1) = 0.0 ;
enddo
101 do k=1,nz ;
do i=isv,iev
102 p(i,j,k+1) = p(i,j,k) + gv%H_to_Pa*h(i,j,k)
107 call int_specific_vol_dp(tv%T(:,:,k), tv%S(:,:,k), p(:,:,k), p(:,:,k+1), &
108 0.0, g%HI, tv%eqn_of_state, dz_geo(:,:,k), halo_size=halo)
112 do k=nz,1,-1 ;
do i=isv,iev
113 eta(i,j,k) = eta(i,j,k+1) + i_gearth * dz_geo(i,j,k)
118 do j=jsv,jev ;
do k=nz,1,-1;
do i=isv,iev
119 eta(i,j,k) = eta(i,j,k+1) + h_to_rho_eta*h(i,j,k) / gv%Rlay(k)
120 enddo ;
enddo ;
enddo
122 if (
present(eta_bt))
then
127 do i=isv,iev ; htot(i) = gv%H_subroundoff ;
enddo
128 do k=1,nz ;
do i=isv,iev ; htot(i) = htot(i) + h(i,j,k) ;
enddo ;
enddo
129 do i=isv,iev ; dilate(i) = eta_bt(i,j) / htot(i) ;
enddo
130 do k=1,nz ;
do i=isv,iev
131 eta(i,j,k) = dilate(i) * (eta(i,j,k) + z_to_eta*g%bathyT(i,j)) - z_to_eta*g%bathyT(i,j)