[MITgcm-support] Floating point overflows in gad_os7mp_adv_r

Constantinos Evangelinos ce107 at ocean.mit.edu
Wed May 21 10:23:30 EDT 2008


On Wed 21 May 2008, Martin Losch wrote:

> Christopher,
> since no-one competent is answering ...
>
> as far as I can see the "+Eps" is only supposed to avoid a division
> by zero. I assume that this "technique" is carried over to some
> extent from, say gad_dst3fl_adv_, where there  is no "abs".
> So my assumption is that you can even replace all instances of abs(Y
> +eps)/abs(X+eps) by (abs(Y)+eps)/(abs(X)+eps) and the algorithm
> should work, but it's up to you to prove it (to yourself). And if it
> works we should consider changing it in the code for everyone, so I
> am curious about your experience. The fact that this scheme is not
> really really documented (e.g. you need a overlap of 4 for it to
> work), tells you that this scheme is not fully established.
>
> Incidentally, I use this scheme for very high resolution grid and
> also for coarse resolution grid, and so far there haven't been any
> problems at all. Why, in your opinion, do you get the overflows and I
> (and others) don't?

Thanks Martin for saying the obvious that my lack of understanding of the 
scheme prevented me from uttering. Usually one adds eps to avoid division by 
zero. What I find surprising is that there is an addition of eps in the 
numerator as well.

Anyway one can catch this exactly where it happens to see what are the guilty 
values by using the IEEE control I've built in to the code. You need to: 
a) have a recent version of the code, 
b) define an environment variable GSLLIB='-lgsl -lgslcblas' (on a Linux box) 
or whatever is needed to get the GNU GSL library on your system 
c) add a -gsl to the genmake flags
d) build the code, making sure you have -g in your flags.
e) define an environment variable 
GSL_IEEE_MODE=double-precision,mask-underflow,mask-denormalized,mask-invalid,mask-division-by-zero
f) run the code under the debugger. It should stop at the exact line where you 
overflow. For more info on how to control GSL_IEEE_MODE go to:
http://www.gnu.org/software/gsl/manual/html_node/Setting-up-your-IEEE-environment.html

Constantinos
-- 
Dr. Constantinos Evangelinos
Department of Earth, Atmospheric and Planetary Sciences
Massachusetts Institute of Technology




More information about the MITgcm-support mailing list