- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Randy
Randy
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
C
CLAH CALL UNDER0(.TRUE.)
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
C**** For the Lahey F77L FORTRAN compiler on a PC, underflows result
C in NDP errors, unless the following system subroutine is
C executed.
C
CLAH CALL UNDER0(.TRUE.)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Randy
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.
Randy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Randy,
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The CVF option to do this is to compile with /fpe:0
Steve
Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page