Skip to content

Commit 2918a9d

Browse files
kshedstromHallberg-NOAA
authored andcommitted
Better Kelvin wave results in layer mode
1 parent 60a0196 commit 2918a9d

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

src/core/MOM_dynamics_split_RK2.F90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,6 @@ subroutine step_MOM_dyn_split_RK2(u_inst, v_inst, h, tv, visc, Time_local, dt, f
798798
call do_group_pass(CS%pass_hp_uv, G%Domain, clock=id_clock_pass)
799799

800800
if (associated(CS%OBC)) then
801-
call update_segment_thickness_reservoirs(G, GV, uhtr, vhtr, hp, CS%OBC)
802801

803802
if (CS%debug) &
804803
call uvchksum("Pre OBC avg [uv]", u_av, v_av, G%HI, haloshift=1, symmetric=sym, unscale=US%L_T_to_m_s)
@@ -1065,7 +1064,6 @@ subroutine step_MOM_dyn_split_RK2(u_inst, v_inst, h, tv, visc, Time_local, dt, f
10651064
endif
10661065

10671066
if (associated(CS%OBC)) then
1068-
call update_segment_thickness_reservoirs(G, GV, uhtr, vhtr, h, CS%OBC)
10691067
!### I suspect that there is a bug here when u_inst is compared with a previous value of u_av
10701068
! to estimate the dominant outward group velocity, but a fix is not available yet.
10711069
call radiation_open_bdry_conds(CS%OBC, u_inst, u_old_rad_OBC, v_inst, v_old_rad_OBC, G, GV, US, dt)
@@ -1090,6 +1088,10 @@ subroutine step_MOM_dyn_split_RK2(u_inst, v_inst, h, tv, visc, Time_local, dt, f
10901088
enddo ; enddo
10911089
enddo
10921090

1091+
if (associated(CS%OBC)) then
1092+
call update_segment_thickness_reservoirs(G, GV, uhtr, vhtr, h, CS%OBC)
1093+
endif
1094+
10931095
if (CS%store_CAu) then
10941096
! Calculate a predictor-step estimate of the Coriolis and momentum advection terms
10951097
! for use in the next time step, possibly after it has been vertically remapped.

src/core/MOM_dynamics_split_RK2b.F90

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ module MOM_dynamics_split_RK2b
5959
use MOM_open_boundary, only : ocean_OBC_type, radiation_open_bdry_conds
6060
use MOM_open_boundary, only : open_boundary_zero_normal_flow, open_boundary_query
6161
use MOM_open_boundary, only : open_boundary_test_extern_h, update_OBC_ramp
62+
use MOM_open_boundary, only : copy_thickness_reservoirs
63+
use MOM_open_boundary, only : update_segment_thickness_reservoirs
6264
use MOM_PressureForce, only : PressureForce, PressureForce_CS
6365
use MOM_PressureForce, only : PressureForce_init
6466
use MOM_set_visc, only : set_viscous_ML, set_visc_CS
@@ -73,7 +75,7 @@ module MOM_dynamics_split_RK2b
7375
use MOM_vert_friction, only : updateCFLtruncationValue, vertFPmix
7476
use MOM_verticalGrid, only : verticalGrid_type, get_thickness_units
7577
use MOM_verticalGrid, only : get_flux_units, get_tr_flux_units
76-
use MOM_wave_interface, only: wave_parameters_CS, Stokes_PGF
78+
use MOM_wave_interface, only : wave_parameters_CS, Stokes_PGF
7779

7880
implicit none ; private
7981

@@ -543,6 +545,9 @@ subroutine step_MOM_dyn_split_RK2b(u_av, v_av, h, tv, visc, Time_local, dt, forc
543545
call disable_averaging(CS%diag)
544546
if (showCallTree) call callTree_wayPoint("done with PressureForce (step_MOM_dyn_split_RK2b)")
545547

548+
if (associated(CS%OBC)) then ; if (CS%OBC%update_OBC) then
549+
call update_OBC_data(CS%OBC, G, GV, US, tv, h, CS%update_OBC_CSp, Time_local)
550+
endif ; endif
546551
if (associated(CS%OBC) .and. CS%debug_OBC) &
547552
call open_boundary_zero_normal_flow(CS%OBC, G, GV, CS%PFu, CS%PFv)
548553

@@ -667,6 +672,9 @@ subroutine step_MOM_dyn_split_RK2b(u_av, v_av, h, tv, visc, Time_local, dt, forc
667672
call cpu_clock_end(id_clock_mom_update)
668673
call do_group_pass(CS%pass_uv_inst, G%Domain, clock=id_clock_pass)
669674

675+
if (associated(CS%OBC)) &
676+
call copy_thickness_reservoirs(CS%OBC, G, GV)
677+
670678
! u_accel_bt = layer accelerations due to barotropic solver
671679
call cpu_clock_begin(id_clock_continuity)
672680
call continuity(u_inst, v_inst, h, hp, uh_in, vh_in, dt, G, GV, US, CS%continuity_CSp, CS%OBC, pbv, &
@@ -798,6 +806,7 @@ subroutine step_MOM_dyn_split_RK2b(u_av, v_av, h, tv, visc, Time_local, dt, forc
798806
call do_group_pass(CS%pass_hp_uv, G%Domain, clock=id_clock_pass)
799807

800808
if (associated(CS%OBC)) then
809+
801810
if (CS%debug) &
802811
call uvchksum("Pre OBC avg [uv]", u_av, v_av, G%HI, haloshift=1, symmetric=sym, unscale=US%L_T_to_m_s)
803812

@@ -1051,6 +1060,10 @@ subroutine step_MOM_dyn_split_RK2b(u_av, v_av, h, tv, visc, Time_local, dt, forc
10511060
enddo ; enddo
10521061
enddo
10531062

1063+
if (associated(CS%OBC)) then
1064+
call update_segment_thickness_reservoirs(G, GV, uhtr, vhtr, h, CS%OBC)
1065+
endif
1066+
10541067
! if (CS%fpmix) then
10551068
! if (CS%id_uold > 0) call post_data(CS%id_uold, uold, CS%diag)
10561069
! if (CS%id_vold > 0) call post_data(CS%id_vold, vold, CS%diag)

src/core/MOM_open_boundary.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6002,9 +6002,9 @@ subroutine update_segment_thickness_reservoirs(G, GV, uhr, vhr, h, OBC)
60026002
! When InvLscale_in is 0 and inflow, only nudged data is applied to reservoirs
60036003
a_out = b_out * max(0.0, sign(1.0, idir*uhr(I,j,k)))
60046004
a_in = b_in * min(0.0, sign(1.0, idir*uhr(I,j,k)))
6005-
u_L_out = max(0.0, (idir*uhr(I,j,k))*segment%Tr_InvLscale_out*resrv_lfac_out / &
6005+
u_L_out = max(0.0, (idir*uhr(I,j,k))*segment%Th_InvLscale_out*resrv_lfac_out / &
60066006
((h(i+ishift,j,k) + GV%H_subroundoff)*G%dyCu(I,j)))
6007-
u_L_in = min(0.0, (idir*uhr(I,j,k))*segment%Tr_InvLscale_in*resrv_lfac_in / &
6007+
u_L_in = min(0.0, (idir*uhr(I,j,k))*segment%Th_InvLscale_in*resrv_lfac_in / &
60086008
((h(i+ishift,j,k) + GV%H_subroundoff)*G%dyCu(I,j)))
60096009
fac1 = (1.0 - (a_out - a_in)) + ((u_L_out + a_out) - (u_L_in + a_in))
60106010
segment%h_Reg%h_res(I,j,k) = (1.0/fac1) * &
@@ -6039,9 +6039,9 @@ subroutine update_segment_thickness_reservoirs(G, GV, uhr, vhr, h, OBC)
60396039
if (allocated(segment%h_Reg%h_res)) then ; do k=1,nz
60406040
a_out = b_out * max(0.0, sign(1.0, jdir*vhr(i,J,k)))
60416041
a_in = b_in * min(0.0, sign(1.0, jdir*vhr(i,J,k)))
6042-
v_L_out = max(0.0, (jdir*vhr(i,J,k))*segment%Tr_InvLscale_out*resrv_lfac_out / &
6042+
v_L_out = max(0.0, (jdir*vhr(i,J,k))*segment%Th_InvLscale_out*resrv_lfac_out / &
60436043
((h(i,j+jshift,k) + GV%H_subroundoff)*G%dxCv(i,J)))
6044-
v_L_in = min(0.0, (jdir*vhr(i,J,k))*segment%Tr_InvLscale_in*resrv_lfac_in / &
6044+
v_L_in = min(0.0, (jdir*vhr(i,J,k))*segment%Th_InvLscale_in*resrv_lfac_in / &
60456045
((h(i,j+jshift,k) + GV%H_subroundoff)*G%dxCv(i,J)))
60466046
fac1 = (1.0 - (a_out - a_in)) + ((v_L_out + a_out) - (v_L_in + a_in))
60476047
segment%h_Reg%h_res(i,J,k) = (1.0/fac1) * &

src/user/Kelvin_initialization.F90

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ subroutine Kelvin_set_OBC_data(OBC, CS, G, GV, US, h, Time)
283283
segment => OBC%segment(n)
284284
if (.not. segment%on_pe) cycle
285285

286-
unrot_dir = segment%direction
287-
if (turns /= 0) unrot_dir = rotate_OBC_segment_direction(segment%direction, -turns)
286+
unrot_dir = segment%direction
287+
if (turns /= 0) unrot_dir = rotate_OBC_segment_direction(segment%direction, -turns)
288288

289289
! Apply values to the inflow end only.
290290
if ((unrot_dir == OBC_DIRECTION_E) .or. (unrot_dir == OBC_DIRECTION_N)) cycle
@@ -346,9 +346,19 @@ subroutine Kelvin_set_OBC_data(OBC, CS, G, GV, US, h, Time)
346346
enddo
347347
endif
348348
else
349-
! Baroclinic, not rotated yet (and apparently not working as intended yet).
349+
! Baroclinic, not rotated yet
350350
segment%SSH(I,j) = 0.0
351351
segment%normal_vel_bt(I,j) = 0.0
352+
! Use inside bathymetry
353+
if (segment%direction == OBC_DIRECTION_W) then
354+
depth_tot_vel = depth_tot(i+1,j)
355+
elseif (segment%direction == OBC_DIRECTION_S) then
356+
depth_tot_vel = depth_tot(i,j+1)
357+
elseif (segment%direction == OBC_DIRECTION_E) then
358+
depth_tot_vel = depth_tot(i,j)
359+
elseif (segment%direction == OBC_DIRECTION_N) then
360+
depth_tot_vel = depth_tot(i,j)
361+
endif
352362
! I suspect that the velocities in both of the following loops should instead be
353363
! normal_vel(I,j,k) = CS%inflow_amp * CS%u_struct(k) * exp(-lambda * y) * cos_wt
354364
! In addition, there should be a specification of the interface-height anomalies at the
@@ -368,6 +378,16 @@ subroutine Kelvin_set_OBC_data(OBC, CS, G, GV, US, h, Time)
368378
exp(-lambda * y) * cos(PI * CS%mode * (k - 0.5) / nz) * cos_wt
369379
enddo
370380
endif
381+
if (associated(segment%h_Reg)) then
382+
if (allocated(segment%h_Reg%h)) then
383+
do k=1,nz
384+
segment%h_Reg%h(I,j,k) = depth_tot_vel / nz + &
385+
((CS%mode * PI) * CS%inflow_amp / (N0 * nz)) * &
386+
cos(((PI * k) * CS%mode) / nz) * &
387+
exp(-lambda * y) * cos_wt
388+
enddo
389+
endif
390+
endif
371391
endif
372392
enddo ; enddo
373393
endif

0 commit comments

Comments
 (0)