E3SM-Project / E3SM-Project/E3SM

Divide-by-zero in advance_windm_edsclrm_module.F90

Open
#2,186 3 comments 0 reactions 2 assignees Claimed by @vlarson View on GitHub
Atmosphere question
Dominant language
Fortran
Stars
440
Forks
481
Avg merge
4d 7h
Merged PRs (30d)
33

Description

Ran into this error with ne120-wcycl runs (`SMS_D.ne120_oRRS18v3_ICG.A_WCYCL1950S_CMIP6_HR.theta_intel.cam-cosplite`)
```
3439: forrtl: error (73): floating divide by zero
3439: Image PC Routine Line Source
3439: e3sm.exe 000000000375F18D advance_windm_eds 1891 advance_windm_edsclrm_module.F90
3439: e3sm.exe 000000000374C6CA advance_windm_eds 509 advance_windm_edsclrm_module.F90
3439: e3sm.exe 000000000370A989 advance_clubb_cor 2019 advance_clubb_core_module.F90
3439: e3sm.exe 00000000021A0930 clubb_intr_mp_clu 1855 clubb_intr.F90
3439: e3sm.exe 0000000000D31B4B physpkg_mp_tphysb 2460 physpkg.F90
3439: e3sm.exe 0000000000D0848F physpkg_mp_phys_r 1027 physpkg.F90
3439: e3sm.exe 000000000081FFA5 cam_comp_mp_cam_r 250 cam_comp.F90
3439: e3sm.exe 00000000007EF416 atm_comp_mct_mp_a 341 atm_comp_mct.F90
3439: e3sm.exe 00000000004557E3 component_mod_mp_ 267 component_mod.F90
3439: e3sm.exe 000000000042A297 cime_comp_mod_mp_ 1958 cime_comp_mod.F90
3439: e3sm.exe 000000000044B66B MAIN__ 92 cime_driver.F90
```

This can be prevented by the following patch:
```
diff --git a/components/cam/src/physics/clubb/grid_class.F90 b/components/cam/src/physics/clubb/grid_class.F90
index 1a68eec59..e28aa45fe 100644
--- a/components/cam/src/physics/clubb/grid_class.F90
+++ b/components/cam/src/physics/clubb/grid_class.F90
@@ -718,6 +718,10 @@ module grid_class
! Define invrs_dzm, which is the inverse spacing between thermodynamic grid
! levels; centered over momentum grid levels.
do k=1,gr%nz-1
+ if (gr%zt(k+1) - gr%zt(k) == 0) then
+ write(fstderr,*) 'Detected div-by-0 with gr%zt', k,gr%nz,gr%zt(k+1),gr%zt(k)
+ stop
+ endif
gr%invrs_dzm(k) = 1._core_rknd / ( gr%zt(k+1) - gr%zt(k) )
enddo
gr%invrs_dzm(gr%nz) = gr%invrs_dzm(gr%nz-1)
@@ -726,6 +730,10 @@ module grid_class
! Define invrs_dzt, which is the inverse spacing between momentum grid
! levels; centered over thermodynamic grid levels.
do k=2,gr%nz
+ if (gr%zm(k) - gr%zm(k-1) == 0) then
+ write(fstderr,*) 'Detected div-by-0 with gr%zm', k,gr%nz,gr%zm(k),gr%zm(k-1)
+ stop
+ endif
gr%invrs_dzt(k) = 1._core_rknd / ( gr%zm(k) - gr%zm(k-1) )
enddo
gr%invrs_dzt(1) = gr%invrs_dzt(2)
```

This is only for better error-checking and might save some time chasing it the next time it happens.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.