Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/parameterizations/vertical/MOM_ALE_sponge.F90
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ subroutine apply_ALE_sponge(h, dt, G, GV, US, CS, Time)
real, allocatable, dimension(:,:,:) :: sp_val_u ! A temporary array for fields
real, allocatable, dimension(:,:,:) :: sp_val_v ! A temporary array for fields
real, allocatable, dimension(:,:,:) :: mask_z ! A temporary array for field mask at h pts
real, allocatable, dimension(:,:,:) :: mask_u ! A temporary array for field mask at u pts
real, allocatable, dimension(:,:,:) :: mask_v ! A temporary array for field mask at v pts
real, allocatable, dimension(:,:,:) :: tmp !< A temporary array for thermodynamic sponge tendency diagnostics,
real, allocatable, dimension(:,:,:) :: tmp_u !< A temporary array for u sponge acceleration diagnostics
real, allocatable, dimension(:,:,:) :: tmp_v !< A temporary array for v sponge acceleration diagnostics
Expand Down Expand Up @@ -994,9 +996,11 @@ subroutine apply_ALE_sponge(h, dt, G, GV, US, CS, Time)
nz_data = CS%Ref_val_u%nz_data
allocate(sp_val(G%isd:G%ied,G%jsd:G%jed,1:nz_data))
allocate(sp_val_u(G%isdB:G%iedB,G%jsd:G%jed,1:nz_data))
allocate(mask_z(G%isdB:G%iedB,G%jsd:G%jed,1:nz_data))
allocate(mask_u(G%isdB:G%iedB,G%jsd:G%jed,1:nz_data))
allocate(mask_z(G%isd:G%ied,G%jsd:G%jed,1:nz_data))
sp_val(:,:,:) = 0.0
sp_val_u(:,:,:) = 0.0
mask_u(:,:,:) = 0.0
mask_z(:,:,:) = 0.0
! Interpolate from the external horizontal grid and in time
call horiz_interp_and_extrap_tracer(CS%Ref_val_u%id, Time, 1.0, G, sp_val, mask_z, z_in, &
Expand All @@ -1006,7 +1010,8 @@ subroutine apply_ALE_sponge(h, dt, G, GV, US, CS, Time)

call pass_var(sp_val,G%Domain)
do j=CS%jsc,CS%jec; do I=CS%iscB,CS%iecB
sp_val_u(I,j,1:nz_data) = 0.5*(sp_val(i,j,1:nz_data)+sp_val(i+1,j,1:nz_data))
sp_val_u(I,j,1:nz_data) = 0.5*(sp_val(i,j,1:nz_data)+sp_val(i+1,j,1:nz_data))
mask_u(I,j,1:nz_data) = max(mask_z(i,j,1:nz_data),mask_z(i+1,j,1:nz_data))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking the average of the sp_val will potentially include a masked valued (huge value if set that way in the input file) and it will not be masked by taking the max of the mask_z. So I would suggest, if we want to keep the max of mask idea to weigh the sp_val by mask_z:
sp_val_u=(sp_val(i)*mask_z(i) + sp_val(i+1)*mask_z(i+1)) / max(mask_z(i)+mask_z(I+1),1e-10)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, that comment was for the main-GFDL-candidate ... on the same code. I added it there.

enddo ; enddo

allocate( hsrc(nz_data) )
Expand All @@ -1019,7 +1024,7 @@ subroutine apply_ALE_sponge(h, dt, G, GV, US, CS, Time)
! Build the source grid
zTopOfCell = 0. ; zBottomOfCell = 0. ; nPoints = 0; hsrc(:) = 0.0; tmpT1d(:) = -99.9
do k=1,nz_data
if (mask_z(i,j,k) == 1.0) then
if (mask_u(i,j,k) == 1.0) then
zBottomOfCell = -min( z_edges_in(k+1), G%bathyT(i,j) )
tmpT1d(k) = sp_val_u(i,j,k)
elseif (k>1) then
Expand All @@ -1030,17 +1035,18 @@ subroutine apply_ALE_sponge(h, dt, G, GV, US, CS, Time)
endif
hsrc(k) = zTopOfCell - zBottomOfCell
if (hsrc(k)>0.) nPoints = nPoints + 1
zTopOfCell = zBottomOfCell ! Bottom becomes top for next value of k
zTopOfCell = zBottomOfCell ! Bottom becomes top for next value of k
enddo
! In case data is deeper than model
hsrc(nz_data) = hsrc(nz_data) + ( zTopOfCell + G%bathyT(i,j) )
CS%Ref_val_u%h(1:nz_data,c) = GV%Z_to_H*hsrc(1:nz_data)
enddo
deallocate(sp_val, sp_val_u, mask_z, hsrc, tmpT1d)
deallocate(sp_val, sp_val_u, mask_u, mask_z, hsrc, tmpT1d)
nz_data = CS%Ref_val_v%nz_data
allocate(sp_val( G%isd:G%ied,G%jsd:G%jed,1:nz_data))
allocate(sp_val_v(G%isd:G%ied,G%jsdB:G%jedB,1:nz_data))
allocate(mask_z(G%isd:G%ied,G%jsdB:G%jedB,1:nz_data))
allocate(mask_v(G%isd:G%ied,G%jsdB:G%jedB,1:nz_data))
allocate(mask_z(G%isd:G%ied,G%jsd:G%jed,1:nz_data))
sp_val(:,:,:) = 0.0
sp_val_v(:,:,:) = 0.0
mask_z(:,:,:) = 0.0
Expand All @@ -1052,6 +1058,7 @@ subroutine apply_ALE_sponge(h, dt, G, GV, US, CS, Time)
call pass_var(sp_val,G%Domain)
do J=CS%jscB,CS%jecB; do i=CS%isc,CS%iec
sp_val_v(i,J,1:nz_data) = 0.5*(sp_val(i,j,1:nz_data)+sp_val(i,j+1,1:nz_data))
mask_v(i,J,1:nz_data) = max(mask_z(i,j,1:nz_data),mask_z(i,j+1,1:nz_data))
enddo ; enddo
!call pass_var(mask_z,G%Domain)
allocate( hsrc(nz_data) )
Expand All @@ -1064,7 +1071,7 @@ subroutine apply_ALE_sponge(h, dt, G, GV, US, CS, Time)
! Build the source grid
zTopOfCell = 0. ; zBottomOfCell = 0. ; nPoints = 0; hsrc(:) = 0.0; tmpT1d(:) = -99.9
do k=1,nz_data
if (mask_z(i,j,k) == 1.0) then
if (mask_v(i,j,k) == 1.0) then
zBottomOfCell = -min( z_edges_in(k+1), G%bathyT(i,j) )
tmpT1d(k) = sp_val_v(i,j,k)
elseif (k>1) then
Expand All @@ -1081,7 +1088,7 @@ subroutine apply_ALE_sponge(h, dt, G, GV, US, CS, Time)
hsrc(nz_data) = hsrc(nz_data) + ( zTopOfCell + G%bathyT(i,j) )
CS%Ref_val_v%h(1:nz_data,c) = GV%Z_to_H*hsrc(1:nz_data)
enddo
deallocate(sp_val, sp_val_v, mask_z, hsrc, tmpT1d)
deallocate(sp_val, sp_val_v, mask_v, mask_z, hsrc, tmpT1d)
endif

nz_data = CS%Ref_val_u%nz_data
Expand Down Expand Up @@ -1282,7 +1289,7 @@ subroutine rotate_ALE_sponge(sponge_in, G_in, sponge, G, GV, turns, param_file)
endif
enddo

! TODO: var_u and var_v sponge dampling is not yet supported.
! TODO: var_u and var_v sponge damping is not yet supported.
if (associated(sponge_in%var_u%p) .or. associated(sponge_in%var_v%p)) &
call MOM_error(FATAL, "Rotation of ALE sponge velocities is not yet " &
// "implemented.")
Expand Down
2 changes: 1 addition & 1 deletion src/parameterizations/vertical/MOM_internal_tide_input.F90
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ subroutine int_tide_input_init(Time, G, GV, US, param_file, diag, CS, itide)
units="m-1", default=8.e-4*atan(1.0), scale=US%L_to_m)

call get_param(param_file, mdl, "KAPPA_H2_FACTOR", kappa_h2_factor, &
"A scaling factor for the roughness amplitude with n"//&
"A scaling factor for the roughness amplitude with "//&
"INT_TIDE_DISSIPATION.", units="nondim", default=1.0)
call get_param(param_file, mdl, "TKE_ITIDE_MAX", CS%TKE_itide_max, &
"The maximum internal tide energy source available to mix "//&
Expand Down
2 changes: 1 addition & 1 deletion src/user/Kelvin_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module Kelvin_initialization
real :: coast_angle = 0 !< Angle of coastline [rad]
real :: coast_offset1 = 0 !< Longshore distance to coastal angle [L ~> m]
real :: coast_offset2 = 0 !< Longshore distance to coastal angle [L ~> m]
real :: H0 = 0 !< Bottom depth [Z ~> m]f
real :: H0 = 0 !< Bottom depth [Z ~> m]
real :: F_0 !< Coriolis parameter [T-1 ~> s-1]
real :: rho_range !< Density range [R ~> kg m-3]
real :: rho_0 !< Mean density [R ~> kg m-3]
Expand Down