From 8912b134006b7cc18c50dd4e10f4926e2afe1e93 Mon Sep 17 00:00:00 2001 From: He Wang Date: Fri, 19 Feb 2021 22:47:31 -0500 Subject: [PATCH 1/4] Fix the bug that Rayleigh_[uv] was not initialized in MOM_barotropic --- src/core/MOM_barotropic.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/MOM_barotropic.F90 b/src/core/MOM_barotropic.F90 index 628f8e1c39..443905dccf 100644 --- a/src/core/MOM_barotropic.F90 +++ b/src/core/MOM_barotropic.F90 @@ -948,11 +948,13 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, do j=CS%jsdw,CS%jedw ; do I=CS%isdw-1,CS%iedw Cor_ref_u(I,j) = 0.0 ; BT_force_u(I,j) = 0.0 ; ubt(I,j) = 0.0 Datu(I,j) = 0.0 ; bt_rem_u(I,j) = 0.0 ; uhbt0(I,j) = 0.0 + Rayleigh_u(I,j) = 0.0 enddo ; enddo !$OMP parallel do default(shared) do J=CS%jsdw-1,CS%jedw ; do i=CS%isdw,CS%iedw Cor_ref_v(i,J) = 0.0 ; BT_force_v(i,J) = 0.0 ; vbt(i,J) = 0.0 Datv(i,J) = 0.0 ; bt_rem_v(i,J) = 0.0 ; vhbt0(i,J) = 0.0 + Rayleigh_v(i,J) = 0.0 enddo ; enddo ! Copy input arrays into their wide-halo counterparts. From 42eb7c7dfe9e08d5b2037f17e78474f80414fabc Mon Sep 17 00:00:00 2001 From: He Wang Date: Wed, 24 Feb 2021 12:17:42 -0500 Subject: [PATCH 2/4] 1. Initialize Rayleigh_[uv] to separate loops 2. Split the loop that addes Rayleigh drag term to [uv]_accel_bt, so that the if-block is now outside the loop --- src/core/MOM_barotropic.F90 | 88 +++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 24 deletions(-) diff --git a/src/core/MOM_barotropic.F90 b/src/core/MOM_barotropic.F90 index 443905dccf..2c496c77bc 100644 --- a/src/core/MOM_barotropic.F90 +++ b/src/core/MOM_barotropic.F90 @@ -948,15 +948,24 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, do j=CS%jsdw,CS%jedw ; do I=CS%isdw-1,CS%iedw Cor_ref_u(I,j) = 0.0 ; BT_force_u(I,j) = 0.0 ; ubt(I,j) = 0.0 Datu(I,j) = 0.0 ; bt_rem_u(I,j) = 0.0 ; uhbt0(I,j) = 0.0 - Rayleigh_u(I,j) = 0.0 enddo ; enddo !$OMP parallel do default(shared) do J=CS%jsdw-1,CS%jedw ; do i=CS%isdw,CS%iedw Cor_ref_v(i,J) = 0.0 ; BT_force_v(i,J) = 0.0 ; vbt(i,J) = 0.0 Datv(i,J) = 0.0 ; bt_rem_v(i,J) = 0.0 ; vhbt0(i,J) = 0.0 - Rayleigh_v(i,J) = 0.0 enddo ; enddo + if (CS%linear_wave_drag) then + !$OMP parallel do default(shared) + do j=CS%jsdw,CS%jedw ; do I=CS%isdw-1,CS%iedw + Rayleigh_u(I,j) = 0.0 + enddo ; enddo + !$OMP parallel do default(shared) + do J=CS%jsdw-1,CS%jedw ; do i=CS%isdw,CS%iedw + Rayleigh_v(i,J) = 0.0 + enddo ; enddo + endif + ! Copy input arrays into their wide-halo counterparts. if (interp_eta_PF) then !$OMP parallel do default(shared) @@ -1902,21 +1911,28 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, endif ; enddo ; enddo !$OMP end do nowait endif + !$OMP do schedule(static) do J=jsv-1,jev ; do i=isv-1,iev+1 vel_prev = vbt(i,J) vbt(i,J) = bt_rem_v(i,J) * (vbt(i,J) + & dtbt * ((BT_force_v(i,J) + Cor_v(i,J)) + PFv(i,J))) vbt_trans(i,J) = trans_wt1*vbt(i,J) + trans_wt2*vel_prev + enddo ; enddo - if (CS%linear_wave_drag) then + if (CS%linear_wave_drag) then + !$OMP do schedule(static) + do J=jsv-1,jev ; do i=isv-1,iev+1 v_accel_bt(i,J) = v_accel_bt(i,J) + wt_accel(n) * & ((Cor_v(i,J) + PFv(i,J)) - vbt(i,J)*Rayleigh_v(i,J)) - else + enddo ; enddo + else + !$OMP do schedule(static) + do J=jsv-1,jev ; do i=isv-1,iev+1 v_accel_bt(i,J) = v_accel_bt(i,J) + wt_accel(n) * (Cor_v(i,J) + PFv(i,J)) - endif - enddo ; enddo - + enddo ; enddo + endif + if (integral_BT_cont) then !$OMP do schedule(static) do J=jsv-1,jev ; do i=isv-1,iev+1 @@ -1971,22 +1987,31 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, endif ; enddo ; enddo !$OMP end do nowait endif + !$OMP do schedule(static) do j=jsv,jev ; do I=isv-1,iev vel_prev = ubt(I,j) ubt(I,j) = bt_rem_u(I,j) * (ubt(I,j) + & dtbt * ((BT_force_u(I,j) + Cor_u(I,j)) + PFu(I,j))) if (abs(ubt(I,j)) < CS%vel_underflow) ubt(I,j) = 0.0 - ubt_trans(I,j) = trans_wt1*ubt(I,j) + trans_wt2*vel_prev + ubt_trans(I,j) = trans_wt1*ubt(I,j) + trans_wt2*vel_prev + enddo ; enddo + !$OMP end do nowait - if (CS%linear_wave_drag) then + if (CS%linear_wave_drag) then + !$OMP do schedule(static) + do j=jsv,jev ; do I=isv-1,iev u_accel_bt(I,j) = u_accel_bt(I,j) + wt_accel(n) * & - ((Cor_u(I,j) + PFu(I,j)) - ubt(I,j)*Rayleigh_u(I,j)) - else + ((Cor_u(I,j) + PFu(I,j)) - ubt(I,j)*Rayleigh_u(I,j)) + enddo ; enddo + !$OMP end do nowait + else + !$OMP do schedule(static) + do j=jsv,jev ; do I=isv-1,iev u_accel_bt(I,j) = u_accel_bt(I,j) + wt_accel(n) * (Cor_u(I,j) + PFu(I,j)) - endif - enddo ; enddo - !$OMP end do nowait + enddo ; enddo + !$OMP end do nowait + endif if (integral_BT_cont) then !$OMP do schedule(static) @@ -2048,14 +2073,20 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, dtbt * ((BT_force_u(I,j) + Cor_u(I,j)) + PFu(I,j))) if (abs(ubt(I,j)) < CS%vel_underflow) ubt(I,j) = 0.0 ubt_trans(I,j) = trans_wt1*ubt(I,j) + trans_wt2*vel_prev + enddo ; enddo - if (CS%linear_wave_drag) then + if (CS%linear_wave_drag) then + !$OMP do schedule(static) + do j=jsv-1,jev+1 ; do I=isv-1,iev u_accel_bt(I,j) = u_accel_bt(I,j) + wt_accel(n) * & ((Cor_u(I,j) + PFu(I,j)) - ubt(I,j)*Rayleigh_u(I,j)) - else + enddo ; enddo + else + !$OMP do schedule(static) + do j=jsv-1,jev+1 ; do I=isv-1,iev u_accel_bt(I,j) = u_accel_bt(I,j) + wt_accel(n) * (Cor_u(I,j) + PFu(I,j)) - endif - enddo ; enddo + enddo ; enddo + endif if (integral_BT_cont) then !$OMP do schedule(static) @@ -2130,15 +2161,24 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, dtbt * ((BT_force_v(i,J) + Cor_v(i,J)) + PFv(i,J))) if (abs(vbt(i,J)) < CS%vel_underflow) vbt(i,J) = 0.0 vbt_trans(i,J) = trans_wt1*vbt(i,J) + trans_wt2*vel_prev + enddo ; enddo + !$OMP end do nowait - if (CS%linear_wave_drag) then + if (CS%linear_wave_drag) then + !$OMP do schedule(static) + do J=jsv-1,jev ; do i=isv,iev v_accel_bt(i,J) = v_accel_bt(i,J) + wt_accel(n) * & - ((Cor_v(i,J) + PFv(i,J)) - vbt(i,J)*Rayleigh_v(i,J)) - else + ((Cor_v(i,J) + PFv(i,J)) - vbt(i,J)*Rayleigh_v(i,J)) + enddo ; enddo + !$OMP end do nowait + else + !$OMP do schedule(static) + do J=jsv-1,jev ; do i=isv,iev v_accel_bt(i,J) = v_accel_bt(i,J) + wt_accel(n) * (Cor_v(i,J) + PFv(i,J)) - endif - enddo ; enddo - !$OMP end do nowait + enddo ; enddo + !$OMP end do nowait + endif + if (integral_BT_cont) then !$OMP do schedule(static) do J=jsv-1,jev ; do i=isv,iev From a0b296e45b30224a05fa285442080c52814323b8 Mon Sep 17 00:00:00 2001 From: He Wang Date: Wed, 24 Feb 2021 12:58:33 -0500 Subject: [PATCH 3/4] Remove the trailing space --- src/core/MOM_barotropic.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/MOM_barotropic.F90 b/src/core/MOM_barotropic.F90 index 2c496c77bc..962df7d0a2 100644 --- a/src/core/MOM_barotropic.F90 +++ b/src/core/MOM_barotropic.F90 @@ -1994,7 +1994,7 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, ubt(I,j) = bt_rem_u(I,j) * (ubt(I,j) + & dtbt * ((BT_force_u(I,j) + Cor_u(I,j)) + PFu(I,j))) if (abs(ubt(I,j)) < CS%vel_underflow) ubt(I,j) = 0.0 - ubt_trans(I,j) = trans_wt1*ubt(I,j) + trans_wt2*vel_prev + ubt_trans(I,j) = trans_wt1*ubt(I,j) + trans_wt2*vel_prev enddo ; enddo !$OMP end do nowait From 9544de2de4c7f6d0a82a718a9cb93570a80592b5 Mon Sep 17 00:00:00 2001 From: He Wang Date: Wed, 24 Feb 2021 13:05:01 -0500 Subject: [PATCH 4/4] Remove blank line spaces --- src/core/MOM_barotropic.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/MOM_barotropic.F90 b/src/core/MOM_barotropic.F90 index 962df7d0a2..545b7fabf7 100644 --- a/src/core/MOM_barotropic.F90 +++ b/src/core/MOM_barotropic.F90 @@ -1932,7 +1932,7 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, v_accel_bt(i,J) = v_accel_bt(i,J) + wt_accel(n) * (Cor_v(i,J) + PFv(i,J)) enddo ; enddo endif - + if (integral_BT_cont) then !$OMP do schedule(static) do J=jsv-1,jev ; do i=isv-1,iev+1