I would like to know if there is a way to multiply or put together floating point numbers (or doubles) together without underflow error when compiling my Fortran code like
gfortran -ffpe-trap=invalid,zero,overflow,underflow ...
I know that a parameter is underflownot always a good idea, but I wonder if multiplication can be done with this option. In fact, in the following example, I know that under-execution may occur, but maybe I don't know another case in my codes. That is why I would like to keep this option, if possible.
Here is an example where I compute the vector u for each x, y matrix indices; The 2 values that make up these vectors are between 0 and 1. Then I calculate the square of my norm.
So it’s logical that due to this square operation I will have unreachable values. Since these very small values can be considered zero for me. Is there a underflowbetter way than comparison if?
implicit none
double :: u(100,100,2), uSqr(100,100)
integer :: x,y
DO x= 1, 100
DO y = 1, 100
CALL Poisin( u(x,y,:), x, y )
ENDDO
ENDDO
uSqr = u(:,:,1)*u(:,:,1) + u(:,:,2) * u(:,:,2) ! where comes the underflow errors