Skip to content

Commit

Permalink
Merge 477e511 into a41d0a0
Browse files Browse the repository at this point in the history
  • Loading branch information
Hallberg-NOAA authored Oct 6, 2023
2 parents a41d0a0 + 477e511 commit 069a539
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 108 deletions.
211 changes: 137 additions & 74 deletions src/core/MOM_barotropic.F90

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/core/MOM_boundary_update.F90
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ subroutine update_OBC_data(OBC, G, GV, US, tv, h, CS, Time)
call shelfwave_set_OBC_data(OBC, CS%shelfwave_OBC_CSp, G, GV, US, h, Time)
if (CS%use_dyed_channel) &
call dyed_channel_update_flow(OBC, CS%dyed_channel_OBC_CSp, G, GV, US, Time)
if (OBC%needs_IO_for_data .or. OBC%add_tide_constituents) &
if (OBC%any_needs_IO_for_data .or. OBC%add_tide_constituents) &
call update_OBC_segment_data(G, GV, US, OBC, tv, h, Time)

end subroutine update_OBC_data
Expand Down
17 changes: 13 additions & 4 deletions src/core/MOM_dynamics_split_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ module MOM_dynamics_split_RK2
use MOM_hor_index, only : hor_index_type
use MOM_hor_visc, only : horizontal_viscosity, hor_visc_CS
use MOM_hor_visc, only : hor_visc_init, hor_visc_end
use MOM_interface_heights, only : find_eta, thickness_to_dz
use MOM_interface_heights, only : thickness_to_dz, find_col_avg_SpV
use MOM_lateral_mixing_coeffs, only : VarMix_CS
use MOM_MEKE_types, only : MEKE_type
use MOM_open_boundary, only : ocean_OBC_type, radiation_open_bdry_conds
use MOM_open_boundary, only : open_boundary_zero_normal_flow
use MOM_open_boundary, only : open_boundary_zero_normal_flow, open_boundary_query
use MOM_open_boundary, only : open_boundary_test_extern_h, update_OBC_ramp
use MOM_PressureForce, only : PressureForce, PressureForce_CS
use MOM_PressureForce, only : PressureForce_init
Expand Down Expand Up @@ -344,6 +344,7 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s

real, dimension(SZI_(G),SZJ_(G)) :: eta_pred ! The predictor value of the free surface height
! or column mass [H ~> m or kg m-2]
real, dimension(SZI_(G),SZJ_(G)) :: SpV_avg ! The column averaged specific volume [R-1 ~> m3 kg-1]
real, dimension(SZI_(G),SZJ_(G)) :: deta_dt ! A diagnostic of the time derivative of the free surface
! height or column mass [H T-1 ~> m s-1 or kg m-2 s-1]

Expand Down Expand Up @@ -596,6 +597,14 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
if (.not.BT_cont_BT_thick) &
call btcalc(h, G, GV, CS%barotropic_CSp, OBC=CS%OBC)
call bt_mass_source(h, eta, .true., G, GV, CS%barotropic_CSp)

SpV_avg(:,:) = 0.0
if ((.not.GV%Boussinesq) .and. associated(CS%OBC)) then
! Determine the column average specific volume if it is needed due to the
! use of Flather open boundary conditions in non-Boussinesq mode.
if (open_boundary_query(CS%OBC, apply_Flather_OBC=.true.)) &
call find_col_avg_SpV(h, SpV_avg, tv, G, GV, US)

Check warning on line 606 in src/core/MOM_dynamics_split_RK2.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_dynamics_split_RK2.F90#L606

Added line #L606 was not covered by tests
endif
call cpu_clock_end(id_clock_btcalc)

if (G%nonblocking_updates) &
Expand Down Expand Up @@ -625,7 +634,7 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
! The CS%ADp argument here stores the weights for certain integrated diagnostics.
call btstep(u, v, eta, dt, u_bc_accel, v_bc_accel, forces, CS%pbce, CS%eta_PF, u_av, v_av, &
CS%u_accel_bt, CS%v_accel_bt, eta_pred, CS%uhbt, CS%vhbt, G, GV, US, &
CS%barotropic_CSp, CS%visc_rem_u, CS%visc_rem_v, CS%ADp, CS%OBC, CS%BT_cont, &
CS%barotropic_CSp, CS%visc_rem_u, CS%visc_rem_v, SpV_avg, CS%ADp, CS%OBC, CS%BT_cont, &
eta_PF_start, taux_bot, tauy_bot, uh_ptr, vh_ptr, u_ptr, v_ptr)
if (showCallTree) call callTree_leave("btstep()")
call cpu_clock_end(id_clock_btstep)
Expand Down Expand Up @@ -847,7 +856,7 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
! This is the corrector step call to btstep.
call btstep(u, v, eta, dt, u_bc_accel, v_bc_accel, forces, CS%pbce, CS%eta_PF, u_av, v_av, &
CS%u_accel_bt, CS%v_accel_bt, eta_pred, CS%uhbt, CS%vhbt, G, GV, US, &
CS%barotropic_CSp, CS%visc_rem_u, CS%visc_rem_v, CS%ADp, CS%OBC, CS%BT_cont, &
CS%barotropic_CSp, CS%visc_rem_u, CS%visc_rem_v, SpV_avg, CS%ADp, CS%OBC, CS%BT_cont, &
eta_PF_start, taux_bot, tauy_bot, uh_ptr, vh_ptr, u_ptr, v_ptr, etaav=eta_av)
if (CS%id_deta_dt>0) then
do j=js,je ; do i=is,ie ; deta_dt(i,j) = (eta_pred(i,j) - eta(i,j))*Idt_bc ; enddo ; enddo
Expand Down
70 changes: 69 additions & 1 deletion src/core/MOM_interface_heights.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module MOM_interface_heights

public find_eta, dz_to_thickness, thickness_to_dz, dz_to_thickness_simple
public calc_derived_thermo
public find_rho_bottom
public find_rho_bottom, find_col_avg_SpV

!> Calculates the heights of the free surface or all interfaces from layer thicknesses.
interface find_eta
Expand Down Expand Up @@ -323,6 +323,74 @@ subroutine calc_derived_thermo(tv, h, G, GV, US, halo, debug)
end subroutine calc_derived_thermo


!> Determine the column average specific volumes.
subroutine find_col_avg_SpV(h, SpV_avg, tv, G, GV, US, halo_size)

Check warning on line 327 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L327

Added line #L327 was not covered by tests
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
intent(in) :: h !< Layer thicknesses [H ~> m or kg m-2]
real, dimension(SZI_(G),SZJ_(G)), &
intent(inout) :: SpV_avg !< Column average specific volume [R-1 ~> m3 kg-1]
! SpV_avg is intent inout to retain excess halo values.
type(thermo_var_ptrs), intent(in) :: tv !< Structure containing pointers to any available
!! thermodynamic fields.
integer, optional, intent(in) :: halo_size !< width of halo points on which to work

! Local variables
real :: h_tot(SZI_(G)) ! Sum of the layer thicknesses [H ~> m or kg m-3]
real :: SpV_x_h_tot(SZI_(G)) ! Vertical sum of the layer average specific volume times

Check warning on line 342 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L341-L342

Added lines #L341 - L342 were not covered by tests
! the layer thicknesses [H R-1 ~> m4 kg-1 or m]
real :: I_rho ! The inverse of the Boussiensq reference density [R-1 ~> m3 kg-1]
real :: SpV_lay(SZK_(GV)) ! The inverse of the layer target potential densities [R-1 ~> m3 kg-1]

Check warning on line 345 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L345

Added line #L345 was not covered by tests
character(len=128) :: mesg ! A string for error messages
integer i, j, k, is, ie, js, je, nz, halo

halo = 0 ; if (present(halo_size)) halo = max(0,halo_size)

Check warning on line 349 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L349

Added line #L349 was not covered by tests

is = G%isc-halo ; ie = G%iec+halo ; js = G%jsc-halo ; je = G%jec+halo
nz = GV%ke

Check warning on line 352 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L351-L352

Added lines #L351 - L352 were not covered by tests

if (GV%Boussinesq) then
I_rho = 1.0 / GV%Rho0
do j=js,je ; do i=is,ie
SpV_avg(i,j) = I_rho

Check warning on line 357 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L355-L357

Added lines #L355 - L357 were not covered by tests
enddo ; enddo
elseif (.not.allocated(tv%SpV_avg)) then
do k=1,nz ; Spv_lay(k) = 1.0 / GV%Rlay(k) ; enddo
do j=js,je
do i=is,ie ; SpV_x_h_tot(i) = 0.0 ; h_tot(i) = 0.0 ; enddo
do k=1,nz ; do i=is,ie
h_tot(i) = h_tot(i) + max(h(i,j,k), GV%H_subroundoff)
SpV_x_h_tot(i) = SpV_x_h_tot(i) + Spv_lay(k)*max(h(i,j,k), GV%H_subroundoff)

Check warning on line 365 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L359-L365

Added lines #L359 - L365 were not covered by tests
enddo ; enddo
do i=is,ie ; SpV_avg(i,j) = SpV_x_h_tot(i) / h_tot(i) ; enddo

Check warning on line 367 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L367

Added line #L367 was not covered by tests
enddo
else
! Check that SpV_avg has been set.
if ((allocated(tv%SpV_avg)) .and. (tv%valid_SpV_halo < halo)) then
if (tv%valid_SpV_halo < 0) then
mesg = "invalid values of SpV_avg."

Check warning on line 373 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L373

Added line #L373 was not covered by tests
else
write(mesg, '("insufficiently large SpV_avg halos of width ", i2, " but ", i2," is needed.")') &
tv%valid_SpV_halo, halo

Check warning on line 376 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L376

Added line #L376 was not covered by tests
endif
call MOM_error(FATAL, "find_col_avg_SpV called in fully non-Boussinesq mode with "//trim(mesg))

Check warning on line 378 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L378

Added line #L378 was not covered by tests
endif

do j=js,je
do i=is,ie ; SpV_x_h_tot(i) = 0.0 ; h_tot(i) = 0.0 ; enddo
do k=1,nz ; do i=is,ie
h_tot(i) = h_tot(i) + max(h(i,j,k), GV%H_subroundoff)
SpV_x_h_tot(i) = SpV_x_h_tot(i) + tv%SpV_avg(i,j,k)*max(h(i,j,k), GV%H_subroundoff)

Check warning on line 385 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L381-L385

Added lines #L381 - L385 were not covered by tests
enddo ; enddo
do i=is,ie ; SpV_avg(i,j) = SpV_x_h_tot(i) / h_tot(i) ; enddo

Check warning on line 387 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L387

Added line #L387 was not covered by tests
enddo
endif

end subroutine find_col_avg_SpV

Check warning on line 391 in src/core/MOM_interface_heights.F90

View check run for this annotation

Codecov / codecov/patch

src/core/MOM_interface_heights.F90#L391

Added line #L391 was not covered by tests


!> Determine the in situ density averaged over a specified distance from the bottom,
!! calculating it as the inverse of the mass-weighted average specific volume.
subroutine find_rho_bottom(h, dz, pres_int, dz_avg, tv, j, G, GV, US, Rho_bot)
Expand Down
Loading

0 comments on commit 069a539

Please sign in to comment.