24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Another method is to use the ieee_set_halting_mode subroutine in the<br />

ieee_exceptions module. This portable, elemental subroutine allows you to set the<br />

halting (trapping) status <strong>for</strong> any FPSCR exception flags. For example:<br />

USE, INTRINSIC :: ieee_exceptions<br />

TYPE(IEEE_STATUS_TYPE) SAVED_FPSCR<br />

CALL ieee_get_status(SAVED_FPSCR)<br />

! Saves the current value of the<br />

! fpscr register<br />

CALL ieee_set_halting_mode(IEEE_DIVIDE_BY_ZERO, .TRUE.) ! Enabled trapping<br />

! ... ! of divide-by-zero.<br />

CALL IEEE_SET_STATUS(SAVED_FPSCR)<br />

! Restore fpscr register<br />

xlf_fp_util Procedures<br />

The xlf_fp_util procedures allow you to query and control the floating-point status<br />

and control register (fpscr) of the processor directly. These procedures are more<br />

efficient than the fpsets and fpgets subroutines because they are mapped into<br />

inlined machine instructions that manipulate the floating-point status and control<br />

register directly.<br />

The intrinsic module, xlf_fp_util, contains the interfaces and data type definitions<br />

<strong>for</strong> these procedures and the definitions <strong>for</strong> the named constants that are needed<br />

by the procedures. This module enables type checking of these procedures at<br />

compile time rather than link time. The following files are supplied <strong>for</strong> the<br />

xlf_fp_util module:<br />

File names File type Locations<br />

xlf_fp_util.mod<br />

module symbol file<br />

(32–bit)<br />

module symbol file<br />

(64–bit)<br />

/usr/lpp/xlf/include_d7<br />

/usr/lpp/xlf/include<br />

/usr/lpp/xlf/include<br />

To use the procedures, you must add a USE <strong>XL</strong>F_FP_UTIL statement to your<br />

source file. For more in<strong>for</strong>mation, see USE, in the <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong><br />

<strong>AIX</strong> Language Reference.<br />

When compiling with the -U option, you must code the names of these procedures<br />

in all lowercase.<br />

For a list of the xlf_fp_util procedures, see the Service and Utility Procedures section<br />

in the <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> Language Reference.<br />

fpgets and fpsets Subroutines<br />

The fpsets and fpgets subroutines provide a way to manipulate or query the<br />

floating-point status and control register. Instead of calling the operating system<br />

routines directly, you pass in<strong>for</strong>mation back and <strong>for</strong>th in fpstat, an array of<br />

logicals. The following table shows the most commonly used array elements that<br />

deal with exceptions:<br />

Table 19. Exception Bits to Use with fpsets and fpgets<br />

Array Element to<br />

Set to Enable<br />

Array Element to<br />

Check if Exception<br />

Occurred<br />

Exception Indicated When .TRUE.<br />

n/a fpstat(fpfx) Floating-point exception summary<br />

300 <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> : User’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!