Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ f77_ieee_environment(3F) — Sun FORTRAN 1.1

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

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). 

EXAMPLES

The following examples illustrate syntax. 

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

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)
 

sets ieeer to 0, and rounding direction to ’nearest’. 

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

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)
 

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)
 

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 ’,code,’ occurred at pc ’,sigcontext(4)
call abort(’ ieee exception occurred ’)
end
 and it might be set up like this:
 extern sample_handler
integer ieeer
ieeer = ieee_handler ( ’set’, ’overflow’, sample_handler )
if (ieeer .ne. 0) print ∗,’ ieee_handler can not set overflow ’
 

FILES

/usr/include/f77/f77_floatingpoint.h
/usr/lib/libm.a

SEE ALSO

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

Sun Release 4.0  —  Last change: 23 March 1988

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