Skip to content

Commit

Permalink
Fix a bug with dyn_prep2. (CICE-Consortium#48)
Browse files Browse the repository at this point in the history
* Add some print statements

* Some print statements

* Fix a bug with dyn_prep2 and change the order of interpolations and halo updates

* Update icepack
  • Loading branch information
dabail10 authored Dec 22, 2021
1 parent 0809cde commit bd59fb0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 41 deletions.
70 changes: 30 additions & 40 deletions cicecore/cicedynB/dynamics/ice_dyn_evp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ subroutine evp (dt)
uocnE (:,:,iblk), vocnE (:,:,iblk), &
strairxE (:,:,iblk), strairyE (:,:,iblk), &
ss_tltxE (:,:,iblk), ss_tltyE (:,:,iblk), &
icetmask (:,:,iblk), icenmask (:,:,iblk), &
icetmask (:,:,iblk), iceemask (:,:,iblk), &
fmE (:,:,iblk), dt, &
strtltxE (:,:,iblk), strtltyE (:,:,iblk), &
strocnxE (:,:,iblk), strocnyE (:,:,iblk), &
Expand All @@ -520,16 +520,6 @@ subroutine evp (dt)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)

call ice_timer_start(timer_bound)
call ice_HaloUpdate (strength, halo_info, &
field_loc_center, field_type_scalar)
! velocities may have changed in dyn_prep2
call stack_velocity_field(uvel, vvel, fld2)
call ice_HaloUpdate (fld2, halo_info, &
field_loc_NEcorner, field_type_vector)
call unstack_velocity_field(fld2, uvel, vvel)
call ice_timer_stop(timer_bound)

if (grid_ice == 'CD') then

call ice_timer_start(timer_bound)
Expand All @@ -545,8 +535,21 @@ subroutine evp (dt)
call unstack_velocity_field(fld2, uvelE, vvelE)
call ice_timer_stop(timer_bound)

call grid_average_X2Y('S',uvelE,'E',uvel,'U')
call grid_average_X2Y('S',vvelN,'N',vvel,'U')
endif

call ice_timer_start(timer_bound)
call ice_HaloUpdate (strength, halo_info, &
field_loc_center, field_type_scalar)

! velocities may have changed in dyn_prep2
call stack_velocity_field(uvel, vvel, fld2)
call ice_HaloUpdate (fld2, halo_info, &
field_loc_NEcorner, field_type_vector)
call unstack_velocity_field(fld2, uvel, vvel)
call ice_timer_stop(timer_bound)

if (maskhalo_dyn) then
call ice_timer_start(timer_bound)
halomask = 0
Expand Down Expand Up @@ -658,13 +661,6 @@ subroutine evp (dt)

do ksub = 1,ndte ! subcycling

! shift velocity components from CD grid locations (N, E) to B grid location (U) for stress_U

if (grid_ice == 'CD') then
call grid_average_X2Y('S',uvelE,'E',uvel,'U')
call grid_average_X2Y('S',vvelN,'N',vvel,'U')
endif

!-----------------------------------------------------------------
! stress tensor equation, total surface stress
!-----------------------------------------------------------------
Expand Down Expand Up @@ -806,35 +802,36 @@ subroutine evp (dt)
enddo
!$TCXOMP END PARALLEL DO

call stack_velocity_field(uvel, vvel, fld2)
call ice_timer_start(timer_bound)
if (maskhalo_dyn) then
call ice_HaloUpdate (fld2, halo_info_mask, &
field_loc_NEcorner, field_type_vector)
else
call ice_HaloUpdate (fld2, halo_info, &
field_loc_NEcorner, field_type_vector)
endif
call ice_timer_stop(timer_bound)
call unstack_velocity_field(fld2, uvel, vvel)

if (grid_ice == 'CD') then

call ice_timer_start(timer_bound)
! velocities may have changed in dyn_prep2
call stack_velocity_field(uvelN, vvelN, fld2)
call ice_HaloUpdate (fld2, halo_info, &
field_loc_Nface, field_type_vector)
call unstack_velocity_field(fld2, uvelN, vvelN)
! velocities may have changed in dyn_prep2
call stack_velocity_field(uvelE, vvelE, fld2)
call ice_HaloUpdate (fld2, halo_info, &
field_loc_Eface, field_type_vector)
call unstack_velocity_field(fld2, uvelE, vvelE)
call ice_timer_stop(timer_bound)

call grid_average_X2Y('S',uvelE,'E',uvel,'U')
call grid_average_X2Y('S',vvelN,'N',vvel,'U')

endif

call ice_timer_start(timer_bound)
call stack_velocity_field(uvel, vvel, fld2)
if (maskhalo_dyn) then
call ice_HaloUpdate (fld2, halo_info_mask, &
field_loc_NEcorner, field_type_vector)
else
call ice_HaloUpdate (fld2, halo_info, &
field_loc_NEcorner, field_type_vector)
endif
call unstack_velocity_field(fld2, uvel, vvel)
call ice_timer_stop(timer_bound)

enddo ! subcycling
endif ! evp_algorithm

Expand Down Expand Up @@ -992,12 +989,6 @@ subroutine evp (dt)
call grid_average_X2Y('F',work1,'U',strocnxT,'T') ! shift
call grid_average_X2Y('F',work2,'U',strocnyT,'T')

! shift velocity components from CD grid locations (N, E) to B grid location (U) for transport
if (grid_ice == 'CD') then
call grid_average_X2Y('S',uvelE,'E',uvel,'U')
call grid_average_X2Y('S',vvelN,'N',vvel,'U')
endif

call ice_timer_stop(timer_dynamics) ! dynamics

end subroutine evp
Expand Down Expand Up @@ -1533,7 +1524,7 @@ subroutine stress_U (nx_block, ny_block, &
ratiodyE , & ! -dyE(i,j+1)/dyE(i,j) factor for BCs across coastline
ratiodyEr, & ! -dyE(i,j)/dyE(i,j+1) factor for BCs across coastline
epm , & ! E-cell mask
npm , & ! E-cell mask
npm , & ! N-cell mask
hm , & ! T-cell mask
uvm , & ! U-cell mask
zetax2T , & ! 2*zeta at the T point
Expand Down Expand Up @@ -1714,7 +1705,6 @@ subroutine div_stress (nx_block, ny_block, &
case default
call abort_ice(subname // ' unknown grid_location: ' // grid_location)
end select


enddo ! ij

Expand Down
2 changes: 1 addition & 1 deletion cicecore/cicedynB/dynamics/ice_dyn_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ subroutine strain_rates_U (nx_block, ny_block, &
ratiodyE , & ! -dyE(i,j+1)/dyE(i,j) for BCs
ratiodyEr, & ! -dyE(i,j)/dyE(i,j+1) for BCs
epm , & ! E-cell mask
npm , & ! E-cell mask
npm , & ! N-cell mask
uvm ! U-cell mask


Expand Down

0 comments on commit bd59fb0

Please sign in to comment.