Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: FGNV streamfunction vertical bounds #1346

Merged
merged 2 commits into from
Mar 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/parameterizations/lateral/MOM_thickness_diffuse.F90
Original file line number Diff line number Diff line change
Expand Up @@ -993,10 +993,14 @@ subroutine thickness_diffuse_full(h, e, Kh_u, Kh_v, tv, uhD, vhD, cg1, dt, G, GV
! Solve an elliptic equation for the streamfunction following Ferrari et al., 2010.
do I=is-1,ie
if (G%mask2dCu(I,j)>0.) then
Sfn_unlim_u(I,:) = ( 1. + CS%FGNV_scale ) * Sfn_unlim_u(I,:)
do K=2,nz
Sfn_unlim_u(I,K) = (1. + CS%FGNV_scale) * Sfn_unlim_u(I,K)
Copy link
Collaborator

@sanAkel sanAkel Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome 👏 thank you @marshallward

Any reason why it can't be
vectorized? e.g.,
x(index1_range, index2_range) =0. (I understand the compiler may do it!)

  • Do you anticipate different behavior for different optimizations?
  • violates coding style?
  • something else?

Copy link
Collaborator Author

@marshallward marshallward Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think Sfn_unlim_[uv](2:nz) = ... would have been OK here, other than that it's discouraged by the style guide (although your example might be permitted).

This next line is a very explicit break from the style guide:

call streamfn_solver(nz, c2_h_v(i,:), hN2_v(i,:), Sfn_unlim_v(i,:))

due to the sliced array inputs - and the implicit 1D arrays - but they are only 1D arrays so I figured let's leave it for another day.

I wouldn't expect vectorization to be affected in this case, but compilers always have a surprise or two.

enddo
call streamfn_solver(nz, c2_h_u(I,:), hN2_u(I,:), Sfn_unlim_u(I,:))
else
Sfn_unlim_u(I,:) = 0.
do K=2,nz
Sfn_unlim_u(I,K) = 0.
enddo
endif
enddo
endif
Expand Down Expand Up @@ -1259,10 +1263,14 @@ subroutine thickness_diffuse_full(h, e, Kh_u, Kh_v, tv, uhD, vhD, cg1, dt, G, GV
! Solve an elliptic equation for the streamfunction following Ferrari et al., 2010.
do i=is,ie
if (G%mask2dCv(i,J)>0.) then
Sfn_unlim_v(i,:) = ( 1. + CS%FGNV_scale ) * Sfn_unlim_v(i,:)
do K=2,nz
Sfn_unlim_v(i,K) = (1. + CS%FGNV_scale) * Sfn_unlim_v(i,K)
enddo
call streamfn_solver(nz, c2_h_v(i,:), hN2_v(i,:), Sfn_unlim_v(i,:))
else
Sfn_unlim_v(i,:) = 0.
do K=2,nz
Sfn_unlim_v(i,K) = 0.
enddo
endif
enddo
endif
Expand Down