Skip to content

Commit

Permalink
Get h averaging right on u, v grids. #62
Browse files Browse the repository at this point in the history
  • Loading branch information
nichannah committed Jul 14, 2015
1 parent ce52f76 commit 2f7ce5b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/framework/MOM_diag_mediator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ subroutine remap_diag_to_z(field, diag, diag_cs, remapped_field)

real, dimension(diag_cs%nz_remap+1) :: dz
real, dimension(diag_cs%nz_remap) :: h_dest
real, dimension(size(diag_cs%h, 3)) :: h_src
integer :: nz_src, nz_dest
integer :: i, j, k

Expand All @@ -676,14 +677,16 @@ subroutine remap_diag_to_z(field, diag, diag_cs, remapped_field)
endif

h_dest(:) = diag_cs%zi_u(i, j, 2:) - diag_cs%zi_u(i, j, :size(diag_cs%zi_u, 3)-1)
call dzFromH1H2(nz_src, diag_cs%h(i, j, :), nz_dest, h_dest(:), dz)
call remapping_core(diag_cs%remap_cs, nz_src, diag_cs%h(i, j, :), &
h_src(:) = 0.5 * (diag_cs%h(i,j,:) + diag_cs%h(i+1,j,:))
call dzFromH1H2(nz_src, h_src(:), nz_dest, h_dest(:), dz)
call remapping_core(diag_cs%remap_cs, nz_src, h_src(:), &
field(i, j, :), nz_dest, dz, remapped_field(i, j, :))

! Lower levels of the remapped data get squashed to follow bathymetry,
! If their nominal depth is below the bathymetry remove.
do k=1, nz_dest
if (diag_cs%zi_remap(k) >= diag_cs%G%bathyT(i, j)) then
!if (diag_cs%zi_remap(k) >= diag_cs%G%bathyT(i, j)) then
if (diag_cs%zi_u(i, j, k) >= diag_cs%G%bathyT(i, j)) then
remapped_field(i, j, k:nz_dest) = diag_cs%missing_value
exit
endif
Expand All @@ -701,11 +704,13 @@ subroutine remap_diag_to_z(field, diag, diag_cs, remapped_field)
endif

h_dest(:) = diag_cs%zi_v(i, j, 2:) - diag_cs%zi_v(i, j, :size(diag_cs%zi_v, 3)-1)
call dzFromH1H2(nz_src, diag_cs%h(i, j, :), nz_dest, h_dest(:), dz)
call remapping_core(diag_cs%remap_cs, nz_src, diag_cs%h(i, j, :), &
h_src(:) = 0.5 * (diag_cs%h(i,j,:) + diag_cs%h(i,j+1,:))
call dzFromH1H2(nz_src, h_src(:), nz_dest, h_dest(:), dz)
call remapping_core(diag_cs%remap_cs, nz_src, h_src(:), &
field(i, j, :), nz_dest, dz, remapped_field(i, j, :))
do k=1, nz_dest
if (diag_cs%zi_remap(k) >= diag_cs%G%bathyT(i, j)) then
!if (diag_cs%zi_remap(k) >= diag_cs%G%bathyT(i, j)) then
if (diag_cs%zi_v(i, j, k) >= diag_cs%G%bathyT(i, j)) then
remapped_field(i, j, k:nz_dest) = diag_cs%missing_value
exit
endif
Expand All @@ -725,7 +730,8 @@ subroutine remap_diag_to_z(field, diag, diag_cs, remapped_field)
call remapping_core(diag_cs%remap_cs, nz_src, diag_cs%h(i, j, :), &
field(i, j, :), nz_dest, dz, remapped_field(i, j, :))
do k=1, nz_dest
if (diag_cs%zi_remap(k) >= diag_cs%G%bathyT(i, j)) then
!if (diag_cs%zi_remap(k) >= diag_cs%G%bathyT(i, j)) then
if (diag_cs%zi_T(i, j, k) >= diag_cs%G%bathyT(i, j)) then
remapped_field(i, j, k:nz_dest) = diag_cs%missing_value
exit
endif
Expand Down

0 comments on commit 2f7ce5b

Please sign in to comment.