Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ f77_ieee_environment(3F) — Sun FORTRAN 1.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

floatingpoint(3)

signal(3)

sigfpe(3)

f77_floatingpoint(3F)

ieee_flags(3M)

ieee_handler(3M)

F77_IEEE_ENVIRONMENT(3F)  —  FORTRAN LIBRARY ROUTINES

NAME

f77_ieee_environment - mode, status, and signal handling subprograms for IEEE arithmetic

SYNOPSIS

#include <f77/f77_floatingpoint.h>
integer function ieee_flags ( action, mode, in, out )
character∗(∗) action, mode, in, out
integer function ieee_handler ( action, exception, hdl )
character∗(∗) action, exception
sigfpe_handler_type hdl
sigfpe_handler_type function sigfpe ( code, hdl )
sigfpe_code_type code
sigfpe_handler_type hdl

DESCRIPTION

These subprograms provide modes and status required to fully exploit ANSI/IEEE Std 754-1985 arithmetic in a FORTRAN program.  They correspond closely to the functions ieee_flags(3M), ieee_handler(3M), and sigfpe(3). 

USAGE

All alphabetic string arguments must be lower case.  The following examples illustrate syntax.

integer ieeer
character∗1 mode, out, in
ieeer = ieee_flags ( ’clearall’, mode, in, out )

The sample above sets ieeer to 0, rounding direction to ’nearest’, rounding precision to ’extended’, and all accrued exception-occurred status to zero. 

character∗1 out, in
ieeer = ieee_flags ( ’clear’, ’direction’, in, out )

The sample above sets ieeer to 0, and rounding direction to ’nearest’. 

character∗1 out
ieeer = ieee_flags ( ’set’, ’direction’, ’tozero’, out )

The sample above sets ieeer to 0 and the rounding direction to ’tozero’ unless the hardware does not support directed rounding modes; then ieeer is set to 1. 

character∗16 out
ieeer = ieee_flags ( ’clear’, ’exception’, ’all’, out )

The sample above sets ieeer to 0 and clears all accrued exception-occurred bits.  If subsequently overflow, invalid, and inexact exceptions are generated then

character∗16 out
ieeer = ieee_flags ( ’get’, ’exception’, ’overflow’, out )

The sample above sets ieeer to 25 and out to ’overflow’. 

A user-specified signal handler might look like this:

integer function sample_handler ( sig, code, sigcontext )
integer sig
integer code
integer sigcontext(5)
cSample user-written sigfpe code handler.
cPrints a message and terminates.
csig .eq. SIGFPE always.
cThe structure of sigcontext is defined in <signal.h>.
print ∗, ’ieee exception code ’, loc(code), ’ occurred at pc ’, sigcontext(4)
call abort
end
and it might be set up like this:
external sample_handler
integer ieeer
ieeer = ieee_handler ( ’set’, ’overflow’, sample_handler )
if (ieeer .ne. 0) print ∗,’ ieee_handler can not set overflow ’

NOTES

1. UNIX invokes signal handlers by passing sig and code by value.  If you write a signal handler function in FORTRAN as in the example, you can access these values with the loc function.  2. Be sure to make all alphabetic string arguments lower case.

FILES

include/f77_floatingpoint.h
libm.a

SEE ALSO

floatingpoint(3), signal(3), sigfpe(3), f77_floatingpoint(3F), ieee_flags(3M), ieee_handler(3M)

Sun Release 4.1  —  Last change: 6 November 1990

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026