Skip to content

Commit 320aac2

Browse files
marshallwardHallberg-NOAA
authored andcommitted
Remove implicit copies in CT_extract_data rotation
Following on the previous commit, the implicit copies in `extract_coupler_type_data`'s `allocate_rotated_array` and `rotate_array` are replaced with the full-sized arrays, with halos managed by `idim` and `jdim` arguments to `CT_extract_data`. I tested this in a rotated `Baltic` test and saw no answer changes. The `ocean.stats` and CFC restart files agree, but there are still known rotation reordering and negative-zero errors in `MOM.res.nc` output.
1 parent 094eb54 commit 320aac2

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/framework/MOM_coupler_types.F90

+15-9
Original file line numberDiff line numberDiff line change
@@ -391,27 +391,33 @@ subroutine extract_coupler_type_data(var_in, bc_index, array_out, scale_factor,
391391
! Local variables
392392
real, allocatable :: array_unrot(:,:) ! Array on the unrotated grid in arbitrary units [A]
393393
integer :: q_turns ! The number of quarter turns through which array_out is to be rotated
394-
integer :: index, is, ie, js, je, halo
394+
integer :: index
395395

396396
index = ind_flux ; if (present(field_index)) index = field_index
397397
q_turns = 0 ; if (present(turns)) q_turns = modulo(turns, 4)
398-
halo = 0 ; if (present(halo_size)) halo = halo_size
399398

400399
! The case with non-trivial grid rotation is complicated by the fact that the data fields
401400
! in the coupler_2d_bc_type are never rotated, so they need to be handled separately.
402401
if (q_turns == 0) then
403402
call CT_extract_data(var_in, bc_index, index, array_out, &
404-
scale_factor=scale_factor, halo_size=halo_size, idim=idim, jdim=jdim)
403+
scale_factor=scale_factor, halo_size=halo_size, idim=idim, jdim=jdim)
405404
elseif (present(idim) .and. present(jdim)) then
406-
! Work only on the computational domain plus symmetric halos.
407-
is = idim(2)-halo ; ie = idim(3)+halo ; js = jdim(2)-halo ; je = jdim(3)+halo
408-
call allocate_rotated_array(array_out(is:ie,js:je), [1,1], -q_turns, array_unrot)
409-
call CT_extract_data(var_in, bc_index, index, array_unrot, scale_factor=scale_factor, halo_size=halo)
410-
call rotate_array(array_unrot, q_turns, array_out(is:ie,js:je))
405+
call allocate_rotated_array(array_out, [1,1], -q_turns, array_unrot)
406+
407+
if (modulo(q_turns, 2) /= 0) then
408+
call CT_extract_data(var_in, bc_index, index, array_unrot, &
409+
idim=jdim, jdim=idim, scale_factor=scale_factor, halo_size=halo_size)
410+
else
411+
call CT_extract_data(var_in, bc_index, index, array_unrot, &
412+
idim=idim, jdim=jdim, scale_factor=scale_factor, halo_size=halo_size)
413+
endif
414+
415+
call rotate_array(array_unrot, q_turns, array_out)
411416
deallocate(array_unrot)
412417
else
413418
call allocate_rotated_array(array_out, [1,1], -q_turns, array_unrot)
414-
call CT_extract_data(var_in, bc_index, index, array_unrot, scale_factor=scale_factor, halo_size=halo)
419+
call CT_extract_data(var_in, bc_index, index, array_unrot, &
420+
scale_factor=scale_factor, halo_size=halo_size)
415421
call rotate_array(array_unrot, q_turns, array_out)
416422
deallocate(array_unrot)
417423
endif

0 commit comments

Comments
 (0)