mizuRoute icon indicating copy to clipboard operation
mizuRoute copied to clipboard

Floating overflow in function flow_depth (hydraulic.f90)

Open BernardoTeufel opened this issue 6 months ago • 1 comments

The following code causes floating overflow crash for extremely small Qin values (e.g., 2.e-114): https://github.com/ESCOMP/mizuRoute/blob/64a49b0ffc3b584c253d8a8f93c9d01ebac5d6a6/route/build/src/hydraulic.f90#L409

Solved by changing the following line to: if (Qin>1.e-50_dp) then https://github.com/ESCOMP/mizuRoute/blob/64a49b0ffc3b584c253d8a8f93c9d01ebac5d6a6/route/build/src/hydraulic.f90#L356

Choice of 1.e-50_dp was based on the value used here: https://github.com/ESCOMP/mizuRoute/blob/64a49b0ffc3b584c253d8a8f93c9d01ebac5d6a6/route/build/src/tracer.f90#L291

An alternative could be 1.e-10_dp (unused variable so far): https://github.com/ESCOMP/mizuRoute/blob/64a49b0ffc3b584c253d8a8f93c9d01ebac5d6a6/route/build/src/public_var.f90#L44

BernardoTeufel avatar Jul 11 '25 19:07 BernardoTeufel

Hi Bernardo, I will need to sort this out. I did run into this problem before even before tracer was implemented. For 64bit, the smallest positive floating number can go even smaller than that

nmizukami avatar Jul 23 '25 14:07 nmizukami

Hi @BernardoTeufel, I am having a difficulty re-producing this error with my test cases, and wondering if you could share yours, so I can test on my own.

nmizukami avatar Nov 10 '25 17:11 nmizukami