-
Notifications
You must be signed in to change notification settings - Fork 138
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
icepack_algae underflow #126
Comments
This needs to be recoded. Either rtau_ret or rtau_rel will always be zero, and so one of the exp() will always underflow. It would be better to put the calculation of the exp in the conditional block above this, where rtau_ret and rtau_rel are computed, and then just use the values here. |
I understand what you're getting at. When those values are zero, I assume the exp should be treated as zero? So if rtau_ret is zero, |
If rtau is zero, then exp(dt*rtau)=1, and the expressions that have 1-exp() should be zero. So if rtau_ret=0, then the mobile term is zero and we use the stationary term, and vice versa if rtau_rel=0. |
OK. There is another issue. I have found another case where rtau_ret is 1.0 and ts = 3600. The exp is under-flowing in that condition and then we'd be left with a "0" with the "exp" value so exp-1 or 1-exp would just be 1 or -1. Mostly, rtau_ret and rtau_rel are about 1e-4 which matches up OK with ts=3600. I need a little more help here about what to do. There seem to be cases where rtau_* is zero and other cases where exp(-rtauts) truly is underflowing on large negative rtauts. Maybe there are other cases too. Can rtau*ts ever be negative? |
Since rtau_ret and rtau_rel are both frequencies in units of 1/s, I don't think they should ever be negative. They are both initialized to 1 in icedrv_init_column.F90, but they should not stay that way unless bgc_tracer_type < 0. The code comments indicate that this is actually the default condition, so this will always produce underflows in the exponential. Now I am beginning to understand this better -- I think the intent is that the exponential should go to zero, and my comments above are not really the problem. Is the logic is incomplete?
simplified logic:
But again, I think that the exponentials should be calculated rather than the timescales. Does this capture the various cases? tau_ret and tau_rel are set using tau_min/max from namelist.
|
So, I sort of did the same thing yesterday, following the argmax of some other implementations, but I think what you propose is better. Is the tau_ret>c1 the right logic? was c1 chosen because it was the default value? the default should be a negative number, say -99 so it can be flagged more clearly. And then that logic should be >c0. but it looks like the default is set outside the columnphysics, so how can we be sure any default is set, and that it will be 1. What if it's set to 2 by default by the driver? There is a bunch of dicey stuff here. Maybe we need something like
Also, one final thought. e-10 is only about 5e-5. Why is argmax 10? Why not 20 (e-20=2e-9) or even a more. 10 is smaller than it could be, you are much greater than needed to protect the underflow. You can probably go to a couple hundred with double precision and still not underflow. That's a separate question though. |
@njeffery We've merged this change but I'd still appreciate it if you'd check the logic in ice_algae.F90 (as above) to make sure it's doing what you intend. Thx! |
Regarding this question:
e-10 is a value that was (I think) chosen by Bruce Briegleb when he was implementing the delta-Eddington radiation. I'm not sure why he chose that value, but my impression was that it was as big as he was comfortable with given the data that he and Bonnie had to build the radiation scheme. So it's specific to the radiation. In my opinion, we could increase the maximum (negative) argument by an order of magnitude (to 100). We also don't have to use the same value everywhere in the code, though I prefer consistency for stuff like that. |
Update documentation
icepack_algae is underflowing in the second part of this line with gnu compiler and debug+bgcISPOL.
If anyone has any ideas, I'm happy to implement and test.
The text was updated successfully, but these errors were encountered: