What is/was Routine Under0()

What is/was Routine Under0()

I need to recompile an old Fortran program. The first thing it does is call UNDER0(TRUE). I can find no documentation on this library routine. What was its purpose? Is it safe to delete this call? The program SEEMS to work OK without it.

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Sounds like a vendor (not CVF) specific routine to turn off underflows or something of that sort. Perhaps the program ran into an occasional problem with an underflow or didn't it handle the condition well on a previous platform.


I am guessing here, but it looks like somehting that would enable a "flush to zero" response when underflow occurs (as opposed to creating a denormal result). On a lot of systems, creating denormal results is slow, as it is handled either by throwing an exception handled in software, or as an exceptional condition handled in microcode. Each such event could take several 100 clock cycles.

Forcing the result to 0 whenever a result underflows is very fast on the other hand as the HW can take of this and significant performance could be gained by doing so. Of course it might also lead to much worse numerical results (there is a reason that IEEE-754 introduced denormals). Also, underflows are unlikely to occur in software using double precision data as the range is quite large. It is more frequently an issue with programs using single precision data.

-- Norbert

I found the following in an old news posting using Google:

C**** For the Lahey F77L FORTRAN compiler on a PC, underflows result
C in NDP errors, unless the following system subroutine is
C executed.

Also via Google I found a Fortran code from 1990 apparently written for the Lahey compiler that says contains the following comment/code:

* This version compiled with Lahey Fortran and these options: *
call ovefl('true')
call under0('true')

-- Norbert

Thank you for your help. You were all on the money. Lahey tech support said:
A call to Under0() tells the runtime to load a zero in memory when an underflow occurs instead of reporting the underflow.

This is how LF95 runs by default. No need to call Under0(). If you want the runtime to report the underflow instead of storing zero, use the -trap option.


I noticed you also posted the same question to comp.lang.fortran. You might want to consider posting the solution over there so Google can preserve it for eternity and the next guy who stumbles across this can pick up the answer from there.

BTW, my LF95 manual does not list UNDER0(), only UNDFL(), with the explanation that this mask the underflow interrupt. Somehow I doubt that LF95 flushes the result to zero, as the masked response of the x86 FPU is to deliver a denormal.

-- Norbert

The CVF option to do this is to compile with /fpe:0


Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today