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

Appendtail potential divide-by-zero fix: cherry pick from dev/ufs-weather-model #1188

Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions model/src/cmake/src_list.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,3 @@ set(scripnc_src
${CMAKE_CURRENT_SOURCE_DIR}/SCRIP/scrip_remap_write.f
${CMAKE_CURRENT_SOURCE_DIR}/SCRIP/scrip_remap_read.f
)


18 changes: 15 additions & 3 deletions model/src/w3fld1md.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,11 @@ SUBROUTINE APPENDTAIL(INSPC, WN2, NKT, KA1, KA2, KA3, WNDDIR,SAT)
DO K=KA1, KA2-1
AVG=SUM(INSPC(K,:))/MAX(REAL(NTH),1.)
DO T=1,NTH
INSPC(K,T)=BT(K)*INSPC(K,T)/TPI/(WN2(K)**3.0)/AVG
if (avg /= 0.0) then
INSPC(K,T)=BT(K)*INSPC(K,T)/TPI/(WN2(K)**3.0)/AVG
else
inspc(k,t) = 0.0
end if
ENDDO
ENDDO
!-----------------------------------------------------------
Expand All @@ -1138,7 +1142,11 @@ SUBROUTINE APPENDTAIL(INSPC, WN2, NKT, KA1, KA2, KA3, WNDDIR,SAT)
ENDDO
AVG=SUM(NORMSPC)/MAX(REAL(NTH),1.)
DO T=1, NTH
INSPC(K,T) = SAT * NORMSPC(T)/TPI/(WN2(K)**3.0)/AVG
if (avg /= 0.0) then
INSPC(K,T) = SAT * NORMSPC(T)/TPI/(WN2(K)**3.0)/AVG
else
inspc(k,t) = 0.0
end if
ENDDO
ENDDO
DO T=1, NTH
Expand All @@ -1152,7 +1160,11 @@ SUBROUTINE APPENDTAIL(INSPC, WN2, NKT, KA1, KA2, KA3, WNDDIR,SAT)
AVG=SUM(NORMSPC)/MAX(REAL(NTH),1.)!1./4.
DO K=KA3+1, NKT
DO T=1, NTH
INSPC(K,T)=NORMSPC(T)*(SAT)/TPI/(WN2(K)**3.0)/AVG
if (avg /= 0.0) then
INSPC(K,T)=NORMSPC(T)*(SAT)/TPI/(WN2(K)**3.0)/AVG
else
inspc(k,t) = 0.0
end if
ENDDO
ENDDO
DEALLOCATE(ANGLE1)
Expand Down
Loading