Skip to content

Commit

Permalink
Avoid divide by zero in horizontal_viscosity() with better_bound_kh
Browse files Browse the repository at this point in the history
- I division by zero was encountered when using the back-scatter settings
  (negative viscosity) in NeverWorld2. It appears hrat_min(I,J) can be
  zero. Reading the code, it makes sense that hrat_min can be zero.
  The division was previously made conditional in 14971b4 also
  when using backscatter, but then only one part of the denomitor was used
  in the conditional.
- I'm not sure why the backscatter setup is repeatedly hitting these edge
  cases or specific line of code.
- This fix uses the entire denominator in the conditional.
  • Loading branch information
adcroft authored and marshallward committed Jan 25, 2022
1 parent 9f0018f commit 03a247e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/parameterizations/lateral/MOM_hor_visc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1308,8 +1308,8 @@ subroutine horizontal_viscosity(u, v, h, diffu, diffv, MEKE, VarMix, G, GV, US,
if (Kh(i,j) >= hrat_min(i,j) * CS%Kh_Max_xy(I,J)) then
visc_bound_rem(i,j) = 0.0
Kh(i,j) = hrat_min(i,j) * CS%Kh_Max_xy(I,J)
elseif (CS%Kh_Max_xy(I,J)>0.) then
visc_bound_rem(i,j) = 1.0 - Kh(i,j) / (hrat_min(i,j) * CS%Kh_Max_xy(I,J))
elseif (hrat_min(I,J)*CS%Kh_Max_xy(I,J)>0.) then
endif
endif

Expand Down

0 comments on commit 03a247e

Please sign in to comment.