Skip to content

Commit

Permalink
ice_dyn_vp: remove unused subroutine and cleanup interfaces
Browse files Browse the repository at this point in the history
The previous commit removed the last caller of 'calc_L2norm_squared'.
Remove the subroutine.

Also, do not compute 'sum_squared' in 'residual_vec', since the variable
'L2norm' which receives this value is also unused in 'anderson_solver'
since the previous commit. Remove that variable, and adjust the
interface of 'residual_vec' accordingly.
  • Loading branch information
phil-blain committed Oct 5, 2022
1 parent 6aab357 commit 5a8b2d1
Showing 1 changed file with 3 additions and 66 deletions.
69 changes: 3 additions & 66 deletions cicecore/cicedynB/dynamics/ice_dyn_vp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,6 @@ subroutine anderson_solver (icellt , icellu , &
stress_Pr, & ! x,y-derivatives of the replacement pressure
diag_rheo ! contributions of the rhelogy term to the diagonal

real (kind=dbl_kind), dimension (max_blocks) :: &
L2norm ! array used to compute l^2 norm of grid function

real (kind=dbl_kind), dimension (ntot) :: &
res , & ! current residual
res_old , & ! previous residual
Expand Down Expand Up @@ -821,7 +818,6 @@ subroutine anderson_solver (icellt , icellu , &

! Initialization
res_num = 0
L2norm = c0

!$OMP PARALLEL DO PRIVATE(iblk)
do iblk = 1, nblocks
Expand Down Expand Up @@ -899,8 +895,7 @@ subroutine anderson_solver (icellt , icellu , &
indxui (:,iblk), indxuj (:,iblk), &
bx (:,:,iblk), by (:,:,iblk), &
Au (:,:,iblk), Av (:,:,iblk), &
Fx (:,:,iblk), Fy (:,:,iblk), &
L2norm (iblk))
Fx (:,:,iblk), Fy (:,:,iblk))
enddo
!$OMP END PARALLEL DO
nlres_norm = global_norm(nx_block, ny_block, &
Expand Down Expand Up @@ -1968,8 +1963,7 @@ subroutine residual_vec (nx_block , ny_block, &
indxui , indxuj , &
bx , by , &
Au , Av , &
Fx , Fy , &
sum_squared)
Fx , Fy )

integer (kind=int_kind), intent(in) :: &
nx_block, ny_block, & ! block dimensions
Expand All @@ -1989,9 +1983,6 @@ subroutine residual_vec (nx_block , ny_block, &
Fx , & ! x residual vector, Fx = bx - Au (N/m^2)
Fy ! y residual vector, Fy = by - Av (N/m^2)

real (kind=dbl_kind), intent(out), optional :: &
sum_squared ! sum of squared residual vector components

! local variables

integer (kind=int_kind) :: &
Expand All @@ -2000,22 +1991,15 @@ subroutine residual_vec (nx_block , ny_block, &
character(len=*), parameter :: subname = '(residual_vec)'

!-----------------------------------------------------------------
! compute residual and sum its squared components
! compute residual
!-----------------------------------------------------------------

if (present(sum_squared)) then
sum_squared = c0
endif

do ij = 1, icellu
i = indxui(ij)
j = indxuj(ij)

Fx(i,j) = bx(i,j) - Au(i,j)
Fy(i,j) = by(i,j) - Av(i,j)
if (present(sum_squared)) then
sum_squared = sum_squared + Fx(i,j)**2 + Fy(i,j)**2
endif
enddo ! ij

end subroutine residual_vec
Expand Down Expand Up @@ -2479,53 +2463,6 @@ end subroutine formDiag_step2

!=======================================================================

! Compute squared l^2 norm of a grid function (tpu,tpv)

subroutine calc_L2norm_squared (nx_block, ny_block, &
icellu , &
indxui , indxuj , &
tpu , tpv , &
L2norm)

integer (kind=int_kind), intent(in) :: &
nx_block, ny_block, & ! block dimensions
icellu ! total count when iceumask is true

integer (kind=int_kind), dimension (nx_block*ny_block), intent(in) :: &
indxui , & ! compressed index in i-direction
indxuj ! compressed index in j-direction

real (kind=dbl_kind), dimension (nx_block,ny_block), intent(in) :: &
tpu , & ! x-component of vector grid function
tpv ! y-component of vector grid function

real (kind=dbl_kind), intent(out) :: &
L2norm ! squared l^2 norm of vector grid function (tpu,tpv)

! local variables

integer (kind=int_kind) :: &
i, j, ij

character(len=*), parameter :: subname = '(calc_L2norm_squared)'

!-----------------------------------------------------------------
! compute squared l^2 norm of vector grid function (tpu,tpv)
!-----------------------------------------------------------------

L2norm = c0

do ij = 1, icellu
i = indxui(ij)
j = indxuj(ij)

L2norm = L2norm + tpu(i,j)**2 + tpv(i,j)**2
enddo ! ij

end subroutine calc_L2norm_squared

!=======================================================================

! Compute global l^2 norm of a vector field (field_x, field_y)

function global_norm (nx_block, ny_block, &
Expand Down

0 comments on commit 5a8b2d1

Please sign in to comment.