Skip to content

Commit c83e238

Browse files
committed
Correct indexing when using ocean_public_type
- The ocean_public_type uses global indexing without halos.
1 parent 1f39c84 commit c83e238

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

config_src/mct_driver/coupler_indices.F90

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,29 @@ subroutine ocn_export(ind, ocn_public, grid, o2x)
212212
real(kind=8), intent(inout) :: o2x(:,:) !< MCT outgoing bugger
213213
! Local variables
214214
real, dimension(grid%isd:grid%ied,grid%jsd:grid%jed) :: ssh !< Local copy of sea_lev with updated halo
215-
integer :: i, j, n
215+
integer :: i, j, n, ig, jg
216216
real :: slp_L, slp_R, slp_C, slope, u_min, u_max
217217

218+
! Copy from ocn_public to o2x. ocn_public uses global indexing with no halos.
219+
! The mask comes from "grid" that uses the usual MOM domain that has halos
220+
! and does not use global indexing.
218221
n = 0
219-
do j=grid%jsc, grid%jec ; do i=grid%isc,grid%iec
220-
n = n+1
221-
o2x(ind%o2x_So_t, n) = ocn_public%t_surf(i,j) * grid%mask2dT(i,j)
222-
o2x(ind%o2x_So_s, n) = ocn_public%s_surf(i,j) * grid%mask2dT(i,j)
223-
o2x(ind%o2x_So_u, n) = ocn_public%u_surf(i,j) * grid%mask2dT(i,j)
224-
o2x(ind%o2x_So_v, n) = ocn_public%v_surf(i,j) * grid%mask2dT(i,j)
225-
end do; end do
226-
227-
! ssh (make a copy in order to do a halo update)
228-
do j=grid%jsc, grid%jec ; do i=grid%isc,grid%iec
229-
ssh(i,j) = ocn_public%sea_lev(i,j)
230-
end do; end do
222+
do j=grid%jsc, grid%jec
223+
jg = j + grid%jdg_offset
224+
do i=grid%isc,grid%iec
225+
n = n+1
226+
ig = i + grid%idg_offset
227+
o2x(ind%o2x_So_t, n) = ocn_public%t_surf(ig,jg) * grid%mask2dT(i,j)
228+
o2x(ind%o2x_So_s, n) = ocn_public%s_surf(ig,jg) * grid%mask2dT(i,j)
229+
o2x(ind%o2x_So_u, n) = ocn_public%u_surf(ig,jg) * grid%mask2dT(i,j)
230+
o2x(ind%o2x_So_v, n) = ocn_public%v_surf(ig,jg) * grid%mask2dT(i,j)
231+
! Make a copy of ssh in order to do a halo update. We use the usual MOM domain
232+
! in order to update halos. i.e. does not use global indexing.
233+
ssh(i,j) = ocn_public%sea_lev(ig,jg)
234+
end do
235+
end do
236+
237+
! Update halo of ssh so we can calculate gradients
231238
call pass_var(ssh, grid%domain)
232239

233240
! d/dx ssh

0 commit comments

Comments
 (0)