WRF icon indicating copy to clipboard operation
WRF copied to clipboard

WDM6 divide by zero

Open davegill opened this issue 4 years ago • 2 comments

Describe the bug Line 1168 in phys/module_mp_wdm6.F has ncr(i,k,2) rasied to the negative 1/3 power. When ncr(i,k,2) is zero, this is a divide by zero.

1168            praut(i,k) = qck1*qci(i,k,1)**(7./3.)*ncr(i,k,2)**(-1./3.)

The ncr variable is the number concentration for cloud, and is the local variable that is input. During the first time step, this value can be zero. There are a number of other locations to stop a divide by zero:

if(qci(i,k,1).le.qmin .or. ncr(i,k,2).le.ncmin ) then

To Reproduce Steps to reproduce the behavior:

  1. The regression test in the docker images has GNU 9.1.0
  2. Use the namelist options for test urb3bNE, and build the code with ./configure -D.
  3. The output is:
WRF TILE 1 IS 1 IE 74 JS 21 JE 40
WRF NUMBER OF TILES = 1
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.
Backtrace for this error:
#0 0x7f78fdb48dfd in ???
#1 0x7f78fdb48013 in ???
#2 0x7f78fce243ff in ???
#3 0x7f78fd857f20 in ???
#4 0x7f78fd85c14a in ???
#5 0x2d84418 in __module_mp_wdm6_MOD_wdm62d
at /wrf/WRF/phys/module_mp_wdm6.f90:1161

Expected behavior There needs to be protection on this computation to avoid divide by zero.

Attachments The namelist.input file:

 &physics
 fractional_seaice                   = 0,
 mp_physics                          = 16,    16,    16,
 ra_lw_physics                       = 14,    14,    14,
 ra_sw_physics                       = 14,    14,    14,
 radt                                = 6,     6,     6,
 sf_sfclay_physics                   = 2,     2,     2,
 sf_surface_physics                  = 4,     4,     4,
 bl_pbl_physics                      = 8,     8,     8,
 bldt                                = 0,     0,     0,
 cu_physics                          = 16,    16,    0,
 sf_urban_physics                    = 3,     3,     3,
 shcu_physics                        = 0,     0,     0,
 topo_shading                        = 0,     0,     0,
 cudt                                = 5,     5,     5,
 isfflx                              = 1,
 ifsnow                              = 0,
 icloud                              = 1,
 surface_input_source                = 1,
 num_soil_layers                     = 5,
 num_land_cat                        = 28,
 mp_zero_out                         = 0,
 maxiens                             = 1,
 maxens                              = 3,
 maxens2                             = 3,
 maxens3                             = 16,
 ensdim                              = 144,
 aer_opt                             = 2,
 aer_type                            = 1,
 aer_aod550_opt                      = 1,
 aer_aod550_val                      = 0.12
 aer_angexp_opt                      = 1,
 aer_angexp_val                      = 1.3
 aer_ssa_opt                         = 1,
 aer_ssa_val                         = 0.85
 aer_asy_opt                         = 1,
 aer_asy_val                         = 0.90
 /

davegill avatar Nov 05 '20 15:11 davegill

@dudhia @cenlinhe @weiwangncar Jimy, Can you bring this to the attention of Prof Hong?

davegill avatar Nov 05 '20 15:11 davegill

This was found with in PR "WRF-urban updates for the next WRF release" #1309

davegill avatar Nov 05 '20 15:11 davegill