Visible to Intel only — GUID: GUID-8729F6EB-8AE8-46DF-8ADE-2243ED0152CB
Visible to Intel only — GUID: GUID-8729F6EB-8AE8-46DF-8ADE-2243ED0152CB
IEEE_FLAGS
Portability Function: Gets, sets or clears IEEE flags for rounding direction and precision as well as queries or controls exception status. This function provides easy access to the modes and status required to use the features of ISO/IEC 60559:2020 arithmetic in a Fortran program.
Module
USE IFPORT
result = IEEE_FLAGS (action,mode,in,out)
action |
(Input) Character*(*). One of the following literal values: 'GET', 'SET', 'CLEAR', or 'CLEARALL'. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mode |
(Input) Character*(*). One of the following literal values: 'direction', 'precision', or 'exception'. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
in |
(Input) Character*(*). One of the following literal values: 'inexact', 'division', 'underflow','overflow', 'invalid', 'all', 'common', 'nearest', 'tozero', 'negative', 'positive','extended', 'double', 'single', or ' ', which represents an unused (null) value. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
out |
(Output) Must be at least CHARACTER*9. One of the literal values listed for in. The descriptions for the values allowed for in and out can be summarized as follows:
The values for in and out depend on the action and mode they are used with. The interaction of the parameters can be summarized as follows:
|
Results
IEEE_FLAGS is an elemental, integer-valued function that sets IEEE flags for GET, SET, CLEAR, or CLEARALL procedures. It lets you control rounding direction and rounding precision, query exception status, and control exception enabling or disabling by using the SET or CLEAR procedures, respectively.
The flags information is returned as a set of 1-bit flags.
Example
The following example gets the highest priority exception that has a flag raised. It passes the input argument in as a null string:
USE IFPORT
INTEGER*4 iflag
CHARACTER*9 out
iflag = ieee_flags('get', 'exception', '', out)
PRINT *, out, ' flag raised'
The following example sets the rounding direction to round toward zero, unless the hardware does not support directed rounding modes:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 mode, out, in
iflag = ieee_flags('set', 'direction', 'tozero', out)
The following example sets the rounding direction to the default ('nearest'):
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 out, in
iflag = ieee_flags('clear','direction', '', '' )
The following example clears all exceptions:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 out
iflag = ieee_flags('clear','exception', 'all', '' )
The following example restores default direction and precision settings, and sets all exception flags to 0:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 mode, out, in
iflag = ieee_flags('clearall', '', '', '')
The following example detects an underflow exception:
USE IFPORT
CHARACTER*20 out, in
excep_detect = ieee_flags('get', 'exception', 'underflow', out)
if (out .eq.'underflow') stop 'underflow'